improved exit code reporting

Former-commit-id: f36f45bc6a2773b8a821d0e046ce1b47fc4ced0f
This commit is contained in:
Arthur Lu 2022-02-19 23:29:58 +00:00
parent 80b63269df
commit 0cace3cec3

View File

@ -168,7 +168,6 @@ def main(logger, verbose, profile, debug, socket_send = None):
client.close() client.close()
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
exit_code = 0
logger.splash(__version__) logger.splash(__version__)
@ -229,12 +228,10 @@ def main(logger, verbose, profile, debug, socket_send = None):
socket_send("finished all tasks in " + str(time.time() - loop_start) + " seconds, looping") socket_send("finished all tasks in " + str(time.time() - loop_start) + " seconds, looping")
if profile: if profile:
exit_code = 0 return 0
break
if debug: if debug:
exit_code = 0 return 0
break
event_delay = config["variable"]["event-delay"] event_delay = config["variable"]["event-delay"]
if event_delay: if event_delay:
@ -258,7 +255,7 @@ def main(logger, verbose, profile, debug, socket_send = None):
close_all() close_all()
logger.info("detected KeyboardInterrupt, exiting") logger.info("detected KeyboardInterrupt, exiting")
socket_send("detected KeyboardInterrupt, exiting") socket_send("detected KeyboardInterrupt, exiting")
break return 0
except ConfigurationError as e: except ConfigurationError as e:
str_e = "".join(traceback.format_exception(e)) str_e = "".join(traceback.format_exception(e))
@ -266,9 +263,8 @@ def main(logger, verbose, profile, debug, socket_send = None):
logger.error(str_e) logger.error(str_e)
socket_send("encountered a configuration error: " + str(e)) socket_send("encountered a configuration error: " + str(e))
socket_send(str_e) socket_send(str_e)
exit_code = 1
close_all() close_all()
break return 1
except Exception as e: except Exception as e:
str_e = "".join(traceback.format_exception(e)) str_e = "".join(traceback.format_exception(e))
@ -276,11 +272,8 @@ def main(logger, verbose, profile, debug, socket_send = None):
logger.error(str_e) logger.error(str_e)
socket_send("encountered an exception while running") socket_send("encountered an exception while running")
socket_send(str_e) socket_send(str_e)
exit_code = 1
close_all() close_all()
break return 1
return exit_code
def start(pid_path, verbose, profile, debug): def start(pid_path, verbose, profile, debug):