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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2019-04-09 09:33:03 +12:00
parent 7f3b4934a9
commit d3de65c924

View File

@ -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