URI: 
       tDeviceMgr: scan_devices can work without hid - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit c0ae266d39786662fee5ae9d03788e2d4d372b14
   DIR parent aabd9f01ee1b847e761e91a10326f1bd234647ac
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Fri, 16 Mar 2018 00:55:45 +0100
       
       DeviceMgr: scan_devices can work without hid
       
       Diffstat:
         M lib/plugins.py                      |      23 ++++++++++++++---------
       
       1 file changed, 14 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/lib/plugins.py b/lib/plugins.py
       t@@ -506,17 +506,15 @@ class DeviceMgr(ThreadJob, PrintError):
                    handler.win.wallet.save_keystore()
                return info
        
       -    def scan_devices(self):
       -        # All currently supported hardware libraries use hid, so we
       -        # assume it here.  This can be easily abstracted if necessary.
       -        # Note this import must be local so those without hardware
       -        # wallet libraries are not affected.
       -        import hid
       -        self.print_error("scanning devices...")
       +    def _scan_devices_with_hid(self):
       +        try:
       +            import hid
       +        except ImportError:
       +            return []
       +
                with self.hid_lock:
                    hid_list = hid.enumerate(0, 0)
        
       -        # First see what's connected that we know about
                devices = []
                for d in hid_list:
                    product_key = (d['vendor_id'], d['product_id'])
       t@@ -530,6 +528,13 @@ class DeviceMgr(ThreadJob, PrintError):
                        id_ += str(interface_number) + str(usage_page)
                        devices.append(Device(d['path'], interface_number,
                                              id_, product_key, usage_page))
       +        return devices
       +
       +    def scan_devices(self):
       +        self.print_error("scanning devices...")
       +
       +        # First see what's connected that we know about
       +        devices = self._scan_devices_with_hid()
        
                # Let plugin handlers enumerate devices we don't know about
                for f in self.enumerate_func:
       t@@ -541,7 +546,7 @@ class DeviceMgr(ThreadJob, PrintError):
                    else:
                        devices.extend(new_devices)
        
       -        # Now find out what was disconnected
       +        # find out what was disconnected
                pairs = [(dev.path, dev.id_) for dev in devices]
                disconnected_ids = []
                with self.lock: