From 4e8299beec75e43005a3f58cee7b37ee2ae9d339 Mon Sep 17 00:00:00 2001 From: vapao Date: Mon, 27 Sep 2021 19:06:38 +0800 Subject: [PATCH] fix issues --- spug_api/apps/deploy/utils.py | 3 ++- spug_api/libs/ssh.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spug_api/apps/deploy/utils.py b/spug_api/apps/deploy/utils.py index d45dce1..b0625b8 100644 --- a/spug_api/apps/deploy/utils.py +++ b/spug_api/apps/deploy/utils.py @@ -196,8 +196,9 @@ def _deploy_ext1_host(req, helper, h_id, env): helper.send_error(h_id, 'no such host') env.update({'SPUG_HOST_ID': h_id, 'SPUG_HOST_NAME': host.hostname}) with host.get_ssh(default_env=env) as ssh: + base_dst_dir = os.path.dirname(extend.dst_dir) code, _ = ssh.exec_command_raw( - f'mkdir -p {extend.dst_repo} && [ -e {extend.dst_dir} ] && [ ! -L {extend.dst_dir} ]') + f'mkdir -p {extend.dst_repo} {base_dst_dir} && [ -e {extend.dst_dir} ] && [ ! -L {extend.dst_dir} ]') if code == 0: helper.send_error(host.id, f'检测到该主机的发布目录 {extend.dst_dir!r} 已存在,为了数据安全请自行备份后删除该目录,Spug 将会创建并接管该目录。') if req.type == '2': diff --git a/spug_api/libs/ssh.py b/spug_api/libs/ssh.py index bbcbfa5..97fca37 100644 --- a/spug_api/libs/ssh.py +++ b/spug_api/libs/ssh.py @@ -74,8 +74,11 @@ class SSH: channel.send(command) out, exit_code = '', -1 for line in self.stdout: - if self.regex.search(line): - exit_code = int(line.rsplit()[-1]) + match = self.regex.search(line) + if match: + exit_code = int(match.group(1)) + line = line[:match.start()] + out += line break out += line return exit_code, out