aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stokes <adam.stokes@ubuntu.com>2013-11-12 09:51:25 -0500
committerAdam Stokes <adam.stokes@ubuntu.com>2013-11-12 09:51:25 -0500
commit0552c421cbf0f7c99c92737f8df10f35f67a2060 (patch)
tree68131074abedbd117235af088a69f9e6364b1680
parent94016f353a2f35ca7fabf85b269ca90527c0fc37 (diff)
downloadsos-0552c421cbf0f7c99c92737f8df10f35f67a2060.tar.gz
sos/sosreport.py: more py3/py2 compatability changes
Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
-rw-r--r--setup.py1
-rw-r--r--sos/sosreport.py19
2 files changed, 14 insertions, 6 deletions
diff --git a/setup.py b/setup.py
index eb20a12c..0ae87b3e 100644
--- a/setup.py
+++ b/setup.py
@@ -67,5 +67,6 @@ setup(name='sosreport',
],
packages=['sos', 'sos.plugins', 'sos.policies'],
cmdclass={'build': BuildData, 'install_data': InstallData},
+ requires=['six'],
)
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 04035a92..66a3ab8e 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -37,13 +37,11 @@ import traceback
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 @@ import sos.policies
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 @@ class SoSReport(object):
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 @@ class SoSReport(object):
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 @@ class SoSReport(object):
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: