From 8b756f2e0ca28481b969c45fa7a167b8ea7d7875 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 11 Dec 2023 01:57:06 +0100 Subject: [PATCH] consistently use shell helper --- deploy-chatmail/src/deploy_chatmail/cmdeploy.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py index f109553a..251f5bde 100644 --- a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py +++ b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py @@ -50,16 +50,12 @@ def run_cmd_options(parser): def run_cmd(args, out): """Deploy chatmail services on the remote server.""" - popen_args = ["pyinfra"] - if args.dry_run: - popen_args.append("--dry") - popen_args.extend(["--ssh-user", "root", args.config.mailname]) - popen_args.append("deploy-chatmail/src/deploy_chatmail/deploy.py") - - out(f"{os.getcwd()} $ {' '.join(popen_args)}") env = os.environ.copy() env["CHATMAIL_DOMAIN"] = args.config.mailname - subprocess.check_call(popen_args, env=env) + deploypy = "deploy-chatmail/src/deploy_chatmail/deploy.py" + pyinf = "pyinfra --dry" if args.dry_run else "pyinfra" + cmd = f"{pyinf} --ssh-user root {args.config.mailname} {deploypy}" + out.check_call(cmd, env=env) def dns_cmd(args, out): @@ -165,6 +161,10 @@ class Out: self(f"[$ {arg}]", file=sys.stderr) return subprocess.check_output(arg, shell=True).decode() + def check_call(self, arg, env): + self(f"[$ {arg}]", file=sys.stderr) + return subprocess.check_call(arg, shell=True, env=env) + def add_config_option(parser): parser.add_argument(