refactor exception handling

This commit is contained in:
Lincoln Stein 2023-06-07 07:35:34 -04:00
parent d114833a12
commit a3357e073c

View File

@ -856,15 +856,12 @@ def select_and_download_models(opt: Namespace):
installApp = AddModelApplication(opt) installApp = AddModelApplication(opt)
try: try:
installApp.run() installApp.run()
except Exception as e: except KeyboardInterrupt:
print(f'An exception has occurred: {str(e)}') form = installApp.main_form
input('Press any key to continue...') if form.subprocess and form.subprocess.is_alive():
if hasattr(installApp,'main_form'): logger.info('Terminating subprocesses')
form = installApp.main_form form.subprocess.terminate()
if form.subprocess and form.subprocess.is_alive(): form.subprocess = None
logger.info('Terminating subprocesses')
form.subprocess.terminate()
form.subprocess = None
process_and_execute(opt, installApp.user_selections) process_and_execute(opt, installApp.user_selections)
# ------------------------------------- # -------------------------------------
@ -972,6 +969,9 @@ def main():
logger.error( logger.error(
"Insufficient horizontal space for the interface. Please make your window wider and try again." "Insufficient horizontal space for the interface. Please make your window wider and try again."
) )
except Exception as e:
print(f'An exception has occurred: {str(e)}')
input('Press any key to continue...')
# ------------------------------------- # -------------------------------------