summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-05-25 16:23:29 +0300
committerLars Wirzenius <liw@liw.fi>2017-05-25 16:26:16 +0300
commitd4b86a2ad1ab6717bad897c45f43221eadd8f368 (patch)
tree62cdcddda6f4b70dfd5ac32a0f8d152f690b079f
parentb728b0eb764dce8493eaf3f6c661e6aafcdc042f (diff)
downloadobnam-d4b86a2ad1ab6717bad897c45f43221eadd8f368.tar.gz
Fix: Hide Python stack trace on SSH problems
-rw-r--r--NEWS4
-rw-r--r--obnamlib/app.py10
2 files changed, 14 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 4eeeda63..cfd4be0c 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,10 @@ Version 1.21+git, not yet released
* SanskritFritz and Ian Cambell fixed the kdirstat plugin.
+* Lars Wirzenius changed Obnam to hide a Python stack trace when
+ there's a problem with the SSH connection (e.g., failure to
+ authenticate, or existing connection breaks).
+
Version 1.21, released 2016-12-29
------------------------------------
diff --git a/obnamlib/app.py b/obnamlib/app.py
index ce32f242..e5d76010 100644
--- a/obnamlib/app.py
+++ b/obnamlib/app.py
@@ -22,6 +22,7 @@ import tracing
import cliapp
import larch
+import paramiko
import ttystatus
import obnamlib
@@ -32,6 +33,11 @@ class ObnamIOError(obnamlib.ObnamError):
msg = 'I/O error: {filename}: {errno}: {strerror}'
+class ObnamSSHError(obnamlib.ObnamError):
+
+ msg = 'SSH error: {msg}'
+
+
class ObnamSystemError(obnamlib.ObnamError):
msg = 'System error: {filename}: {errno}: {strerror}'
@@ -221,6 +227,10 @@ class App(cliapp.Application):
self.hooks.call('config-loaded')
cliapp.Application.process_args(self, args)
self.hooks.call('shutdown')
+ except paramiko.SSHException as e:
+ logging.critical(
+ 'Caught SSHExcpetion: %s', str(e), exc_info=True)
+ raise ObnamSSHError(msg=str(e))
except IOError as e:
logging.critical('Caught IOError: %s', str(e), exc_info=True)
raise ObnamIOError(