From 201b5d759e5a0f97d7016664e947f6ce3b632721 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 13 Feb 2020 21:42:30 +0100 Subject: ssh_client/remote: add __str__ methods to ease debugging --- bupper/_ssh_client.py | 6 ++++++ bupper/ssh_remote.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/bupper/_ssh_client.py b/bupper/_ssh_client.py index f1c9e23..dec3390 100644 --- a/bupper/_ssh_client.py +++ b/bupper/_ssh_client.py @@ -13,6 +13,7 @@ class SSHConnection: """ _proxy_conn = None _client = None + _remote = None def __init__(self, remote): sock = None @@ -26,6 +27,8 @@ class SSHConnection: self._client.connect(remote.host, remote.port, remote.username, sock = sock) + self._remote = remote + def close(self): if self._client: self._client.close() @@ -43,3 +46,6 @@ class SSHConnection: return self def __exit__(self, exc_type, exc_value, traceback): self.close() + + def __str__(self): + return 'ssh:%s' % str(self._remote) diff --git a/bupper/ssh_remote.py b/bupper/ssh_remote.py index 89e8f17..634c86a 100644 --- a/bupper/ssh_remote.py +++ b/bupper/ssh_remote.py @@ -17,3 +17,9 @@ class SSHRemote: self.port = port self.username = username self.proxy_remote = proxy_remote + def __str__(self): + return '{user}@{host}:{port}{proxy}'.format( + user = self.username, + host = self.host, + port = self.port, + proxy = '@@{%s}' % str(self.proxy_remote) if self.proxy_remote else '') -- cgit v1.2.3