diff --git a/gui/__main__.py b/gui/__main__.py index 0a8ab4c..cfd6510 100755 --- a/gui/__main__.py +++ b/gui/__main__.py @@ -7,6 +7,7 @@ from core.models.DatabaseOperation import DatabaseOperation, DBErrorType from core.models.manage.migrations import migrate_sql from core.models.manage.clear_sql_model import clear_sql_model from core.controllers.SyncController import new_sync +from core.controllers.ConfigurationController import ConfigurationController from essentials.observers.ConnectionObserver import ConnectionObserver from core.observers.ClientObserver import ClientObserver @@ -86,18 +87,20 @@ def emergency_sync(): client_observer = ClientObserver() connection_observer = ConnectionObserver() - if option == 1 or option == 2: - # # setup the function to do: - do_this_function = partial(new_sync, client_observer, connection_observer) + if option == 1: + ConfigurationController.set_connection("system") + elif option == 2: + ConfigurationController.set_connection("tor") - sync_worked = show_terminal( - do_this_function=do_this_function, - connection_observer=connection_observer, - client_observer=client_observer - ) + # setup the function to be able to have the UI background thread run it. + do_this_function = partial(new_sync, client_observer, connection_observer) + + return show_terminal( + do_this_function=do_this_function, + connection_observer=connection_observer, + client_observer=client_observer + ) - if sync_worked: - print("it worked") # ============================================================================ # BEGIN PROGRAM @@ -153,7 +156,12 @@ if not main_db_exists: create_ONLY_db_version_table() from gui.main_ui import start_ui - start_ui(force_sync=False) + try: + start_ui(force_sync=False) + except Exception as e: + error_msg = f"Critical Error with loading UI: {str(e)}" + logger.error(error_msg) + recovery_dialog(error_msg, "Sync Error") sys.exit()