From d3de65c9248038d53fb75305c5369125c62e066d Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 9 Apr 2019 09:33:03 +1200 Subject: [PATCH] tasks: support running non-shell commands Allow passing a list to run_update_command() instead of a string which will run the command directly instead of within the shell. Signed-off-by: Paul Eggleton --- layerindex/tasks.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/layerindex/tasks.py b/layerindex/tasks.py index 915461d..8339b5f 100644 --- a/layerindex/tasks.py +++ b/layerindex/tasks.py @@ -40,8 +40,11 @@ def run_update_command(self, branch_name, update_command): updateobj.started = datetime.now() updateobj.save() output = '' - update_command = update_command.replace('%update%', str(updateobj.id)) - update_command = update_command.replace('%branch%', branch_name) + shell = False + if isinstance(update_command, str): + update_command = update_command.replace('%update%', str(updateobj.id)) + update_command = update_command.replace('%branch%', branch_name) + shell = True try: os.makedirs(settings.TASK_LOG_DIR) except FileExistsError: @@ -50,7 +53,7 @@ def run_update_command(self, branch_name, update_command): retcode = 0 erroutput = None try: - output = utils.runcmd(update_command, os.path.dirname(os.path.dirname(__file__)), outfile=logfile, shell=True) + output = utils.runcmd(update_command, os.path.dirname(os.path.dirname(__file__)), outfile=logfile, shell=shell) except subprocess.CalledProcessError as e: output = e.output erroutput = output