summaryrefslogtreecommitdiff
path: root/pygerrit/ssh.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-09-10 19:14:16 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-09-11 14:08:23 +0900
commit424ed8f54b4360f1609c4c032b793add74fb5bd3 (patch)
treeba6faf25332a3614452a96a8d0b8ed973e5d00d0 /pygerrit/ssh.py
parent46283a771c31324553ad820f010590edfea195ad (diff)
downloadpygerrit-424ed8f54b4360f1609c4c032b793add74fb5bd3.tar.gz
Remove redundant `exec_command` method
The `exec_command` overrides the method of the same name from the parent class unnecessarily. Remove it and call the parent `exec_command` method directly from the `run_gerrit_command` method. Change-Id: I977000a372c9b6e9143ca0e740b971a606a83146
Diffstat (limited to 'pygerrit/ssh.py')
-rw-r--r--pygerrit/ssh.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/pygerrit/ssh.py b/pygerrit/ssh.py
index 7728e48..97e712d 100644
--- a/pygerrit/ssh.py
+++ b/pygerrit/ssh.py
@@ -128,18 +128,6 @@ class GerritSSHClient(SSHClient):
finally:
self.lock.release()
- def exec_command(self, command, bufsize=1, timeout=None, get_pty=False):
- """ Execute the command.
-
- Make sure we're connected and then execute the command.
-
- Return a tuple of stdin, stdout, stderr.
-
- """
- self._connect()
- return super(GerritSSHClient, self).\
- exec_command(command, bufsize, timeout, get_pty)
-
def get_remote_version(self):
""" Return the version of the remote Gerrit server. """
if self.remote_version is None:
@@ -152,17 +140,24 @@ class GerritSSHClient(SSHClient):
def run_gerrit_command(self, command):
""" Run the given command.
- Run `command` and return a `GerritSSHCommandResult`.
+ Make sure we're connected to the remote server, and run `command`.
- Raise `ValueError` if `command` is not a string.
+ Return the results as a `GerritSSHCommandResult`.
+
+ Raise `ValueError` if `command` is not a string, or `GerritError` if
+ command execution fails.
"""
if not isinstance(command, basestring):
raise ValueError("command must be a string")
gerrit_command = "gerrit " + command
+ self._connect()
try:
- stdin, stdout, stderr = self.exec_command(gerrit_command)
+ stdin, stdout, stderr = self.exec_command(gerrit_command,
+ bufsize=1,
+ timeout=None,
+ get_pty=False)
except SSHException as err:
raise GerritError("Command execution error: %s" % err)
return GerritSSHCommandResult(command, stdin, stdout, stderr)