mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 14:58:09 +00:00
Reworked get_transport for hid/bridge.
This commit is contained in:
parent
3b4f226d48
commit
39e827a90a
16
trezorctl
16
trezorctl
@ -65,15 +65,9 @@ def get_transport(transport_string, path, **kwargs):
|
||||
if transport_string == 'usb':
|
||||
from trezorlib.transport_hid import HidTransport
|
||||
|
||||
if path == '':
|
||||
try:
|
||||
path = list_usb()[0][0]
|
||||
except IndexError:
|
||||
raise Exception("No TREZOR found on USB")
|
||||
|
||||
for d in HidTransport.enumerate():
|
||||
# Two-tuple of (normal_interface, debug_interface)
|
||||
if path in d:
|
||||
if path == '' or path in d:
|
||||
return HidTransport(d, **kwargs)
|
||||
|
||||
raise Exception("Device not found")
|
||||
@ -88,7 +82,13 @@ def get_transport(transport_string, path, **kwargs):
|
||||
|
||||
if transport_string == 'bridge':
|
||||
from trezorlib.transport_bridge import BridgeTransport
|
||||
return BridgeTransport({'path': path}, **kwargs)
|
||||
|
||||
devices = BridgeTransport.enumerate()
|
||||
for d in devices:
|
||||
if path == '' or d['path'] == binascii.hexlify(path):
|
||||
return BridgeTransport(d, **kwargs)
|
||||
|
||||
raise Exception("Device not found")
|
||||
|
||||
raise NotImplementedError("Unknown transport")
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
import json
|
||||
import requests
|
||||
import binascii
|
||||
from . import protobuf_json
|
||||
from . import messages_pb2 as proto
|
||||
from .transport import TransportV1
|
||||
@ -17,7 +16,7 @@ class BridgeTransport(TransportV1):
|
||||
def __init__(self, device, *args, **kwargs):
|
||||
self.configure()
|
||||
|
||||
self.path = binascii.hexlify(device['path'])
|
||||
self.path = device['path']
|
||||
|
||||
self.session = None
|
||||
self.response = None
|
||||
|
Loading…
Reference in New Issue
Block a user