Do not use side-effects of import to initialize hardware plugins
Call HidTransport in the context of a function
This commit is contained in:
@@ -11,11 +11,25 @@ class KeepKeyPlugin(TrezorCompatiblePlugin):
|
||||
libraries_URL = 'https://github.com/keepkey/python-keepkey'
|
||||
minimum_firmware = (1, 0, 0)
|
||||
keystore_class = KeepKey_KeyStore
|
||||
try:
|
||||
from .client import KeepKeyClient as client_class
|
||||
import keepkeylib.ckd_public as ckd_public
|
||||
from keepkeylib.client import types
|
||||
from keepkeylib.transport_hid import HidTransport, DEVICE_IDS
|
||||
libraries_available = True
|
||||
except ImportError:
|
||||
libraries_available = False
|
||||
|
||||
def __init__(self, *args):
|
||||
try:
|
||||
import client
|
||||
import keepkeylib
|
||||
import keepkeylib.ckd_public
|
||||
import keepkeylib.transport_hid
|
||||
self.client_class = client.KeepKeyClient
|
||||
self.ckd_public = keepkeylib.ckd_public
|
||||
self.types = keepkeylib.client.types
|
||||
self.DEVICE_IDS = keepkeylib.transport_hid.DEVICE_IDS
|
||||
self.libraries_available = True
|
||||
except ImportError:
|
||||
self.libraries_available = False
|
||||
TrezorCompatiblePlugin.__init__(self, *args)
|
||||
|
||||
def hid_transport(self, pair):
|
||||
from keepkeylib.transport_hid import HidTransport
|
||||
return HidTransport(pair)
|
||||
|
||||
def bridge_transport(self, d):
|
||||
raise NotImplementedError('')
|
||||
|
||||
Reference in New Issue
Block a user