aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2013-11-14 16:18:23 +0000
committerBryn M. Reeves <bmr@redhat.com>2013-11-14 16:18:23 +0000
commitf2b8c12427843f1ebe5c5f89971eeaffc36ebd44 (patch)
tree7f2d07f189fd8b6e41c83196fc8aeb41284d217b
parent4ef079272a4c8d6e17f687a50a39de4241596cd1 (diff)
downloadsos-f2b8c12427843f1ebe5c5f89971eeaffc36ebd44.tar.gz
Fix regressions introduced with --build option
The changes to reinstate the --build option introduced two regressions: - Running sosreport with no otions generates a backtrace due to a non-existant _build member in the SoSOptions object - Running sosreport without --build leaves the temporary archive directory in places with the sos_logs directory containing sos.log and ui.log due to changes in the order of log shutdown and archive creation. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/policies/__init__.py26
-rw-r--r--sos/sosreport.py23
2 files changed, 27 insertions, 22 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 46b41e0c..d4bec69e 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -254,26 +254,32 @@ No changes will be made to system configuration.
to use"""
return "md5"
- def display_results(self, final_filename=None):
+ def display_results(self, final_filename=None, build=False):
# make sure a report exists
if not final_filename:
return False
- # store checksum into file
- fp = open(final_filename + "." + get_hash_name(), "w")
- checksum = self._create_checksum(final_filename)
- if checksum:
- fp.write(checksum + "\n")
- fp.close()
-
self._print()
- self._print(_("Your sosreport has been generated and saved in:\n %s") % final_filename)
+
+ if not build:
+ # store checksum into file
+ fp = open(final_filename + "." + get_hash_name(), "w")
+ checksum = self._create_checksum(final_filename)
+ if checksum:
+ fp.write(checksum + "\n")
+ fp.close()
+
+ self._print(_("Your sosreport has been generated and saved in:\n %s") % final_filename)
+ else:
+ checksum = None
+ self._print(_("sosreport build tree is located at : %s" % final_filename))
+
self._print()
if checksum:
self._print(_("The checksum is: ") + checksum)
self._print()
- self._print(_("Please send this file to your support representative."))
+ self._print(_("Please send this file to your support representative."))
self._print()
def upload_results(self, final_filename):
diff --git a/sos/sosreport.py b/sos/sosreport.py
index f297b670..0076d64d 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -212,6 +212,7 @@ class SoSOptions(object):
_usealloptions = False
_upload = False
_batch = False
+ _build = False
_verbosity = 0
_quiet = False
_debug = False
@@ -1119,11 +1120,12 @@ class SoSReport(object):
raise
def final_work(self):
-
+ # this must come before archive creation to ensure that log
+ # files are closed and cleaned up at exit.
+ self._finish_logging()
# package up the results for the support organization
if not self.opts.build:
- self.ui_log.info(_("Creating compressed archive..."))
-
+ print _("Creating compressed archive...")
# compression could fail for a number of reasons
try:
final_filename = self.archive.finalize(self.opts.compression_type)
@@ -1133,17 +1135,14 @@ class SoSReport(object):
else:
return False
- # automated submission will go here
- if not self.opts.upload:
- self.policy.display_results(final_filename)
- else:
- self.policy.upload_results(final_filename)
-
else:
- self.ui_log.info(_("\n sosreport build tree is located at : %s\n"
- % self.archive.get_archive_path()))
+ final_filename = self.archive.get_archive_path()
- self._finish_logging()
+ # automated submission will go here
+ if not self.opts.upload:
+ self.policy.display_results(final_filename, build = self.opts.build)
+ else:
+ self.policy.upload_results(final_filename)
self.tempfile_util.clean()