From 424ed8f54b4360f1609c4c032b793add74fb5bd3 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 10 Sep 2013 19:14:16 +0900 Subject: 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 --- pygerrit/ssh.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'pygerrit') 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) -- cgit v1.2.1