Added new option to Main.start: silent, if silent=True, stdout and stderr are redirected to stringio fileobject (necessary to write commandline apps)
This commit is contained in:
parent
c3b67a479c
commit
86f3a6344b
|
@ -35,6 +35,7 @@ from class_addressGenerator import *
|
||||||
import helper_bootstrap
|
import helper_bootstrap
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import StringIO
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
if float("{1}.{2}".format(*sys.version_info)) < 7.5:
|
if float("{1}.{2}".format(*sys.version_info)) < 7.5:
|
||||||
print "You should use python 2.7.5 or greater."
|
print "You should use python 2.7.5 or greater."
|
||||||
|
@ -769,7 +770,13 @@ if shared.useVeryEasyProofOfWorkForTesting:
|
||||||
shared.networkDefaultPayloadLengthExtraBytes / 7000)
|
shared.networkDefaultPayloadLengthExtraBytes / 7000)
|
||||||
|
|
||||||
class Main:
|
class Main:
|
||||||
def start(self, deamon=False):
|
def start(self, deamon=False, silent=False):
|
||||||
|
|
||||||
|
if silent:
|
||||||
|
fobj = StringIO.StringIO()
|
||||||
|
sys.stdout = fobj
|
||||||
|
sys.stderr = fobj
|
||||||
|
|
||||||
# is the application already running? If yes then exit.
|
# is the application already running? If yes then exit.
|
||||||
thisapp = singleton.singleinstance()
|
thisapp = singleton.singleinstance()
|
||||||
|
|
||||||
|
@ -1286,7 +1293,8 @@ class Main:
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
mainprogram = Main()
|
mainprogram = Main()
|
||||||
mainprogram.start()
|
mainprogram.start(True,True)
|
||||||
|
mainprogram.stop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user