U api update

pull/22/head
vapao 2020-01-09 22:30:03 +08:00
parent 2d755ddcee
commit e6873c7650
2 changed files with 3 additions and 1 deletions

View File

@ -209,7 +209,7 @@ class Helper:
self.send_error('local', f'exit code: {task.returncode}') self.send_error('local', f'exit code: {task.returncode}')
def remote(self, key, ssh, command, env=None): def remote(self, key, ssh, command, env=None):
command, code = 'set -e\n' + command, -1 code = -1
try: try:
for code, out in ssh.exec_command_with_stream(command, environment=env): for code, out in ssh.exec_command_with_stream(command, environment=env):
self.send_info(key, out) self.send_info(key, out)

View File

@ -53,6 +53,7 @@ class SSH:
sftp.close() sftp.close()
def exec_command(self, command, timeout=1800, environment=None): def exec_command(self, command, timeout=1800, environment=None):
command = 'set -e\n' + command
with self as cli: with self as cli:
chan = cli.get_transport().open_session() chan = cli.get_transport().open_session()
chan.settimeout(timeout) chan.settimeout(timeout)
@ -65,6 +66,7 @@ class SSH:
return chan.recv_exit_status(), out.read() return chan.recv_exit_status(), out.read()
def exec_command_with_stream(self, command, timeout=1800, environment=None): def exec_command_with_stream(self, command, timeout=1800, environment=None):
command = 'set -e\n' + command
with self as cli: with self as cli:
chan = cli.get_transport().open_session() chan = cli.get_transport().open_session()
chan.settimeout(timeout) chan.settimeout(timeout)