1
0

detect available hardware wallets before listing them in wizard

This commit is contained in:
ThomasV
2015-08-22 08:56:04 +02:00
committed by ThomasV
parent 280b5c79d2
commit 992c70a688
3 changed files with 24 additions and 17 deletions

View File

@@ -49,6 +49,14 @@ def is_available(name, w):
return True
def plugin_loader(config, name):
global plugins
if plugins.get(name) is None:
print_error(_("Loading plugin by constructor:"), name)
p = loader(name)
plugins[name] = p.Plugin(config, name)
return plugins[name]
@profiler
def init_plugins(config, is_local, gui_name):
global plugins, descriptions, loader
@@ -60,20 +68,9 @@ def init_plugins(config, is_local, gui_name):
electrum_plugins = __import__('electrum_plugins')
loader = lambda name: __import__('electrum_plugins.' + name, fromlist=['electrum_plugins'])
def constructor(name, storage):
if plugins.get(name) is None:
try:
print_error(_("Loading plugin by constructor:"), name)
p = loader(name)
plugins[name] = p.Plugin(config, name)
except:
print_msg(_("Error: cannot initialize plugin"), name)
return
return plugins[name].constructor(storage)
def register_wallet_type(name, x, constructor):
def register_wallet_type(name, x):
import wallet
x += (lambda storage: constructor(name, storage),)
x += (lambda: plugin_loader(config, name),)
wallet.wallet_types.append(x)
descriptions = electrum_plugins.descriptions
@@ -83,7 +80,7 @@ def init_plugins(config, is_local, gui_name):
continue
x = item.get('registers_wallet_type')
if x:
register_wallet_type(name, x, constructor)
register_wallet_type(name, x)
if not config.get('use_' + name):
continue
try: