Used state.testmode to indicate when operating in test mode

This commit is contained in:
Dmitri Bogomolov 2018-04-05 12:50:34 +03:00
parent 54c37150e0
commit 43a471a79b
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 19 additions and 8 deletions

View File

@ -220,13 +220,13 @@ class Main:
daemon = True daemon = True
elif opt in ("-c", "--curses"): elif opt in ("-c", "--curses"):
state.curses = True state.curses = True
elif opt in ("-t", "test"): elif opt in ("-t", "--test"):
daemon = 10 state.testmode = daemon = True
# is the application already running? If yes then exit. # is the application already running? If yes then exit.
shared.thisapp = singleinstance("", daemon) shared.thisapp = singleinstance("", daemon)
if daemon == 1: if daemon and not state.testmode:
with shared.printLock: with shared.printLock:
print('Running as a daemon. Send TERM signal to end.') print('Running as a daemon. Send TERM signal to end.')
self.daemonize() self.daemonize()
@ -328,9 +328,18 @@ class Main:
if daemon == False and BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon') == False: if daemon == False and BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon') == False:
if state.curses == False: if state.curses == False:
if not depends.check_pyqt(): if not depends.check_pyqt():
print('PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon') sys.exit(
print('You can also run PyBitmessage with the new curses interface by providing \'-c\' as a commandline argument.') 'PyBitmessage requires PyQt unless you want'
sys.exit() ' to run it as a daemon and interact with it'
' using the API. You can download PyQt from '
'http://www.riverbankcomputing.com/software/pyqt/download'
' or by searching Google for \'PyQt Download\'.'
' If you want to run in daemon mode, see '
'https://bitmessage.org/wiki/Daemon'
'You can also run PyBitmessage with'
' the new curses interface by providing'
' \'-c\' as a commandline argument.'
)
import bitmessageqt import bitmessageqt
bitmessageqt.run() bitmessageqt.run()
@ -344,8 +353,8 @@ class Main:
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect') BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
if daemon: if daemon:
sleep(daemon) if state.testmode:
if daemon > 1: sleep(30)
# make testing # make testing
self.stop() self.stop()
while state.shutdown == 0: while state.shutdown == 0:

View File

@ -55,3 +55,5 @@ def resetNetworkProtocolAvailability():
resetNetworkProtocolAvailability() resetNetworkProtocolAvailability()
dandelion = 0 dandelion = 0
testmode = False