1
0
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:
slush 2018-02-06 18:40:07 +01:00
parent d45cba1ddb
commit 6a22cf481c
3 changed files with 4 additions and 7 deletions

View File

@ -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'')

View File

@ -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):

View File

@ -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: