diff --git a/trezorlib/transport_bridge.py b/trezorlib/transport_bridge.py index cb5ff4121f..64276d0d92 100644 --- a/trezorlib/transport_bridge.py +++ b/trezorlib/transport_bridge.py @@ -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 diff --git a/trezorlib/transport_hid.py b/trezorlib/transport_hid.py index 712685360a..79da1e5cd8 100644 --- a/trezorlib/transport_hid.py +++ b/trezorlib/transport_hid.py @@ -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') diff --git a/trezorlib/transport_udp.py b/trezorlib/transport_udp.py index 05037d72ed..490aba5eca 100644 --- a/trezorlib/transport_udp.py +++ b/trezorlib/transport_udp.py @@ -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):