added some more error handling

This commit is contained in:
Jonathan Warren 2013-08-14 19:46:59 -04:00
parent 6ec4d5c73a
commit b092df7e58
3 changed files with 20 additions and 14 deletions

View File

@ -438,6 +438,7 @@ class MyForm(QtGui.QMainWindow):
self.rerenderComboBoxSendFrom()
# Check to see whether we can connect to namecoin. Hide the 'Fetch Namecoin ID' button if we can't.
try:
options = {}
options["type"] = shared.config.get('bitmessagesettings', 'namecoinrpctype')
options["host"] = shared.config.get('bitmessagesettings', 'namecoinrpchost')
@ -447,6 +448,9 @@ class MyForm(QtGui.QMainWindow):
nc = namecoinConnection(options)
if nc.test()[0] == 'failed':
self.ui.pushButtonFetchNamecoinID.hide()
except:
print 'There was a problem testing for a Namecoin daemon. Hiding the Fetch Namecoin ID button'
self.ui.pushButtonFetchNamecoinID.hide()
# Show or hide the application window after clicking an item within the
@ -3095,8 +3099,6 @@ class settingsDialog(QtGui.QDialog):
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')) / shared.networkDefaultPayloadLengthExtraBytes)))
# Namecoin integration tab
ensureNamecoinOptions()
nmctype = shared.config.get('bitmessagesettings', 'namecoinrpctype')
self.ui.lineEditNamecoinHost.setText(str(
shared.config.get('bitmessagesettings', 'namecoinrpchost')))
@ -3200,9 +3202,11 @@ class settingsDialog(QtGui.QDialog):
options["user"] = self.ui.lineEditNamecoinUser.text()
options["password"] = self.ui.lineEditNamecoinPassword.text()
nc = namecoinConnection(options)
responseStatus = nc.test()[1]
self.ui.labelNamecoinTestResult.setText(responseStatus)
if nc.test()[0]== 'success':
response = nc.test()
responseStatus = response[0]
responseText = response[1]
self.ui.labelNamecoinTestResult.setText(responseText)
if responseStatus== 'success':
self.parent.ui.pushButtonFetchNamecoinID.show()

View File

@ -6,6 +6,7 @@ import shutil # used for moving the messages.dat file
import sys
import os
from debug import logger
from namecoin import ensureNamecoinOptions
# This thread exists because SQLITE3 is so un-threadsafe that we must
# submit queries to it and it puts results back in a different queue. They
@ -190,6 +191,8 @@ class sqlThread(threading.Thread):
if not shared.config.has_option('bitmessagesettings', 'sockslisten'):
shared.config.set('bitmessagesettings', 'sockslisten', 'false')
ensureNamecoinOptions()
# Add a new column to the inventory table to store the first 20 bytes of encrypted messages to support Android app
item = '''SELECT value FROM settings WHERE key='version';'''
parameters = ''

View File

@ -52,7 +52,6 @@ class namecoinConnection (object):
# actually changing the values (yet).
def __init__ (self, options = None):
if options is None:
ensureNamecoinOptions ()
self.nmctype = shared.config.get (configSection, "namecoinrpctype")
self.host = shared.config.get (configSection, "namecoinrpchost")
self.port = shared.config.get (configSection, "namecoinrpcport")