mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 17:42:02 +00:00
transport: inject info about udev rules into io/os exception
This commit is contained in:
parent
7c08800cb9
commit
12c58ce3cc
@ -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 @@ class HidHandle:
|
||||
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
|
||||
|
||||
|
@ -20,6 +20,7 @@ import time
|
||||
import os
|
||||
import atexit
|
||||
import usb1
|
||||
import sys
|
||||
|
||||
from ..protocol_v1 import ProtocolV1
|
||||
from ..protocol_v2 import ProtocolV2
|
||||
@ -46,7 +47,11 @@ class WebUsbHandle:
|
||||
if self.count == 0:
|
||||
self.handle = self.device.open()
|
||||
if self.handle is None:
|
||||
raise Exception('Cannot open device')
|
||||
if sys.platform.startswith('linux'):
|
||||
args = ('Do you have udev rules installed? https://github.com/trezor/trezor-common/blob/master/udev/51-trezor.rules', )
|
||||
else:
|
||||
args = ()
|
||||
raise IOError('Cannot open device', *args)
|
||||
self.handle.claimInterface(interface)
|
||||
self.count += 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user