Startup fixes

- correctly test for "smtpdeliver" variable without crashing
- new method for safely getting values from config even if the option
  may be missing
This commit is contained in:
Peter Šurda 2016-06-30 15:19:58 +02:00
parent d3e8771aed
commit 685ff6cecd
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
4 changed files with 11 additions and 3 deletions

View File

@ -187,7 +187,7 @@ class Main:
sqlLookup.start()
# SMTP delivery thread
if daemon and shared.config.get("bitmessagesettings", "smtpdeliver", None):
if daemon and shared.safeConfigGet("bitmessagesettings", "smtpdeliver", '') != '':
smtpDeliveryThread = smtpDeliver()
smtpDeliveryThread.start()

View File

@ -46,8 +46,8 @@ class smtpDeliver(threading.Thread, StoppableThread):
pass
elif command == 'displayNewInboxMessage':
inventoryHash, toAddress, fromAddress, subject, body = data
dest = shared.config.get("bitmessagesettings", "smtpdeliver", None)
if not dest:
dest = shared.safeConfigGet("bitmessagesettings", "smtpdeliver", '')
if dest == '':
continue
try:
u = urlparse.urlparse(dest)

View File

@ -425,6 +425,8 @@ class sqlThread(threading.Thread):
shared.config.set('bitmessagesettings', 'onionport', '8444')
if not shared.config.has_option('bitmessagesettings', 'onionbindip'):
shared.config.set('bitmessagesettings', 'onionbindip', '127.0.0.1')
if not shared.config.has_option('bitmessagesettings', 'smtpdeliver'):
shared.config.set('bitmessagesettings', 'smtpdeliver', '')
shared.writeKeysFile()
# Are you hoping to add a new option to the keys.dat file of existing

View File

@ -401,6 +401,12 @@ def safeConfigGetBoolean(section,field):
except Exception, err:
return False
def safeConfigGet(section, option, default = None):
if config.has_option (section, option):
return config.get(section, option)
else:
return default
def decodeWalletImportFormat(WIFstring):
fullString = arithmetic.changebase(WIFstring,58,256)
privkey = fullString[:-4]