tPass plugins object to plugin constructor - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit ec3b7ba5ee0fd20ceae9766589c492f03d14fc64 DIR parent ac4adbb298ee9b0782e481af75367f1a8b2b5e85 HTML Author: Neil Booth <kyuupichan@gmail.com> Date: Fri, 4 Sep 2015 09:07:18 +0900 Pass plugins object to plugin constructor Diffstat: M lib/plugins.py | 5 +++-- M plugins/audio_modem.py | 6 ++---- M plugins/btchipwallet.py | 14 +++++++------- M plugins/email_requests.py | 8 +++----- M plugins/exchange_rate.py | 4 ++-- M plugins/keepkey.py | 6 +++--- M plugins/trezor.py | 4 ++-- M plugins/trustedcoin.py | 4 ++-- 8 files changed, 24 insertions(+), 27 deletions(-) --- DIR diff --git a/lib/plugins.py b/lib/plugins.py t@@ -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 t@@ -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 DIR diff --git a/plugins/audio_modem.py b/plugins/audio_modem.py t@@ -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 = { t@@ -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) - - DIR diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py t@@ -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 t@@ -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() t@@ -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: t@@ -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: t@@ -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: DIR diff --git a/plugins/email_requests.py b/plugins/email_requests.py t@@ -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', '') t@@ -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()) t@@ -215,5 +215,3 @@ class Plugin(BasePlugin): password = str(password_e.text()) self.config.set_key('email_password', password) - - DIR diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py t@@ -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) DIR diff --git a/plugins/keepkey.py b/plugins/keepkey.py t@@ -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 t@@ -240,7 +240,7 @@ class Plugin(BasePlugin): except Exception, e: self.handler.stop() give_error(e) - + self.handler.stop() raw = signed_tx.encode('hex') DIR diff --git a/plugins/trezor.py b/plugins/trezor.py t@@ -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 DIR diff --git a/plugins/trustedcoin.py b/plugins/trustedcoin.py t@@ -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