aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/__init__.py27
-rw-r--r--sos/__init__.py.in1
-rw-r--r--sos/archive.py45
-rw-r--r--sos/reporting.py32
4 files changed, 65 insertions, 40 deletions
diff --git a/sos/__init__.py b/sos/__init__.py
index fc6738b6..ae46c511 100644
--- a/sos/__init__.py
+++ b/sos/__init__.py
@@ -1,19 +1,19 @@
-## Copyright 2010 Red Hat, Inc.
-## Author: Adam Stokes <astokes@fedoraproject.org>
+# Copyright 2010 Red Hat, Inc.
+# Author: Adam Stokes <astokes@fedoraproject.org>
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
This module houses the i18n setup and message function. The default is to use
@@ -28,6 +28,7 @@ gettext_app = "sos"
gettext.bindtextdomain(gettext_app, gettext_dir)
+
def _default(msg):
return gettext.dgettext(gettext_app, msg)
diff --git a/sos/__init__.py.in b/sos/__init__.py.in
index 36b15382..e239e37c 100644
--- a/sos/__init__.py.in
+++ b/sos/__init__.py.in
@@ -28,6 +28,7 @@ gettext_app = "sos"
gettext.bindtextdomain(gettext_app, gettext_dir)
+
def _default(msg):
return gettext.dgettext(gettext_app, msg)
diff --git a/sos/archive.py b/sos/archive.py
index a56c7123..c0d3d426 100644
--- a/sos/archive.py
+++ b/sos/archive.py
@@ -1,20 +1,20 @@
-## Copyright (C) 2012 Red Hat, Inc.,
-## Jesse Jaggars <jjaggars@redhat.com>
-## Bryn M. Reeves <bmr@redhat.com>
-##
-### This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Copyright (C) 2012 Red Hat, Inc.,
+# Jesse Jaggars <jjaggars@redhat.com>
+# Bryn M. Reeves <bmr@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
import time
import tarfile
@@ -52,7 +52,7 @@ class Archive(object):
_name = "unset"
_debug = False
- def _format_msg(self,msg):
+ def _format_msg(self, msg):
return "[archive:%s] %s" % (self.archive_type(), msg)
def set_debug(self, debug):
@@ -61,7 +61,7 @@ class Archive(object):
def log_error(self, msg):
self.log.error(self._format_msg(msg))
- def log_warn(self,msg):
+ def log_warn(self, msg):
self.log.warning(self._format_msg(msg))
def log_info(self, msg):
@@ -132,7 +132,7 @@ class FileCacheArchive(Archive):
self._archive_root = os.path.join(tmpdir, name)
os.makedirs(self._archive_root, 0o700)
self.log_info("initialised empty FileCacheArchive at '%s'" %
- (self._archive_root,))
+ (self._archive_root,))
def dest_path(self, name):
if os.path.isabs(name):
@@ -223,11 +223,11 @@ class FileCacheArchive(Archive):
def finalize(self, method):
self.log_info("finalizing archive '%s' using method '%s'"
- % (self._archive_root, method))
+ % (self._archive_root, method))
self._build_archive()
self.cleanup()
self.log_info("built archive at '%s' (size=%d)" % (self._archive_name,
- os.stat(self._archive_name).st_size))
+ os.stat(self._archive_name).st_size))
self.method = method
return self._compress()
@@ -327,6 +327,7 @@ class ZipFileArchive(Archive):
self._name = name
try:
import zlib
+ assert zlib
self.compression = zipfile.ZIP_DEFLATED
except:
self.compression = zipfile.ZIP_STORED
diff --git a/sos/reporting.py b/sos/reporting.py
index 809af705..709aaf07 100644
--- a/sos/reporting.py
+++ b/sos/reporting.py
@@ -1,4 +1,23 @@
-"""This provides a restricted tag language to define the sosreport index/report"""
+# Copyright (C) 2014 Red Hat, Inc.,
+# Bryn M. Reeves <bmr@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+""" This provides a restricted tag language to define the sosreport
+ index/report
+"""
try:
import json
@@ -8,6 +27,7 @@ except ImportError:
# PYCOMPAT
from six import iteritems
+
class Node(object):
def __str__(self):
@@ -100,9 +120,9 @@ class Note(Leaf):
class PlainTextReport(object):
"""Will generate a plain text report from a top_level Report object"""
- LEAF = " * %(name)s"
+ LEAF = " * %(name)s"
ALERT = " ! %s"
- NOTE = " * %s"
+ NOTE = " * %s"
DIVIDER = "=" * 72
subsections = (
@@ -120,10 +140,12 @@ class PlainTextReport(object):
def __str__(self):
self.buf = buf = []
- for section_name, section_contents in sorted(iteritems(self.report_node.data)):
+ for section_name, section_contents in sorted(iteritems(
+ self.report_node.data)):
buf.append(section_name + "\n" + self.DIVIDER)
for type_, format_, header in self.subsections:
- self.process_subsection(section_contents, type_.ADDS_TO, header, format_)
+ self.process_subsection(section_contents, type_.ADDS_TO,
+ header, format_)
return "\n".join(buf)