Browse Source

check gui when loading plugins

283
ThomasV 10 years ago
parent
commit
d40c12c949
  1. 12
      electrum
  2. 7
      lib/plugins.py
  3. 33
      plugins/__init__.py

12
electrum

@ -222,14 +222,14 @@ if __name__ == '__main__':
else: else:
cmd = args[0] cmd = args[0]
gui_name = config.get('gui', 'qt') if cmd == 'gui' else 'cmdline'
if gui_name in ['lite', 'classic']:
gui_name = 'qt'
# initialize plugins. # initialize plugins.
# FIXME: check gui init_plugins(config, is_bundle or is_local or is_android, gui_name)
init_plugins(config, is_bundle or is_local or is_android, cmd=='gui')
if cmd == 'gui': if gui_name != 'cmdline':
gui_name = config.get('gui', 'classic')
if gui_name in ['lite', 'classic']:
gui_name = 'qt'
try: try:
gui = __import__('electrum_gui.' + gui_name, fromlist=['electrum_gui']) gui = __import__('electrum_gui.' + gui_name, fromlist=['electrum_gui'])
except ImportError: except ImportError:

7
lib/plugins.py

@ -24,7 +24,7 @@ import pkgutil
from util import * from util import *
from i18n import _ from i18n import _
from util import print_error from util import print_error, profiler
plugins = {} plugins = {}
descriptions = [] descriptions = []
@ -49,7 +49,8 @@ def is_available(name, w):
return True return True
def init_plugins(config, is_local, is_gui): @profiler
def init_plugins(config, is_local, gui_name):
global plugins, descriptions, loader global plugins, descriptions, loader
if is_local: if is_local:
fp, pathname, description = imp.find_module('plugins') fp, pathname, description = imp.find_module('plugins')
@ -73,6 +74,8 @@ def init_plugins(config, is_local, is_gui):
descriptions = electrum_plugins.descriptions descriptions = electrum_plugins.descriptions
for item in descriptions: for item in descriptions:
name = item['name'] name = item['name']
if gui_name not in item.get('available_for', []):
continue
if item.get('registers_wallet_type'): if item.get('registers_wallet_type'):
register_wallet_type(name) register_wallet_type(name)
if not config.get('use_' + name): if not config.get('use_' + name):

33
plugins/__init__.py

@ -25,7 +25,7 @@ descriptions = [
'description': ('Provides support for air-gapped transaction signing.\n\n' 'description': ('Provides support for air-gapped transaction signing.\n\n'
'Requires http://github.com/romanz/amodem/'), 'Requires http://github.com/romanz/amodem/'),
'requires': ['amodem'], 'requires': ['amodem'],
'GUI': ['qt'] 'available_for': ['qt'],
}, },
{ {
'name': 'btchipwallet', 'name': 'btchipwallet',
@ -33,7 +33,8 @@ descriptions = [
'description': _('Provides support for BTChip hardware wallet') + '\n\n' + _('Requires github.com/btchip/btchip-python'), 'description': _('Provides support for BTChip hardware wallet') + '\n\n' + _('Requires github.com/btchip/btchip-python'),
'requires': ['btchip'], 'requires': ['btchip'],
'requires_wallet_type': ['btchip'], 'requires_wallet_type': ['btchip'],
'registers_wallet_type': True 'registers_wallet_type': True,
'available_for': ['qt'],
}, },
{ {
'name': 'cosigner_pool', 'name': 'cosigner_pool',
@ -43,29 +44,33 @@ descriptions = [
_("It sends and receives partially signed transactions from/to your cosigner wallet."), _("It sends and receives partially signed transactions from/to your cosigner wallet."),
_("Transactions are encrypted and stored on a remote server.") _("Transactions are encrypted and stored on a remote server.")
]), ]),
'GUI': ['qt'], 'requires_wallet_type': ['2of2', '2of3'],
'requires_wallet_type': ['2of2', '2of3'] 'available_for': ['qt'],
}, },
{ {
'name': 'exchange_rate', 'name': 'exchange_rate',
'fullname': _("Exchange rates"), 'fullname': _("Exchange rates"),
'description': """exchange rates, retrieved from blockchain.info, CoinDesk, or Coinbase""" 'description': """exchange rates, retrieved from blockchain.info, CoinDesk, or Coinbase""",
'available_for': ['qt'],
}, },
{ {
'name': 'greenaddress_instant', 'name': 'greenaddress_instant',
'fullname': 'GreenAddress instant', 'fullname': 'GreenAddress instant',
'description': _("Allows validating if your transactions have instant confirmations by GreenAddress") 'description': _("Allows validating if your transactions have instant confirmations by GreenAddress"),
'available_for': ['qt'],
}, },
{ {
'name': 'labels', 'name': 'labels',
'fullname': _('LabelSync'), 'fullname': _('LabelSync'),
'description': '%s\n\n%s' % (_("The new and improved LabelSync plugin. This can sync your labels across multiple Electrum installs by using a remote database to save your data. Labels, transactions ids and addresses are encrypted before they are sent to the remote server."), _("The label sync's server software is open-source as well and can be found on github.com/maran/electrum-sync-server")) 'description': '%s\n\n%s' % (_("The new and improved LabelSync plugin. This can sync your labels across multiple Electrum installs by using a remote database to save your data. Labels, transactions ids and addresses are encrypted before they are sent to the remote server."), _("The label sync's server software is open-source as well and can be found on github.com/maran/electrum-sync-server")),
'available_for': ['qt']
}, },
{ {
'name': 'openalias', 'name': 'openalias',
'fullname': 'OpenAlias', 'fullname': 'OpenAlias',
'description': 'Allow for payments to OpenAlias addresses.\nRequires dnspython', 'description': 'Allow for payments to OpenAlias addresses.\nRequires dnspython',
'requires': ['dns'] 'requires': ['dns'],
'available_for': ['qt']
}, },
{ {
'name': 'plot', 'name': 'plot',
@ -75,16 +80,17 @@ descriptions = [
_("Warning: Requires matplotlib library.") _("Warning: Requires matplotlib library.")
]), ]),
'requires': ['matplotlib'], 'requires': ['matplotlib'],
'GUI': ['qt'] 'available_for': ['qt'],
}, },
{ {
'name':'trezor', 'name':'trezor',
'fullname': 'Trezor Wallet', 'fullname': 'Trezor Wallet',
'description': 'Provides support for Trezor hardware wallet\n\nRequires github.com/trezor/python-trezor', 'description': 'Provides support for Trezor hardware wallet\n\nRequires github.com/trezor/python-trezor',
'GUI': ['qt'], 'available_for': ['qt'],
'requires': ['trezorlib'], 'requires': ['trezorlib'],
'requires_wallet_type': ['trezor'], 'requires_wallet_type': ['trezor'],
'registers_wallet_type': True 'registers_wallet_type': True,
'available_for': ['qt', 'cmdline']
}, },
{ {
'name': 'trustedcoin', 'name': 'trustedcoin',
@ -94,13 +100,14 @@ descriptions = [
_("For more information, visit"), _("For more information, visit"),
" <a href=\"https://api.trustedcoin.com/#/electrum-help\">https://api.trustedcoin.com/#/electrum-help</a>" " <a href=\"https://api.trustedcoin.com/#/electrum-help\">https://api.trustedcoin.com/#/electrum-help</a>"
]), ]),
'GUI': ['none', 'qt'],
'requires_wallet_type': ['2fa'], 'requires_wallet_type': ['2fa'],
'registers_wallet_type': True 'registers_wallet_type': True,
'available_for': ['qt', 'cmdline'],
}, },
{ {
'name': 'virtualkeyboard', 'name': 'virtualkeyboard',
'fullname': 'Virtual Keyboard', 'fullname': 'Virtual Keyboard',
'description': '%s\n%s' % (_("Add an optional virtual keyboard to the password dialog."), _("Warning: do not use this if it makes you pick a weaker password.")), 'description': '%s\n%s' % (_("Add an optional virtual keyboard to the password dialog."), _("Warning: do not use this if it makes you pick a weaker password.")),
'available_for': ['qt'],
} }
] ]

Loading…
Cancel
Save