diff --git a/trezorlib/transport/hid.py b/trezorlib/transport/hid.py index 3a6884ca..9a47354a 100644 --- a/trezorlib/transport/hid.py +++ b/trezorlib/transport/hid.py @@ -19,6 +19,7 @@ import time import hid import os +import sys from ..protocol_v1 import ProtocolV1 from ..protocol_v2 import ProtocolV2 @@ -39,7 +40,12 @@ def __init__(self, path): def open(self): if self.count == 0: self.handle = hid.device() - self.handle.open_path(self.path) + try: + self.handle.open_path(self.path) + except (IOError, OSError) as e: + if sys.platform.startswith('linux'): + e.args = e.args + ('Do you have udev rules installed? https://github.com/trezor/trezor-common/blob/master/udev/51-trezor.rules', ) + raise e self.handle.set_nonblocking(True) self.count += 1 diff --git a/trezorlib/transport/webusb.py b/trezorlib/transport/webusb.py index 44b5dafb..1e2cff25 100644 --- a/trezorlib/transport/webusb.py +++ b/trezorlib/transport/webusb.py @@ -46,7 +46,7 @@ def open(self, interface): if self.count == 0: self.handle = self.device.open() if self.handle is None: - raise Exception('Cannot open device') + raise IOError('Cannot open device', 'Do you have udev rules installed? https://github.com/trezor/trezor-common/blob/master/udev/51-trezor.rules') self.handle.claimInterface(interface) self.count += 1