URI: 
       tdetect available hardware wallets before listing them in wizard - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 992c70a6885f22150086658cafb931d61240e505
   DIR parent 280b5c79d2268a89fccb7740904e5a59948ea887
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Sat, 22 Aug 2015 08:56:04 +0200
       
       detect available hardware wallets before listing them in wizard
       
       Diffstat:
         M gui/qt/installwizard.py             |      12 +++++++++++-
         M lib/plugins.py                      |      25 +++++++++++--------------
         M lib/wallet.py                       |       4 ++--
       
       3 files changed, 24 insertions(+), 17 deletions(-)
       ---
   DIR diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py
       t@@ -442,7 +442,17 @@ class InstallWizard(QDialog):
                        if not wallet_type:
                            return
                    elif wallet_type == 'hardware':
       -                hardware_wallets = map(lambda x:(x[1],x[2]), filter(lambda x:x[0]=='hardware', electrum.wallet.wallet_types))
       +                hardware_wallets = []
       +                for item in electrum.wallet.wallet_types:
       +                    t, name, description, loader = item
       +                    if t == 'hardware':
       +                        try:
       +                            p = loader()
       +                        except:
       +                            util.print_error("cannot load plugin for:", name)
       +                            continue
       +                        if p:
       +                            hardware_wallets.append((name, description))
                        wallet_type = self.choice(_("Hardware Wallet"), 'Select your hardware wallet', hardware_wallets)
        
                        if not wallet_type:
   DIR diff --git a/lib/plugins.py b/lib/plugins.py
       t@@ -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
       t@@ -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
       t@@ -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:
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -1925,9 +1925,9 @@ class Wallet(object):
        
                wallet_type = storage.get('wallet_type')
                if wallet_type:
       -            for cat, t, name, c in wallet_types:
       +            for cat, t, name, loader in wallet_types:
                        if t == wallet_type:
       -                    WalletClass = c
       +                    WalletClass = lambda storage: apply(loader().constructor, (storage,))
                            break
                    else:
                        if re.match('(\d+)of(\d+)', wallet_type):