Merge pull request #1944 from mbedmicro/ctrl-c-traceback

Fixes the python traceback when the user does ctrl+c during compilation
pull/1949/head
Sam Grove 2016-06-15 12:29:21 +01:00 committed by GitHub
commit 2a4a02caa7
2 changed files with 7 additions and 2 deletions

View File

@ -41,7 +41,11 @@ CPU_COUNT_MIN = 1
def compile_worker(job):
results = []
for command in job['commands']:
_, _stderr, _rc = run_cmd(command, job['work_dir'])
try:
_, _stderr, _rc = run_cmd(command, job['work_dir'])
except KeyboardInterrupt as e:
raise ToolException
results.append({
'code': _rc,
'output': _stderr,

View File

@ -38,9 +38,10 @@ def run_cmd(command, wd=None, redirect=False):
try:
p = Popen(command, stdout=PIPE, stderr=STDOUT if redirect else PIPE, cwd=wd)
_stdout, _stderr = p.communicate()
except:
except OSError as e:
print "[OS ERROR] Command: "+(' '.join(command))
raise
return _stdout, _stderr, p.returncode