提交 122dfc51 编写于 作者: A alex_hold 提交者: Gitee

update src/xdevice/_core/utils.py.

Signed-off-by: <hejian3@huawei.com>
上级 bb55bc86
...@@ -137,7 +137,7 @@ def _get_find_proc(find_command, list_command): ...@@ -137,7 +137,7 @@ def _get_find_proc(find_command, list_command):
return proc return proc
def exec_cmd(cmd, timeout=5 * 60, error_print=True, join_result=False): def exec_cmd(cmd, timeout=1 * 60, error_print=True, join_result=False):
""" """
Executes commands in a new shell. Directing stderr to PIPE. Executes commands in a new shell. Directing stderr to PIPE.
...@@ -154,6 +154,10 @@ def exec_cmd(cmd, timeout=5 * 60, error_print=True, join_result=False): ...@@ -154,6 +154,10 @@ def exec_cmd(cmd, timeout=5 * 60, error_print=True, join_result=False):
""" """
sys_type = platform.system() sys_type = platform.system()
if isinstance(cmd, list):
LOG.info("The running command is: {}".format(" ".join(cmd)))
if isinstance(cmd, str):
LOG.info("The running command is: {}".format(cmd))
if sys_type == "Linux" or sys_type == "Darwin": if sys_type == "Linux" or sys_type == "Darwin":
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=False, stderr=subprocess.PIPE, shell=False,
...@@ -173,7 +177,7 @@ def exec_cmd(cmd, timeout=5 * 60, error_print=True, join_result=False): ...@@ -173,7 +177,7 @@ def exec_cmd(cmd, timeout=5 * 60, error_print=True, join_result=False):
return err if err else out return err if err else out
except (TimeoutError, KeyboardInterrupt, AttributeError, ValueError, except (TimeoutError, KeyboardInterrupt, AttributeError, ValueError,
EOFError, IOError): EOFError, IOError, subprocess.TimeoutExpired):
sys_type = platform.system() sys_type = platform.system()
if sys_type == "Linux" or sys_type == "Darwin": if sys_type == "Linux" or sys_type == "Darwin":
os.killpg(proc.pid, signal.SIGTERM) os.killpg(proc.pid, signal.SIGTERM)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册