summaryrefslogtreecommitdiff
path: root/pygerrit/ssh.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-08-02 18:14:13 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-08-05 19:17:58 +0900
commitee0a7001bf42c4fee00b480865bede265bffaf22 (patch)
treec37a696b4485335509ab039a14636d87c11a84c9 /pygerrit/ssh.py
parent7762f04080d98b6dc0f4f16cdd8cb918cdac8941 (diff)
downloadpygerrit-ee0a7001bf42c4fee00b480865bede265bffaf22.tar.gz
Include command in GerritCommandResult
Include the name of the command that was run in the result object. Change-Id: I93c27ed937d27942428f561dc50d84b5ea25591a
Diffstat (limited to 'pygerrit/ssh.py')
-rw-r--r--pygerrit/ssh.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pygerrit/ssh.py b/pygerrit/ssh.py
index d508d56..adb3dd3 100644
--- a/pygerrit/ssh.py
+++ b/pygerrit/ssh.py
@@ -52,11 +52,15 @@ class GerritSSHCommandResult(object):
""" Represents the results of a Gerrit command run over SSH. """
- def __init__(self, stdin, stdout, stderr):
+ def __init__(self, command, stdin, stdout, stderr):
+ self.command = command
self.stdin = stdin
self.stdout = stdout
self.stderr = stderr
+ def __repr__(self):
+ return "<GerritSSHCommandResult [%s]>" % self.command
+
class GerritSSHClient(SSHClient):
@@ -134,7 +138,7 @@ class GerritSSHClient(SSHClient):
def run_gerrit_command(self, command):
""" Run the given command.
- Run `command` and return a tuple of stdin, stdout, and stderr.
+ Run `command` and return a `GerritSSHCommandResult`.
"""
gerrit_command = ["gerrit"]
@@ -142,9 +146,10 @@ class GerritSSHClient(SSHClient):
gerrit_command += command
else:
gerrit_command.append(command)
+
try:
c = " ".join(gerrit_command)
stdin, stdout, stderr = self.exec_command(c)
except SSHException as err:
raise GerritError("Command execution error: %s" % err)
- return GerritSSHCommandResult(stdin, stdout, stderr)
+ return GerritSSHCommandResult(command, stdin, stdout, stderr)