Use config = BMConfigParser() in bitmessagemain.Main
This commit is contained in:
parent
d8d76ed42d
commit
2bd75b87bd
|
@ -187,8 +187,8 @@ class Main:
|
||||||
def start(self):
|
def start(self):
|
||||||
_fixSocket()
|
_fixSocket()
|
||||||
|
|
||||||
daemon = BMConfigParser().safeGetBoolean(
|
config = BMConfigParser()
|
||||||
'bitmessagesettings', 'daemon')
|
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(
|
opts, args = getopt.getopt(
|
||||||
|
@ -216,7 +216,6 @@ class Main:
|
||||||
# Fallback: in case when no api command was issued
|
# Fallback: in case when no api command was issued
|
||||||
state.last_api_response = time.time()
|
state.last_api_response = time.time()
|
||||||
# Apply special settings
|
# Apply special settings
|
||||||
config = BMConfigParser()
|
|
||||||
config.set(
|
config.set(
|
||||||
'bitmessagesettings', 'apienabled', 'true')
|
'bitmessagesettings', 'apienabled', 'true')
|
||||||
config.set(
|
config.set(
|
||||||
|
@ -256,14 +255,14 @@ class Main:
|
||||||
|
|
||||||
helper_threading.set_thread_name("PyBitmessage")
|
helper_threading.set_thread_name("PyBitmessage")
|
||||||
|
|
||||||
state.dandelion = BMConfigParser().safeGetInt('network', 'dandelion')
|
state.dandelion = config.safeGetInt('network', 'dandelion')
|
||||||
# dandelion requires outbound connections, without them,
|
# dandelion requires outbound connections, without them,
|
||||||
# stem objects will get stuck forever
|
# stem objects will get stuck forever
|
||||||
if state.dandelion and not BMConfigParser().safeGetBoolean(
|
if state.dandelion and not config.safeGetBoolean(
|
||||||
'bitmessagesettings', 'sendoutgoingconnections'):
|
'bitmessagesettings', 'sendoutgoingconnections'):
|
||||||
state.dandelion = 0
|
state.dandelion = 0
|
||||||
|
|
||||||
if state.testmode or BMConfigParser().safeGetBoolean(
|
if state.testmode or config.safeGetBoolean(
|
||||||
'bitmessagesettings', 'extralowdifficulty'):
|
'bitmessagesettings', 'extralowdifficulty'):
|
||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte = int(
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte = int(
|
||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte / 100)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte / 100)
|
||||||
|
@ -302,15 +301,15 @@ class Main:
|
||||||
if state.enableObjProc:
|
if state.enableObjProc:
|
||||||
|
|
||||||
# SMTP delivery thread
|
# SMTP delivery thread
|
||||||
if daemon and BMConfigParser().safeGet(
|
if daemon and config.safeGet(
|
||||||
"bitmessagesettings", "smtpdeliver", '') != '':
|
'bitmessagesettings', 'smtpdeliver', '') != '':
|
||||||
from class_smtpDeliver import smtpDeliver
|
from class_smtpDeliver import smtpDeliver
|
||||||
smtpDeliveryThread = smtpDeliver()
|
smtpDeliveryThread = smtpDeliver()
|
||||||
smtpDeliveryThread.start()
|
smtpDeliveryThread.start()
|
||||||
|
|
||||||
# SMTP daemon thread
|
# SMTP daemon thread
|
||||||
if daemon and BMConfigParser().safeGetBoolean(
|
if daemon and config.safeGetBoolean(
|
||||||
"bitmessagesettings", "smtpd"):
|
'bitmessagesettings', 'smtpd'):
|
||||||
from class_smtpServer import smtpServer
|
from class_smtpServer import smtpServer
|
||||||
smtpServerThread = smtpServer()
|
smtpServerThread = smtpServer()
|
||||||
smtpServerThread.start()
|
smtpServerThread.start()
|
||||||
|
@ -335,7 +334,7 @@ class Main:
|
||||||
shared.reloadBroadcastSendersForWhichImWatching()
|
shared.reloadBroadcastSendersForWhichImWatching()
|
||||||
|
|
||||||
# API is also objproc dependent
|
# API is also objproc dependent
|
||||||
if BMConfigParser().safeGetBoolean('bitmessagesettings', 'apienabled'):
|
if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
|
||||||
import api # pylint: disable=relative-import
|
import api # pylint: disable=relative-import
|
||||||
singleAPIThread = api.singleAPI()
|
singleAPIThread = api.singleAPI()
|
||||||
# close the main program even if there are threads left
|
# close the main program even if there are threads left
|
||||||
|
@ -348,7 +347,7 @@ class Main:
|
||||||
asyncoreThread = BMNetworkThread()
|
asyncoreThread = BMNetworkThread()
|
||||||
asyncoreThread.daemon = True
|
asyncoreThread.daemon = True
|
||||||
asyncoreThread.start()
|
asyncoreThread.start()
|
||||||
for i in range(BMConfigParser().getint("threads", "receive")):
|
for i in range(config.getint('threads', 'receive')):
|
||||||
receiveQueueThread = ReceiveQueueThread(i)
|
receiveQueueThread = ReceiveQueueThread(i)
|
||||||
receiveQueueThread.daemon = True
|
receiveQueueThread.daemon = True
|
||||||
receiveQueueThread.start()
|
receiveQueueThread.start()
|
||||||
|
@ -370,8 +369,7 @@ class Main:
|
||||||
|
|
||||||
connectToStream(1)
|
connectToStream(1)
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean(
|
if config.safeGetBoolean('bitmessagesettings', 'upnp'):
|
||||||
'bitmessagesettings', 'upnp'):
|
|
||||||
import upnp
|
import upnp
|
||||||
upnpThread = upnp.uPnPThread()
|
upnpThread = upnp.uPnPThread()
|
||||||
upnpThread.start()
|
upnpThread.start()
|
||||||
|
@ -387,14 +385,14 @@ class Main:
|
||||||
import bitmessagecurses
|
import bitmessagecurses
|
||||||
bitmessagecurses.runwrapper()
|
bitmessagecurses.runwrapper()
|
||||||
elif state.kivy:
|
elif state.kivy:
|
||||||
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
|
config.remove_option('bitmessagesettings', 'dontconnect')
|
||||||
from bitmessagekivy.mpybit import NavigateApp
|
from bitmessagekivy.mpybit import NavigateApp
|
||||||
NavigateApp().run()
|
NavigateApp().run()
|
||||||
else:
|
else:
|
||||||
import bitmessageqt
|
import bitmessageqt
|
||||||
bitmessageqt.run()
|
bitmessageqt.run()
|
||||||
else:
|
else:
|
||||||
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
|
config.remove_option('bitmessagesettings', 'dontconnect')
|
||||||
|
|
||||||
if daemon:
|
if daemon:
|
||||||
while state.shutdown == 0:
|
while state.shutdown == 0:
|
||||||
|
|
Reference in New Issue
Block a user