|
|
|
@ -24,6 +24,7 @@ from . import TransportException
|
|
|
|
|
from .protocol import ProtocolBasedTransport, ProtocolV1
|
|
|
|
|
|
|
|
|
|
SOCKET_TIMEOUT = 10
|
|
|
|
|
TRY_PATH_TIMEOUT = 1
|
|
|
|
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
@ -59,15 +60,12 @@ class UdpTransport(ProtocolBasedTransport):
|
|
|
|
|
def _try_path(cls, path: str) -> "UdpTransport":
|
|
|
|
|
d = cls(path)
|
|
|
|
|
try:
|
|
|
|
|
d.open()
|
|
|
|
|
if d._ping():
|
|
|
|
|
return d
|
|
|
|
|
else:
|
|
|
|
|
raise TransportException(
|
|
|
|
|
"No Trezor device found at address {}".format(d.get_path())
|
|
|
|
|
)
|
|
|
|
|
finally:
|
|
|
|
|
d.close()
|
|
|
|
|
d.wait_until_ready(timeout=TRY_PATH_TIMEOUT)
|
|
|
|
|
return d
|
|
|
|
|
except Exception as e:
|
|
|
|
|
raise TransportException(
|
|
|
|
|
"No Trezor device found at address {}".format(d.get_path())
|
|
|
|
|
) from e
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def enumerate(cls) -> Iterable["UdpTransport"]:
|
|
|
|
|