check gui when loading plugins

This commit is contained in:
ThomasV 2015-05-24 09:26:28 +02:00
parent a48a7951a7
commit d40c12c949
3 changed files with 32 additions and 22 deletions

View File

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

View File

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

View File

@ -25,7 +25,7 @@ descriptions = [
'description': ('Provides support for air-gapped transaction signing.\n\n'
'Requires http://github.com/romanz/amodem/'),
'requires': ['amodem'],
'GUI': ['qt']
'available_for': ['qt'],
},
{
'name': 'btchipwallet',
@ -33,7 +33,8 @@ descriptions = [
'description': _('Provides support for BTChip hardware wallet') + '\n\n' + _('Requires github.com/btchip/btchip-python'),
'requires': ['btchip'],
'requires_wallet_type': ['btchip'],
'registers_wallet_type': True
'registers_wallet_type': True,
'available_for': ['qt'],
},
{
'name': 'cosigner_pool',
@ -43,29 +44,33 @@ descriptions = [
_("It sends and receives partially signed transactions from/to your cosigner wallet."),
_("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',
'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',
'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',
'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',
'fullname': 'OpenAlias',
'description': 'Allow for payments to OpenAlias addresses.\nRequires dnspython',
'requires': ['dns']
'requires': ['dns'],
'available_for': ['qt']
},
{
'name': 'plot',
@ -75,16 +80,17 @@ descriptions = [
_("Warning: Requires matplotlib library.")
]),
'requires': ['matplotlib'],
'GUI': ['qt']
'available_for': ['qt'],
},
{
'name':'trezor',
'fullname': 'Trezor Wallet',
'description': 'Provides support for Trezor hardware wallet\n\nRequires github.com/trezor/python-trezor',
'GUI': ['qt'],
'available_for': ['qt'],
'requires': ['trezorlib'],
'requires_wallet_type': ['trezor'],
'registers_wallet_type': True
'registers_wallet_type': True,
'available_for': ['qt', 'cmdline']
},
{
'name': 'trustedcoin',
@ -94,13 +100,14 @@ descriptions = [
_("For more information, visit"),
" <a href=\"https://api.trustedcoin.com/#/electrum-help\">https://api.trustedcoin.com/#/electrum-help</a>"
]),
'GUI': ['none', 'qt'],
'requires_wallet_type': ['2fa'],
'registers_wallet_type': True
'registers_wallet_type': True,
'available_for': ['qt', 'cmdline'],
},
{
'name': 'virtualkeyboard',
'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.")),
'available_for': ['qt'],
}
]