commit ec3b7ba5ee0fd20ceae9766589c492f03d14fc64
parent ac4adbb298ee9b0782e481af75367f1a8b2b5e85
Author: Neil Booth <kyuupichan@gmail.com>
Date: Fri, 4 Sep 2015 09:07:18 +0900
Pass plugins object to plugin constructor
Diffstat:
8 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/lib/plugins.py b/lib/plugins.py
@@ -67,7 +67,7 @@ class Plugins:
p = imp.load_source(full_name, path)
else:
p = __import__(full_name, fromlist=['electrum_plugins'])
- plugin = p.Plugin(config, name)
+ plugin = p.Plugin(self, config, name)
self.plugins[name] = plugin
self.print_error("loaded", name)
return plugin
@@ -155,7 +155,8 @@ def _run_hook(name, always, *args):
class BasePlugin:
- def __init__(self, config, name):
+ def __init__(self, parent, config, name):
+ self.parent = parent # The plugins object
self.name = name
self.config = config
self.wallet = None
diff --git a/plugins/audio_modem.py b/plugins/audio_modem.py
@@ -27,8 +27,8 @@ except ImportError:
class Plugin(BasePlugin):
- def __init__(self, config, name):
- BasePlugin.__init__(self, config, name)
+ def __init__(self, parent, config, name):
+ BasePlugin.__init__(self, parent, config, name)
if self.is_available():
self.modem_config = amodem.config.slowest()
self.library_name = {
@@ -141,5 +141,3 @@ class Plugin(BasePlugin):
msg = 'Receiving from Audio MODEM ({0:.1f} kbps)...'.format(kbps)
return WaitingDialog(parent=parent, message=msg,
run_task=receiver_thread, on_success=on_success)
-
-
diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py
@@ -34,8 +34,8 @@ except ImportError:
class Plugin(BasePlugin):
- def __init__(self, gui, name):
- BasePlugin.__init__(self, gui, name)
+ def __init__(self, parent, config, name):
+ BasePlugin.__init__(self, parent, config, name)
self._is_available = self._init()
self.wallet = None
self.handler = None
@@ -170,10 +170,10 @@ class BTChipWallet(BIP32_HD_Wallet):
aborted = False
if not self.client or self.client.bad:
- try:
+ try:
d = getDongle(BTCHIP_DEBUG)
self.client = btchip(d)
- self.client.handler = self.plugin.handler
+ self.client.handler = self.plugin.handler
firmware = self.client.getFirmwareVersion()['version'].split(".")
if not checkFirmware(firmware):
d.close()
@@ -416,7 +416,7 @@ class BTChipWallet(BIP32_HD_Wallet):
format_satoshis_plain(self.get_tx_fee(tx)), changePath, bytearray(rawTx.decode('hex')))
if firstTransaction:
transactionOutput = outputData['outputData']
- if outputData['confirmationNeeded']:
+ if outputData['confirmationNeeded']:
# TODO : handle different confirmation types. For the time being only supports keyboard 2FA
self.plugin.handler.stop()
if 'keycardData' in outputData:
@@ -532,7 +532,7 @@ class BTChipQTHandler:
return self.response
def auth_dialog(self):
- response = QInputDialog.getText(None, "Ledger Wallet Authentication", self.message, QLineEdit.Password)
+ response = QInputDialog.getText(None, "Ledger Wallet Authentication", self.message, QLineEdit.Password)
if not response[1]:
self.response = None
else:
@@ -563,7 +563,7 @@ class BTChipCmdLineHandler:
print_msg(msg)
def prompt_auth(self, msg):
- import getpass
+ import getpass
print_msg(msg)
response = getpass.getpass('')
if len(response) == 0:
diff --git a/plugins/email_requests.py b/plugins/email_requests.py
@@ -114,8 +114,8 @@ class Plugin(BasePlugin):
def is_available(self):
return True
- def __init__(self, a, b):
- BasePlugin.__init__(self, a, b)
+ def __init__(self, parent, config, name)
+ BasePlugin.__init__(self, parent, config, name)
self.imap_server = self.config.get('email_server', '')
self.username = self.config.get('email_username', '')
self.password = self.config.get('email_password', '')
@@ -204,7 +204,7 @@ class Plugin(BasePlugin):
vbox.addStretch()
vbox.addLayout(Buttons(CloseButton(d), OkButton(d)))
- if not d.exec_():
+ if not d.exec_():
return
server = str(server_e.text())
@@ -215,5 +215,3 @@ class Plugin(BasePlugin):
password = str(password_e.text())
self.config.set_key('email_password', password)
-
-
diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py
@@ -162,8 +162,8 @@ class Exchanger(ThreadJob):
class Plugin(BasePlugin):
- def __init__(self,a,b):
- BasePlugin.__init__(self,a,b)
+ def __init__(self, parent, config, name):
+ BasePlugin.__init__(self, parent, config, name)
self.exchange = self.config.get('use_exchange', "Blockchain")
self.currencies = [self.fiat_unit()]
self.exchanger = Exchanger(self)
diff --git a/plugins/keepkey.py b/plugins/keepkey.py
@@ -48,8 +48,8 @@ def give_error(message):
class Plugin(BasePlugin):
- def __init__(self, config, name):
- BasePlugin.__init__(self, config, name)
+ def __init__(self, parent, config, name):
+ BasePlugin.__init__(self, parent, config, name)
self._is_available = self._init()
self.wallet = None
self.handler = None
@@ -240,7 +240,7 @@ class Plugin(BasePlugin):
except Exception, e:
self.handler.stop()
give_error(e)
-
+
self.handler.stop()
raw = signed_tx.encode('hex')
diff --git a/plugins/trezor.py b/plugins/trezor.py
@@ -48,8 +48,8 @@ def give_error(message):
class Plugin(BasePlugin):
- def __init__(self, config, name):
- BasePlugin.__init__(self, config, name)
+ def __init__(self, parent, config, name):
+ BasePlugin.__init__(self, parent, config, name)
self._is_available = self._init()
self.wallet = None
self.handler = None
diff --git a/plugins/trustedcoin.py b/plugins/trustedcoin.py
@@ -212,8 +212,8 @@ class Plugin(BasePlugin):
wallet = None
- def __init__(self, x, y):
- BasePlugin.__init__(self, x, y)
+ def __init__(self, parent, config, name):
+ BasePlugin.__init__(self, parent, config, name)
self.seed_func = lambda x: bitcoin.is_new_seed(x, SEED_PREFIX)
self.billing_info = None
self.is_billing = False