2013-02-19 00:11:43 +00:00
|
|
|
# This program is free software. It comes without any warranty, to
|
|
|
|
# the extent permitted by applicable law. You can redistribute it
|
|
|
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
|
|
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
|
|
|
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
|
|
|
|
2014-08-27 22:15:22 +00:00
|
|
|
try:
|
2013-02-19 00:11:43 +00:00
|
|
|
|
2014-08-27 22:15:22 +00:00
|
|
|
import locale
|
2013-02-19 00:11:43 +00:00
|
|
|
|
2014-08-27 22:15:22 +00:00
|
|
|
try: locale.setlocale( locale.LC_ALL, '' )
|
|
|
|
except: pass
|
|
|
|
|
|
|
|
from include import HydrusConstants as HC
|
2015-11-18 22:44:07 +00:00
|
|
|
from include import HydrusData
|
2014-08-27 22:15:22 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
|
|
|
|
from include import ClientController
|
|
|
|
import threading
|
|
|
|
from twisted.internet import reactor
|
2015-03-25 22:04:19 +00:00
|
|
|
from include import HydrusGlobals
|
2015-11-18 22:44:07 +00:00
|
|
|
from include import HydrusLogger
|
2015-09-02 23:16:09 +00:00
|
|
|
import traceback
|
|
|
|
|
|
|
|
HydrusGlobals.instance = HC.HYDRUS_CLIENT
|
2014-08-27 22:15:22 +00:00
|
|
|
|
2015-11-18 22:44:07 +00:00
|
|
|
with HydrusLogger.HydrusLogger( 'client.log' ) as logger:
|
2014-06-18 21:53:48 +00:00
|
|
|
|
2014-08-27 22:15:22 +00:00
|
|
|
try:
|
|
|
|
|
2015-11-18 22:44:07 +00:00
|
|
|
HydrusData.Print( 'hydrus client started' )
|
2014-08-27 22:15:22 +00:00
|
|
|
|
|
|
|
threading.Thread( target = reactor.run, kwargs = { 'installSignalHandlers' : 0 } ).start()
|
|
|
|
|
2015-09-02 23:16:09 +00:00
|
|
|
controller = ClientController.Controller()
|
2014-08-27 22:15:22 +00:00
|
|
|
|
2015-09-02 23:16:09 +00:00
|
|
|
controller.Run()
|
2014-08-27 22:15:22 +00:00
|
|
|
|
|
|
|
except:
|
|
|
|
|
2015-11-18 22:44:07 +00:00
|
|
|
HydrusData.Print( 'hydrus client failed' )
|
2014-08-27 22:15:22 +00:00
|
|
|
|
2015-11-18 22:44:07 +00:00
|
|
|
HydrusData.Print( traceback.format_exc() )
|
2014-08-27 22:15:22 +00:00
|
|
|
|
2015-08-26 21:18:39 +00:00
|
|
|
finally:
|
|
|
|
|
|
|
|
HydrusGlobals.view_shutdown = True
|
|
|
|
HydrusGlobals.model_shutdown = True
|
|
|
|
|
2015-09-02 23:16:09 +00:00
|
|
|
try: controller.pubimmediate( 'wake_daemons' )
|
|
|
|
except: pass
|
2015-08-26 21:18:39 +00:00
|
|
|
|
|
|
|
reactor.callFromThread( reactor.stop )
|
|
|
|
|
2015-11-18 22:44:07 +00:00
|
|
|
HydrusData.Print( 'hydrus client shut down' )
|
2015-08-26 21:18:39 +00:00
|
|
|
|
2013-07-24 20:26:00 +00:00
|
|
|
|
2014-11-12 23:33:13 +00:00
|
|
|
|
2014-08-27 22:15:22 +00:00
|
|
|
except:
|
|
|
|
|
|
|
|
import traceback
|
|
|
|
|
2015-11-18 22:44:07 +00:00
|
|
|
HydrusData.Print( 'Critical error occured! Details written to crash.log!' )
|
2014-10-22 22:31:58 +00:00
|
|
|
|
2014-08-27 22:15:22 +00:00
|
|
|
with open( 'crash.log', 'wb' ) as f: f.write( traceback.format_exc() )
|
|
|
|
|