aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2017-07-16 13:44:32 -0400
committerBryn M. Reeves <bmr@redhat.com>2018-03-28 12:03:51 +0100
commit0f88926f43cc1b113811c3471902eae203d54955 (patch)
tree7c7a176282f46f2820d05acac62cf28d97b9fbbe
parenta05619cb550e3597e569e1e53b9bbaece731457b (diff)
downloadsos-0f88926f43cc1b113811c3471902eae203d54955.tar.gz
[sosreport] Fix exit status propagation
This fixes exit status propagation so that sos will now properly exit with a non-zero exit code when appropriate, such as when a keyboard interrupt is issued. Additionally, this fixes an issue when a NameError would be hit when using --debug due to FileNotFoundError not existing in python 2.7. Resolves: #672 Closes: #1062 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py6
-rw-r--r--sos/sosreport.py5
2 files changed, 8 insertions, 3 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 2a8bc516..4d52b150 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -33,6 +33,12 @@ import errno
import six
from six.moves import zip, filter
+# FileNotFoundError does not exist in 2.7, so map it to IOError
+try:
+ FileNotFoundError
+except NameError:
+ FileNotFoundError = IOError
+
def _to_u(s):
if not isinstance(s, six.text_type):
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 121459c1..8bfc95fd 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -791,7 +791,6 @@ class SoSReport(object):
def _exit(self, error=0):
raise SystemExit(error)
-# sys.exit(error)
def get_exit_handler(self):
def exit_handler(signum, frame):
@@ -1177,9 +1176,9 @@ class SoSReport(object):
msg += _("Press ENTER to continue, or CTRL-C to quit.\n")
try:
input(msg)
- except:
+ except Exception as err:
self.ui_log.info("")
- self._exit()
+ self._exit(err)
def _log_plugin_exception(self, plugin, method):
trace = traceback.format_exc()