From 43a471a79b73c62ff1a1a210cdd1d8b4f1dbb52d Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 5 Apr 2018 12:50:34 +0300 Subject: [PATCH] Used state.testmode to indicate when operating in test mode --- src/bitmessagemain.py | 25 +++++++++++++++++-------- src/state.py | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 453010ad..11f71b47 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -220,13 +220,13 @@ class Main: daemon = True elif opt in ("-c", "--curses"): state.curses = True - elif opt in ("-t", "test"): - daemon = 10 + elif opt in ("-t", "--test"): + state.testmode = daemon = True # is the application already running? If yes then exit. shared.thisapp = singleinstance("", daemon) - if daemon == 1: + if daemon and not state.testmode: with shared.printLock: print('Running as a daemon. Send TERM signal to end.') self.daemonize() @@ -328,9 +328,18 @@ class Main: if daemon == False and BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon') == False: if state.curses == False: 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') - print('You can also run PyBitmessage with the new curses interface by providing \'-c\' as a commandline argument.') - sys.exit() + sys.exit( + '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' + 'You can also run PyBitmessage with' + ' the new curses interface by providing' + ' \'-c\' as a commandline argument.' + ) import bitmessageqt bitmessageqt.run() @@ -344,8 +353,8 @@ class Main: BMConfigParser().remove_option('bitmessagesettings', 'dontconnect') if daemon: - sleep(daemon) - if daemon > 1: + if state.testmode: + sleep(30) # make testing self.stop() while state.shutdown == 0: diff --git a/src/state.py b/src/state.py index 73e4f789..3e2b6487 100644 --- a/src/state.py +++ b/src/state.py @@ -55,3 +55,5 @@ def resetNetworkProtocolAvailability(): resetNetworkProtocolAvailability() dandelion = 0 + +testmode = False