From b092df7e586006b1f6394f9935716437414a8499 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Wed, 14 Aug 2013 19:46:59 -0400 Subject: [PATCH] added some more error handling --- src/bitmessageqt/__init__.py | 30 +++++++++++++++++------------- src/class_sqlThread.py | 3 +++ src/namecoin.py | 1 - 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index b426e6e5..6064fe3d 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -438,14 +438,18 @@ 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. - options = {} - options["type"] = shared.config.get('bitmessagesettings', 'namecoinrpctype') - options["host"] = shared.config.get('bitmessagesettings', 'namecoinrpchost') - options["port"] = shared.config.get('bitmessagesettings', 'namecoinrpcport') - options["user"] = shared.config.get('bitmessagesettings', 'namecoinrpcuser') - options["password"] = shared.config.get('bitmessagesettings', 'namecoinrpcpassword') - nc = namecoinConnection(options) - if nc.test()[0] == 'failed': + try: + options = {} + options["type"] = shared.config.get('bitmessagesettings', 'namecoinrpctype') + options["host"] = shared.config.get('bitmessagesettings', 'namecoinrpchost') + options["port"] = shared.config.get('bitmessagesettings', 'namecoinrpcport') + options["user"] = shared.config.get('bitmessagesettings', 'namecoinrpcuser') + options["password"] = shared.config.get('bitmessagesettings', 'namecoinrpcpassword') + 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() @@ -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() diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index 625b2b2f..6ac0f168 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -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 = '' diff --git a/src/namecoin.py b/src/namecoin.py index 3f6c584c..037eae80 100644 --- a/src/namecoin.py +++ b/src/namecoin.py @@ -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")