Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sos/sosreport.py: more py3/py2 compatability changes

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
  • Loading branch information...
commit 0552c421cbf0f7c99c92737f8df10f35f67a2060 1 parent 94016f3
Adam Stokes battlemidget authored
Showing with 14 additions and 6 deletions.
  1. +1 −0  setup.py
  2. +13 −6 sos/sosreport.py
1  setup.py
View
@@ -67,5 +67,6 @@ def _find_mo_files(self):
],
packages=['sos', 'sos.plugins', 'sos.policies'],
cmdclass={'build': BuildData, 'install_data': InstallData},
+ requires=['six'],
)
19 sos/sosreport.py
View
@@ -37,13 +37,11 @@
import os
import logging
from optparse import OptionParser, Option
-import ConfigParser
from sos.plugins import import_plugin
from sos.utilities import ImporterHelper
from stat import ST_UID, ST_GID, ST_MODE, ST_CTIME, ST_ATIME, ST_MTIME, S_IMODE
from time import strftime, localtime
from collections import deque
-from itertools import izip
import textwrap
import tempfile
@@ -53,6 +51,15 @@
from sos.archive import TarFileArchive, ZipFileArchive
from sos.reporting import Report, Section, Command, CopiedFile, CreatedFile, Alert, Note, PlainTextReport
+# PYCOMPAT
+import six
+from six.moves import zip
+if six.PY3:
+ from configparser import ConfigParser
+else:
+ from ConfigParser import ConfigParser
+
+
class TempFileUtil(object):
def __init__(self, tmp_dir):
@@ -638,7 +645,7 @@ def exit_handler(signum, frame):
return exit_handler
def _read_config(self):
- self.config = ConfigParser.ConfigParser()
+ self.config = ConfigParser()
if self.opts.config_file:
config_file = self.opts.config_file
else:
@@ -662,10 +669,10 @@ def _setup_logging(self):
if not self.opts.quiet:
console = logging.StreamHandler(sys.stderr)
console.setFormatter(logging.Formatter('%(message)s'))
- if self.opts.verbosity > 1:
+ if self.opts.verbosity and self.opts.verbosity > 1:
console.setLevel(logging.DEBUG)
flog.setLevel(logging.DEBUG)
- elif self.opts.verbosity > 0:
+ elif self.opts.verbosity and self.opts.verbosity > 0:
console.setLevel(logging.INFO)
else:
console.setLevel(logging.ERROR)
@@ -979,7 +986,7 @@ def collect(self):
self.ui_log.info("")
plugruncount = 0
- for i in izip(self.loaded_plugins):
+ for i in zip(self.loaded_plugins):
plugruncount += 1
plugname, plug = i[0]
if not self.opts.quiet:
Please sign in to comment.
Something went wrong with that request. Please try again.