in fork() do sys.exit() so parent knows about failures

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
remotes/origin/feature_files_export
Nico Schottelius 13 years ago
parent d3b9aa6769
commit 531ad2966f
  1. 38
      bin/cdist

@ -177,28 +177,25 @@ def configinstall_onehost(host, args, mode, parallel):
context.cleanup()
except cdist.Error as e:
log.error(e)
return False
except KeyboardInterrupt:
# Do not care in sequential mode, catch in parallel mode
if not parallel:
raise
if parallel:
log.error(e)
sys.exit(1)
else:
# Catch here, above does not need to know about our errors
return False
raise
return True
except KeyboardInterrupt:
# Ignore in parallel mode, we are existing anyway
if parallel:
sys.exit(0)
# Pass back to controlling code in sequential mode
else:
raise
def emulator():
"""Prepare and run emulator"""
try:
import cdist.emulator
emulator = cdist.emulator.Emulator(sys.argv)
emulator.run()
except cdist.Error as e:
log.error(e)
sys.exit(1)
import cdist.emulator
emulator = cdist.emulator.Emulator(sys.argv)
return emulator.run()
if __name__ == "__main__":
# Sys is needed for sys.exit()
@ -213,9 +210,8 @@ if __name__ == "__main__":
cdistpythonversion = '3.2'
if sys.version < cdistpythonversion:
print('Cdist requires Python >= ' + cdistpythonversion +
raise cdist.Error('Cdist requires Python >= ' + cdistpythonversion +
' on the source host.')
sys.exit(1)
# Ensure our /lib/ is included into PYTHON_PATH
sys.path.insert(0, os.path.abspath(
@ -236,6 +232,10 @@ if __name__ == "__main__":
except KeyboardInterrupt:
pass
except cdist.Error as e:
log.error(e)
exit_code = 1
# Determine exit code by return value of function
if not run:
exit_code = 1

Loading…
Cancel
Save