aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/policies/__init__.py24
-rw-r--r--sos/sosreport.py12
2 files changed, 23 insertions, 13 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index bf9afde0..5b0b7063 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -285,11 +285,11 @@ No changes will be made to system configuration.
considered to be a superuser"""
return (os.getuid() == 0)
- def _create_checksum(self, hash_name, final_filename=None):
- if not final_filename:
+ def _create_checksum(self, hash_name, archive=None):
+ if not archive:
return False
- archive_fp = open(final_filename, 'rb')
+ archive_fp = open(archive, 'rb')
digest = hashlib.new(hash_name)
digest.update(archive_fp.read())
archive_fp.close()
@@ -300,29 +300,33 @@ No changes will be made to system configuration.
to use"""
return "md5"
- def display_results(self, final_filename=None, build=False):
+ def display_results(self, archive, directory):
+ # Display results is called from the tail of SoSReport.final_work()
+ #
+ # Logging is already shutdown and all terminal output must use the
+ # print() call.
# make sure a report exists
- if not final_filename:
+ if not archive and not directory:
return False
self._print()
hash_name = self.get_preferred_hash_name()
- if not build:
+ if archive:
# store checksum into file
- fp = open(final_filename + "." + hash_name, "w")
- checksum = self._create_checksum(hash_name, final_filename)
+ fp = open(archive + "." + hash_name, "w")
+ checksum = self._create_checksum(hash_name, archive)
if checksum:
fp.write(checksum + "\n")
fp.close()
self._print(_("Your sosreport has been generated and saved "
- "in:\n %s") % final_filename)
+ "in:\n %s") % archive)
else:
checksum = None
self._print(_("sosreport build tree is located at : %s" %
- final_filename))
+ directory))
self._print()
if checksum:
diff --git a/sos/sosreport.py b/sos/sosreport.py
index a1f1b96c..f3e0f346 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -1436,6 +1436,10 @@ class SoSReport(object):
# this must come before archive creation to ensure that log
# files are closed and cleaned up at exit.
self._finish_logging()
+
+ archive = None # archive path
+ directory = None # report directory path (--build)
+
# package up the results for the support organization
if not self.opts.build:
old_umask = os.umask(0o077)
@@ -1443,7 +1447,7 @@ class SoSReport(object):
print(_("Creating compressed archive..."))
# compression could fail for a number of reasons
try:
- final_filename = self.archive.finalize(
+ archive = self.archive.finalize(
self.opts.compression_type)
except (OSError, IOError) as e:
if e.errno in fatal_fs_errors:
@@ -1460,8 +1464,10 @@ class SoSReport(object):
finally:
os.umask(old_umask)
else:
- final_filename = self.archive.get_archive_path()
- self.policy.display_results(final_filename, build=self.opts.build)
+ directory = self.archive.get_archive_path()
+
+ self.policy.display_results(archive, directory)
+
self.tempfile_util.clean()
return True