mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
Fix handling of find_by_path in transports.
This commit is contained in:
parent
d45cba1ddb
commit
6a22cf481c
@ -97,7 +97,7 @@ class HidTransport(Transport):
|
||||
return devices
|
||||
|
||||
@classmethod
|
||||
def find_by_path(cls, path=None):
|
||||
def find_by_path(cls, path):
|
||||
if isinstance(path, str):
|
||||
path = path.encode()
|
||||
path = path.replace(b'%s:' % cls.PATH_PREFIX.encode(), b'')
|
||||
|
@ -69,11 +69,8 @@ class UdpTransport(Transport):
|
||||
return devices
|
||||
|
||||
@classmethod
|
||||
def find_by_path(cls, path=None):
|
||||
if isinstance(path, str):
|
||||
path = path.encode()
|
||||
|
||||
path = path.replace(b'%s:' % cls.PATH_PREFIX.encode(), b'')
|
||||
def find_by_path(cls, path):
|
||||
path = path.replace('%s:' % cls.PATH_PREFIX, '')
|
||||
return UdpTransport(path)
|
||||
|
||||
def open(self):
|
||||
|
@ -106,7 +106,7 @@ class WebUsbTransport(Transport):
|
||||
return devices
|
||||
|
||||
@classmethod
|
||||
def find_by_path(cls, path=None):
|
||||
def find_by_path(cls, path):
|
||||
path = path.replace('%s:' % cls.PATH_PREFIX, '') # Remove prefix from __str__()
|
||||
for transport in WebUsbTransport.enumerate():
|
||||
if path is None or dev_to_str(transport.device) == path:
|
||||
|
Loading…
Reference in New Issue
Block a user