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 untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
4 changed files with 11 additions and 3 deletions

View File

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

View File

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

View File

@ -425,6 +425,8 @@ class sqlThread(threading.Thread):
shared.config.set('bitmessagesettings', 'onionport', '8444') shared.config.set('bitmessagesettings', 'onionport', '8444')
if not shared.config.has_option('bitmessagesettings', 'onionbindip'): if not shared.config.has_option('bitmessagesettings', 'onionbindip'):
shared.config.set('bitmessagesettings', 'onionbindip', '127.0.0.1') shared.config.set('bitmessagesettings', 'onionbindip', '127.0.0.1')
if not shared.config.has_option('bitmessagesettings', 'smtpdeliver'):
shared.config.set('bitmessagesettings', 'smtpdeliver', '')
shared.writeKeysFile() shared.writeKeysFile()
# Are you hoping to add a new option to the keys.dat file of existing # 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: except Exception, err:
return False 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): def decodeWalletImportFormat(WIFstring):
fullString = arithmetic.changebase(WIFstring,58,256) fullString = arithmetic.changebase(WIFstring,58,256)
privkey = fullString[:-4] privkey = fullString[:-4]