Browse Source

handle DNSPython libs not being available

283
Riccardo Spagni 10 years ago
parent
commit
8b2af48b56
No known key found for this signature in database GPG Key ID: 55432DF31CCD4FCD
  1. 30
      plugins/openalias.py

30
plugins/openalias.py

@ -6,13 +6,17 @@ from PyQt4.QtCore import *
import re import re
import dns.name try:
import dns.query import dns.name
import dns.dnssec import dns.query
import dns.message import dns.dnssec
import dns.resolver import dns.message
import dns.rdatatype import dns.resolver
from dns.exception import DNSException import dns.rdatatype
from dns.exception import DNSException
OA_READY = True
except ImportError:
OA_READY = False
class Plugin(BasePlugin): class Plugin(BasePlugin):
@ -20,11 +24,14 @@ class Plugin(BasePlugin):
return 'OpenAlias' return 'OpenAlias'
def description(self): def description(self):
return 'Import contacts by OpenAlias.' return 'Allow for payments to OpenAlias addresses.'
def is_available(self):
return OA_READY
def __init__(self, gui, name): def __init__(self, gui, name):
BasePlugin.__init__(self, gui, name) BasePlugin.__init__(self, gui, name)
self._is_available = True self._is_available = OA_READY
@hook @hook
def init_qt(self, gui): def init_qt(self, gui):
@ -45,12 +52,17 @@ class Plugin(BasePlugin):
return False to continue execution of the send return False to continue execution of the send
return True to stop execution of the send return True to stop execution of the send
''' '''
if self.win.payto_e.is_multiline(): # only supports single line entries atm if self.win.payto_e.is_multiline(): # only supports single line entries atm
return False return False
url = str(self.win.payto_e.toPlainText()) url = str(self.win.payto_e.toPlainText())
if not '.' in url: if not '.' in url:
return False return False
else:
if not OA_READY:
QMessageBox.warning(self.win, _('Error'), 'Could not load DNSPython libraries, please ensure they are available and/or Electrum has been built correctly', _('OK'))
return False
data = self.resolve(url) data = self.resolve(url)

Loading…
Cancel
Save