summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-02-13 21:42:30 +0100
committerAnton Khirnov <anton@khirnov.net>2020-02-13 21:42:30 +0100
commit201b5d759e5a0f97d7016664e947f6ce3b632721 (patch)
tree98781fd2f93781b6b0ffb4249c5b4ae66a1741cd
parentf1ef9c053c84515761f59412a91ca3adbc8e7392 (diff)
ssh_client/remote: add __str__ methods to ease debugging
-rw-r--r--bupper/_ssh_client.py6
-rw-r--r--bupper/ssh_remote.py6
2 files changed, 12 insertions, 0 deletions
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 '')