[sos-devel] [PATCH v3] sosreport: Check for rpm database corruption during initialization
Bryn M. Reeves
bmr at redhat.com
Thu Dec 11 11:14:05 UTC 2014
On Thu, Dec 11, 2014 at 12:15:30PM +0530, Aruna Balakrishnaiah wrote:
> On Wednesday 10 December 2014 11:02 PM, Bryn M. Reeves wrote:
> >Why use distutils.log here? It's not used anywhere else in sos; it
> >would be cleaner to just print to stderr:
> >
> > print(error_message, file=sys.stderr)
>
> Bryn,
>
> This is available only since Python 3.0, lower versions are not supporting this.
No that's not correct - 3.0 just makes the print function the default
(and remove the print statement). The print() function is available in
python 2.6 (our oldest supported runtime) and onwards via the __future__
module:
# python
Python 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_statement
>>> print("error", file=sys.stderr)
error
We use __future__ features (with_statement) in several places already
so it'd be fine to use for this purpose.
>
> >
> >There is also the Policy._print() method (which also obeys the
> >setting of --quiet).
>
> Is there a need to create a new Policy instance just to print?Can I just use
> print_ ?
> And should we not print this error message even if its in quiet mode.
As it's an error it should also appear on stderr rather than stdout;
that's the sort of API change that may be needed to implement a change
like this.
Regards,
Bryn.
More information about the sos-devel
mailing list