Stop using not existing ShellCommandError exception class
In commit [1] was introduced exception class ShellCommandFailed and it should be used in common.shell module. But by mistake there was used not existing ShellCommandError class there. This patch fixes that. [1] https://review.opendev.org/#/c/612978/ Change-Id: I0b51165ea4d541b0cd2f5820a64cd7a82f23c6c9
This commit is contained in:
parent
6b151cfd44
commit
86620dacc6
@ -46,7 +46,7 @@ def execute(command, ssh_client=None, timeout=None, check=True):
|
|||||||
|
|
||||||
:param timeout: command execution timeout in seconds
|
:param timeout: command execution timeout in seconds
|
||||||
|
|
||||||
:param check: when False it doesn't raises ShellCommandError when
|
:param check: when False it doesn't raises ShellCommandFailed when
|
||||||
exit status is not zero. True by default
|
exit status is not zero. True by default
|
||||||
|
|
||||||
:returns: STDOUT text when command execution terminates with zero exit
|
:returns: STDOUT text when command execution terminates with zero exit
|
||||||
@ -57,7 +57,7 @@ def execute(command, ssh_client=None, timeout=None, check=True):
|
|||||||
try to read STDOUT and STDERR buffers (not fully implemented) before
|
try to read STDOUT and STDERR buffers (not fully implemented) before
|
||||||
raising the exception.
|
raising the exception.
|
||||||
|
|
||||||
:raises ShellCommandError: when command execution terminates with non-zero
|
:raises ShellCommandFailed: when command execution terminates with non-zero
|
||||||
exit status.
|
exit status.
|
||||||
"""
|
"""
|
||||||
ssh_client = ssh_client or SSH_PROXY_CLIENT
|
ssh_client = ssh_client or SSH_PROXY_CLIENT
|
||||||
@ -110,7 +110,7 @@ def execute_remote_command(command, ssh_client, timeout=None):
|
|||||||
|
|
||||||
except lib_exc.SSHExecCommandFailed as ex:
|
except lib_exc.SSHExecCommandFailed as ex:
|
||||||
# Please note class SSHExecCommandFailed has been re-based on
|
# Please note class SSHExecCommandFailed has been re-based on
|
||||||
# top of ShellCommandError
|
# top of ShellCommandFailed
|
||||||
stdout = ex.stdout
|
stdout = ex.stdout
|
||||||
stderr = ex.stderr
|
stderr = ex.stderr
|
||||||
exit_status = ex.exit_status
|
exit_status = ex.exit_status
|
||||||
@ -174,7 +174,7 @@ class ShellExecuteResult(collections.namedtuple(
|
|||||||
stdout=self.stdout)
|
stdout=self.stdout)
|
||||||
|
|
||||||
elif self.exit_status != 0:
|
elif self.exit_status != 0:
|
||||||
raise exceptions.ShellCommandError(command=self.command,
|
raise exceptions.ShellCommandFailed(command=self.command,
|
||||||
exit_status=self.exit_status,
|
exit_status=self.exit_status,
|
||||||
stderr=self.stderr,
|
stderr=self.stderr,
|
||||||
stdout=self.stdout)
|
stdout=self.stdout)
|
||||||
|
@ -96,5 +96,5 @@ exceptions.SSHExecCommandFailed = utils.override_class(
|
|||||||
exceptions.SSHExecCommandFailed, ShellCommandFailed)
|
exceptions.SSHExecCommandFailed, ShellCommandFailed)
|
||||||
|
|
||||||
# Above code created a new SSHExecCommandFailed class based on top
|
# Above code created a new SSHExecCommandFailed class based on top
|
||||||
# of ShellCommandError
|
# of ShellCommandFailed
|
||||||
assert issubclass(exceptions.SSHExecCommandFailed, ShellCommandFailed)
|
assert issubclass(exceptions.SSHExecCommandFailed, ShellCommandFailed)
|
||||||
|
Loading…
Reference in New Issue
Block a user