mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-31 18:40:56 +00:00
Fix handling of bytes/str in transport paths
This commit is contained in:
parent
29ad78d57b
commit
81db1da68f
@ -66,7 +66,10 @@ class BridgeTransport(Transport):
|
||||
|
||||
@classmethod
|
||||
def find_by_path(cls, path):
|
||||
if isinstance(path, bytes):
|
||||
path = path.decode()
|
||||
path = path.replace('%s:' % cls.PATH_PREFIX, '')
|
||||
|
||||
for transport in BridgeTransport.enumerate():
|
||||
if path is None or transport.device['path'] == path:
|
||||
return transport
|
||||
|
@ -98,8 +98,12 @@ class HidTransport(Transport):
|
||||
|
||||
@classmethod
|
||||
def find_by_path(cls, path=None):
|
||||
path = path.replace('%s:' % cls.PATH_PREFIX, '').encode() # Remove prefix from __str__()
|
||||
if isinstance(path, str):
|
||||
path = path.encode()
|
||||
path = path.replace(b'%s:' % cls.PATH_PREFIX.encode(), b'')
|
||||
|
||||
for transport in HidTransport.enumerate():
|
||||
print(path, transport.device['path'])
|
||||
if path is None or transport.device['path'] == path:
|
||||
return transport
|
||||
raise TransportException('HID device not found')
|
||||
|
@ -70,7 +70,10 @@ class UdpTransport(Transport):
|
||||
|
||||
@classmethod
|
||||
def find_by_path(cls, path=None):
|
||||
path = path.replace('%s:' % cls.PATH_PREFIX , '') # Remove prefix from __str__()
|
||||
if isinstance(path, str):
|
||||
path = path.encode()
|
||||
|
||||
path = path.replace(b'%s:' % cls.PATH_PREFIX.encode(), b'')
|
||||
return UdpTransport(path)
|
||||
|
||||
def open(self):
|
||||
|
Loading…
Reference in New Issue
Block a user