From 142965cfd6c5c7f0b1147bf106e87e4d8fa3f74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E4=BA=8C=E7=8C=9B?= Date: Wed, 18 Dec 2019 21:19:29 +0800 Subject: [PATCH] A api update --- spug_api/libs/ssh.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spug_api/libs/ssh.py b/spug_api/libs/ssh.py index d9e6bd4..723bed5 100644 --- a/spug_api/libs/ssh.py +++ b/spug_api/libs/ssh.py @@ -52,7 +52,8 @@ class SSH: chan.settimeout(timeout) chan.set_combine_stderr(True) if environment: - chan.update_environment(environment) + str_env = ' '.join(f'{k}={v}' for k, v in environment.items()) + command = f'export {str_env} && {command}' chan.exec_command(command) out = chan.makefile("r", -1) return chan.recv_exit_status(), out.read() @@ -63,7 +64,8 @@ class SSH: chan.settimeout(timeout) chan.set_combine_stderr(True) if environment: - chan.update_environment(environment) + str_env = ' '.join(f'{k}={v}' for k, v in environment.items()) + command = f'export {str_env} && {command}' chan.exec_command(command) stdout = chan.makefile("r", -1) out = stdout.readline()