示例#1
0
 def __init__(self, parent, config, name):
     HW_PluginBase.__init__(self, parent, config, name)
     if not self.libraries_available:
         return
     # to support legacy devices and legacy firmwares
     self.device_manager().register_devices(self.DEVICE_IDS, plugin=self)
     # to support modern firmware
     self.device_manager().register_vendor_ids(self.VENDOR_IDS, plugin=self)
示例#2
0
    def unpaired_device_infos(
            self,
            handler: Optional[HardwareHandlerBase],
            plugin: HW_PluginBase,
            devices: List[Device] = None) -> List['DeviceInfo']:
        '''Returns a list of DeviceInfo objects: one for each connected,
        unpaired device accepted by the plugin.'''
        if devices is None:
            devices = self.scan_devices()
        devices = [dev for dev in devices if not self.xpub_by_id(dev.id_)]
        infos = []
        for device in devices:
            if not plugin.can_recognize_device(device):
                continue
            client = self.create_client(device, handler, plugin)
            if not client:
                continue
            infos.append(
                DeviceInfo(
                    device=device,
                    label=client.label(),
                    initialized=client.is_initialized(),
                    model_name=client.device_model_name(),
                ))

        return infos
示例#3
0
 def create_client(self, device: Device, handler: HardwareHandlerBase,
                   plugin: HW_PluginBase) -> Optional[HardwareClientBase]:
     # Get from cache first
     client = self._client_by_id(device.id_)
     if client:
         return client
     client = plugin.create_client(device, handler)
     if client:
         self.print_error("Registering", client)
         with self.lock:
             self.clients[client] = (device.path, device.id_)
     return client
示例#4
0
    def __init__(self, parent, config, name):
        HW_PluginBase.__init__(self, parent, config, name)

        try:
            from electroncash_plugins.keepkey import client
            import keepkeylib
            import keepkeylib.ckd_public
            import keepkeylib.transport_hid
            import keepkeylib.transport_webusb
            from usb1 import USBContext
            self.client_class = client.KeepKeyClient
            self.ckd_public = keepkeylib.ckd_public
            self.types = keepkeylib.client.types
            self.DEVICE_IDS = (keepkeylib.transport_hid.DEVICE_IDS +
                               keepkeylib.transport_webusb.DEVICE_IDS)
            self.device_manager().register_devices(self.DEVICE_IDS)
            self.device_manager().register_enumerate_func(self.enumerate)
            self.usb_context = USBContext()
            self.usb_context.open()
            self.libraries_available = True
        except ImportError:
            self.libraries_available = False
示例#5
0
 def __init__(self, parent, config, name):
     HW_PluginBase.__init__(self, parent, config, name)
     if self.libraries_available:
         self.device_manager().register_devices(self.DEVICE_IDS)