def wx_code( job_key ): try: result = func( *args, **kwargs ) job_key.SetVariable( 'result', result ) except HydrusExceptions.PermissionException as e: job_key.SetVariable( 'error', e ) except Exception as e: job_key.SetVariable( 'error', e ) HydrusData.Print( 'CallBlockingToWx just caught this error:' ) HydrusData.DebugPrint( traceback.format_exc() ) finally: job_key.Finish()
import os import sys import time from include import ServerController import threading from twisted.internet import reactor from include import HydrusGlobals from include import HydrusLogger import traceback action = ServerController.GetStartingAction() if action == 'help': HydrusData.Print( 'This is the hydrus server. It accepts these commands:') HydrusData.Print('') HydrusData.Print('server start - runs the server') HydrusData.Print( 'server stop - stops an existing instance of this server') HydrusData.Print( 'server restart - stops an existing instance of this server, then runs itself' ) HydrusData.Print('') HydrusData.Print( 'You can also run \'server\' without arguments. Depending on what is going on, it will try to start or it will ask you if you want to stop or restart.' ) HydrusData.Print( 'You can also stop the running server just by hitting Ctrl+C.') else:
HG.no_db_temp_files = result.no_db_temp_files if result.temp_dir is not None: HydrusPaths.SetEnvTempDir( result.temp_dir ) # try: action = ServerController.ProcessStartingAction( db_dir, action ) except HydrusExceptions.ShutdownException as e: HydrusData.Print( e ) action = 'exit' if action == 'exit': sys.exit( 0 ) except Exception as e: import traceback import os error_trace = traceback.format_exc()
print( 'Critical boot error occurred! Details written to hydrus_crash.log in either db dir or user dir!' ) import sys sys.exit(1) controller = None with HydrusLogger.HydrusLogger(db_dir, 'client') as logger: try: HydrusData.Print('hydrus client started') if not HG.twisted_is_broke: import threading threading.Thread(target=reactor.run, name='twisted', kwargs={ 'installSignalHandlers': 0 }).start() from include import ClientController controller = ClientController.Controller(db_dir)