Use subprocess.call in place of os.system

Also removes the buried exit() in favor of raising an Exception to be
handled or ignored, resulting in the same behavior (but with a non-zero
exit code).


Former-commit-id: 7172502f97
pull/1161/head
Seth Fitzsimmons 2016-10-24 17:47:38 -06:00
rodzic 1b183ab7c7
commit 36d30c9aa7
1 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -16,15 +16,16 @@ def get_ccd_widths():
sensor_data = json.loads(f.read())
return dict(zip(map(string.lower, sensor_data.keys()), sensor_data.values()))
def run(cmd):
"""Run a system command"""
log.ODM_DEBUG('running %s' % cmd)
returnCode = os.system(cmd)
retcode = subprocess.call(cmd, shell=True)
if (returnCode != 0):
log.ODM_ERROR("quitting cause: \n\t" + cmd + "\nreturned with code " +
str(returnCode) + ".\n")
sys.exit('An error occurred. Check stdout above or the logs.')
if retcode < 0:
raise Exception("Child was terminated by signal {}".format(-retcode))
elif retcode > 0:
raise Exception("Child returned {}".format(retcode))
def now():