Commit db8db907 authored by Mattia Rizzolo's avatar Mattia Rizzolo

Use a try/except while executing this external command

So it catches things like FileNotFoundError
Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent c218b3d8
......@@ -161,7 +161,7 @@ class Branch:
def exec_command(self, raw_command, replaces=None, build=False):
"""Exec a command in the context of the branch"""
args, kwargs = self.command_popen_args(raw_command, replaces, build)
return subprocess.call(*args, **kwargs) == 0
return subprocess.check_call(*args, **kwargs)
def command_popen_args(self, raw_command, replaces=None, build=False):
"""Get the Popen arguments for exec_command"""
......@@ -256,8 +256,11 @@ class Branch:
# Build the website
for cmd in self.config["build"]:
if not self.exec_command(cmd, build=True):
try:
self.exec_command(cmd, build=True)
except (IOError, subprocess.CalledProcessError) as e:
log("[!] Failed to execute build command: %s" % " ".join(cmd))
log("[!] Error: %s" % e)
log("[!] Aborting!")
self.fail_deployment(branch)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment