mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
Plugin wallets: better error when unloadable
Used to get: jsonrpclib.jsonrpc.ProtocolError: (-32603, u'Server error: File "src/electrum/lib/plugins.py", line 144, in wallet_plugin_loader | KeyError: \'trustedcoin\'') Now get: jsonrpclib.jsonrpc.ProtocolError: (-32603, u'Server error: File "src/electrum/lib/plugins.py", line 81, in load_plugin | RuntimeError: cmdline implementation for trustedcoin plugin not found')
This commit is contained in:
parent
f4fa53e915
commit
dee402b961
3 changed files with 19 additions and 14 deletions
1
electrum
1
electrum
|
@ -18,7 +18,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -51,6 +51,8 @@ class Plugins(DaemonThread):
|
||||||
m = loader.find_module(name).load_module(name)
|
m = loader.find_module(name).load_module(name)
|
||||||
d = m.__dict__
|
d = m.__dict__
|
||||||
gui_good = gui_name in d.get('available_for', [])
|
gui_good = gui_name in d.get('available_for', [])
|
||||||
|
# We register wallet types even if the GUI isn't provided
|
||||||
|
# so that they can be restored in the install wizard
|
||||||
details = d.get('registers_wallet_type')
|
details = d.get('registers_wallet_type')
|
||||||
if details:
|
if details:
|
||||||
self.register_plugin_wallet(name, gui_good, details)
|
self.register_plugin_wallet(name, gui_good, details)
|
||||||
|
@ -58,7 +60,12 @@ class Plugins(DaemonThread):
|
||||||
continue
|
continue
|
||||||
self.descriptions[name] = d
|
self.descriptions[name] = d
|
||||||
if not d.get('requires_wallet_type') and config.get('use_' + name):
|
if not d.get('requires_wallet_type') and config.get('use_' + name):
|
||||||
|
try:
|
||||||
self.load_plugin(name)
|
self.load_plugin(name)
|
||||||
|
except BaseException as e:
|
||||||
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
self.print_error("cannot initialize plugin %s:" % name,
|
||||||
|
str(e))
|
||||||
|
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
return self.plugins.get(name)
|
return self.plugins.get(name)
|
||||||
|
@ -68,17 +75,16 @@ class Plugins(DaemonThread):
|
||||||
|
|
||||||
def load_plugin(self, name):
|
def load_plugin(self, name):
|
||||||
full_name = 'electrum_plugins.' + name + '.' + self.gui_name
|
full_name = 'electrum_plugins.' + name + '.' + self.gui_name
|
||||||
try:
|
loader = pkgutil.find_loader(full_name)
|
||||||
p = pkgutil.find_loader(full_name).load_module(full_name)
|
if not loader:
|
||||||
|
raise RuntimeError("%s implementation for %s plugin not found"
|
||||||
|
% (self.gui_name, name))
|
||||||
|
p = loader.load_module(full_name)
|
||||||
plugin = p.Plugin(self, self.config, name)
|
plugin = p.Plugin(self, self.config, name)
|
||||||
self.add_jobs(plugin.thread_jobs())
|
self.add_jobs(plugin.thread_jobs())
|
||||||
self.plugins[name] = plugin
|
self.plugins[name] = plugin
|
||||||
self.print_error("loaded", name)
|
self.print_error("loaded", name)
|
||||||
return plugin
|
return plugin
|
||||||
except Exception:
|
|
||||||
self.print_error("cannot initialize plugin", name)
|
|
||||||
traceback.print_exc(file=sys.stdout)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def close_plugin(self, plugin):
|
def close_plugin(self, plugin):
|
||||||
self.remove_jobs(plugin.thread_jobs())
|
self.remove_jobs(plugin.thread_jobs())
|
||||||
|
|
|
@ -8,4 +8,4 @@ description = ''.join([
|
||||||
])
|
])
|
||||||
requires_wallet_type = ['2fa']
|
requires_wallet_type = ['2fa']
|
||||||
registers_wallet_type = ('twofactor', '2fa', _("Wallet with two-factor authentication"))
|
registers_wallet_type = ('twofactor', '2fa', _("Wallet with two-factor authentication"))
|
||||||
available_for = ['qt', 'cmdline']
|
available_for = ['qt']
|
||||||
|
|
Loading…
Add table
Reference in a new issue