mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-08 09:58:46 +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 time
|
||||||
import hid
|
import hid
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from ..protocol_v1 import ProtocolV1
|
from ..protocol_v1 import ProtocolV1
|
||||||
from ..protocol_v2 import ProtocolV2
|
from ..protocol_v2 import ProtocolV2
|
||||||
@ -39,7 +40,12 @@ class HidHandle:
|
|||||||
def open(self):
|
def open(self):
|
||||||
if self.count == 0:
|
if self.count == 0:
|
||||||
self.handle = hid.device()
|
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.handle.set_nonblocking(True)
|
||||||
self.count += 1
|
self.count += 1
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import time
|
|||||||
import os
|
import os
|
||||||
import atexit
|
import atexit
|
||||||
import usb1
|
import usb1
|
||||||
|
import sys
|
||||||
|
|
||||||
from ..protocol_v1 import ProtocolV1
|
from ..protocol_v1 import ProtocolV1
|
||||||
from ..protocol_v2 import ProtocolV2
|
from ..protocol_v2 import ProtocolV2
|
||||||
@ -46,7 +47,11 @@ class WebUsbHandle:
|
|||||||
if self.count == 0:
|
if self.count == 0:
|
||||||
self.handle = self.device.open()
|
self.handle = self.device.open()
|
||||||
if self.handle is None:
|
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.handle.claimInterface(interface)
|
||||||
self.count += 1
|
self.count += 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user