diff options
author | Thomas Waldmann <tw@waldmann-edv.de> | 2015-02-27 16:44:33 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-03-22 14:07:22 +0200 |
commit | e753aa4298c657ec507a1afb59a6e0f463f190e9 (patch) | |
tree | 01d81e360d433041bcc3fb010a1206c0a3593486 | |
parent | 0909a1f59b0aef635ebe4c29e61b7ac887cc8d56 (diff) | |
download | obnam-e753aa4298c657ec507a1afb59a6e0f463f190e9.tar.gz |
refactor slightly misleading code, improve logging
there were 2 issues with the code:
a) the logging logged "port=None" when self.port was None, which is a bit unpretty as None just meant default, which is 22 in the end.
b) remote was either assigned a tuple or a string with unneeded parens (which almost looks like a tuple, except that missing comma).
it still worked, because paramiko can deal with getting a string or a tuple. in case of the string, paramiko would try to parse the port from the string though, which is not needed because obnam already did that and port is only None if no port was found in the sftp url.
-rw-r--r-- | obnamlib/plugins/sftp_plugin.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py index 6329e520..a496c1d6 100644 --- a/obnamlib/plugins/sftp_plugin.py +++ b/obnamlib/plugins/sftp_plugin.py @@ -244,12 +244,9 @@ class SftpFS(obnamlib.VirtualFileSystem): return True def _connect_paramiko(self): + remote = (self.host, self.port or 22) logging.debug( - 'connect_paramiko: host=%s port=%s' % (self.host, self.port)) - if self.port: - remote = (self.host, self.port) - else: - remote = (self.host) + 'connect_paramiko: host=%s port=%s' % remote) self.transport = paramiko.Transport(remote) self.transport.connect() logging.debug('connect_paramiko: connected') |