Add helper _exit_with_error() which log and exit with return code

This commit is contained in:
Laurent Monin
2014-01-12 16:06:08 +01:00
parent c9661b6d4a
commit 48c5086554

View File

@@ -68,6 +68,10 @@ ext_modules = [
Extension('picard.util.astrcmp', sources=['picard/util/astrcmp.c']),
]
def _exit_with_error(msg, code=1):
log.error("%s (code=%d)" % (msg, code))
raise SystemExit(code)
class picard_test(Command):
description = "run automated tests"
@@ -321,7 +325,7 @@ class picard_get_po_files(Command):
log.info("Running %s" % TXPULL_CMD)
retcode = subprocess.call(TXPULL_CMD, shell=True)
if retcode:
log.error("Failed to update po files (retcode=%d)" % (retcode))
_exit_with_error("Failed to update po files", retcode)
class picard_update_countries(Command):