hydrus/hydrus/hydrus_test_boot.py

110 lines
2.5 KiB
Python
Raw Normal View History

2021-01-27 22:14:03 +00:00
#!/usr/bin/env python3
from hydrus.client.gui import QtInit
2021-01-27 22:14:03 +00:00
from hydrus.client.gui import QtPorting as QP
from qtpy import QtWidgets as QW
import locale
try: locale.setlocale( locale.LC_ALL, '' )
except: pass
from hydrus.core import HydrusConstants as HC
from hydrus.core import HydrusData
from hydrus.core import HydrusGlobals as HG
2023-04-19 20:38:13 +00:00
from hydrus.core import HydrusTime
2021-01-27 22:14:03 +00:00
from hydrus.test import TestController
import sys
import threading
import traceback
from twisted.internet import reactor
def boot():
args = sys.argv[1:]
if len( args ) > 0:
only_run = args[0]
else:
only_run = None
try:
threading.Thread( target = reactor.run, kwargs = { 'installSignalHandlers' : 0 } ).start()
QtInit.MonkeyPatchMissingMethods()
2021-01-27 22:14:03 +00:00
app = QW.QApplication( sys.argv )
app.call_after_catcher = QP.CallAfterEventCatcher( app )
try:
# we run the tests on the Qt thread atm
# keep a window alive the whole time so the app doesn't finish its mainloop
win = QW.QWidget( None )
win.setWindowTitle( 'Running tests...' )
controller = TestController.Controller( win, only_run )
def do_it():
controller.Run( win )
QP.CallAfter( do_it )
app.exec_()
except:
HydrusData.DebugPrint( traceback.format_exc() )
finally:
2022-01-19 21:28:59 +00:00
HG.started_shutdown = True
2021-01-27 22:14:03 +00:00
HG.view_shutdown = True
controller.pubimmediate( 'wake_daemons' )
HG.model_shutdown = True
controller.pubimmediate( 'wake_daemons' )
controller.TidyUp()
except:
HydrusData.DebugPrint( traceback.format_exc() )
finally:
reactor.callFromThread( reactor.stop )
print( 'This was version ' + str( HC.SOFTWARE_VERSION ) )
2021-05-12 20:49:20 +00:00
if sys.stdin.isatty():
input( 'Press any key to exit.' )
2021-01-27 22:14:03 +00:00
2021-06-30 21:27:35 +00:00
if controller.was_successful:
sys.exit( 0 )
else:
sys.exit( 1 )
2021-01-27 22:14:03 +00:00