summaryrefslogtreecommitdiff
path: root/pygerrit/ssh.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2012-10-23 20:51:36 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2012-10-24 11:01:21 +0900
commit9930c04fa5045516da8b9a5e82e2f26cfff7f2a0 (patch)
tree59200f33c2f8e594e32721e2f09ace1b2159de8d /pygerrit/ssh.py
parentb361460cee9138a0bd6d541e35d93747097f4c85 (diff)
downloadpygerrit-9930c04fa5045516da8b9a5e82e2f26cfff7f2a0.tar.gz
Encapsulate the SSH command results in a class
Add a new class GerritSSHCommandResult to encapsulate the stdin, stdout, and stderr streams that are returned from running a command over SSH. Change-Id: Ic851c195ac63e530e62198eb7e0af62c2fbd73d5
Diffstat (limited to 'pygerrit/ssh.py')
-rw-r--r--pygerrit/ssh.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/pygerrit/ssh.py b/pygerrit/ssh.py
index 52817c2..fe0af5a 100644
--- a/pygerrit/ssh.py
+++ b/pygerrit/ssh.py
@@ -43,6 +43,16 @@ def _extract_version(version_string, pattern):
return ""
+class GerritSSHCommandResult(object):
+
+ """ Represents the results of a Gerrit command run over SSH. """
+
+ def __init__(self, stdin, stdout, stderr):
+ self.stdin = stdin
+ self.stdout = stdout
+ self.stderr = stderr
+
+
class GerritSSHClient(SSHClient):
""" Gerrit SSH Client, wrapping the paramiko SSH Client. """
@@ -92,11 +102,11 @@ class GerritSSHClient(SSHClient):
self.remote_version = _extract_version(version_string, pattern)
except AttributeError:
try:
- _stdin, stdout, _stderr = self.run_gerrit_command("version")
+ result = self.run_gerrit_command("version")
except GerritError:
self.remote_version = ""
else:
- version_string = stdout.read()
+ version_string = result.stdout.read()
pattern = re.compile(r'^gerrit version (.*)$')
self.remote_version = _extract_version(version_string, pattern)
return self.remote_version
@@ -119,4 +129,4 @@ class GerritSSHClient(SSHClient):
raise GerritError("Command execution error: %s" % err)
finally:
self.lock.release()
- return stdin, stdout, stderr
+ return GerritSSHCommandResult(stdin, stdout, stderr)