tools: update to new transport api

This commit is contained in:
Jan Pochyla 2017-09-04 13:36:31 +02:00
parent 8202971109
commit 259a61878b
7 changed files with 13 additions and 16 deletions

View File

@ -41,7 +41,7 @@ def choose_device(devices):
if len(devices) == 1:
try:
return HidTransport(devices[0])
return devices[0]
except IOError:
raise Exception("Device is currently in use")
@ -50,18 +50,16 @@ def choose_device(devices):
sys.stderr.write("Available devices:\n")
for d in devices:
try:
t = HidTransport(d)
client = TrezorClient(d)
except IOError:
sys.stderr.write("[-] <device is currently in use>\n")
continue
client = TrezorClient(t)
if client.features.label:
sys.stderr.write("[%d] %s\n" % (i, client.features.label))
else:
sys.stderr.write("[%d] <no label>\n" % i)
t.close()
client.close()
i += 1
sys.stderr.write("----------------------------\n")
@ -69,7 +67,7 @@ def choose_device(devices):
try:
device_id = int(input())
return HidTransport(devices[device_id])
return devices[device_id]
except:
raise Exception("Invalid choice, exiting...")

View File

@ -15,7 +15,7 @@ def main():
return
# Use first connected device
transport = HidTransport(devices[0])
transport = devices[0]
# Creates object for manipulating TREZOR
client = TrezorClient(transport)

View File

@ -25,10 +25,10 @@ def main():
return
# Use first connected device
transport = HidTransport(devices[0])
transport = devices[0]
debug_transport = devices[0].find_debug()
# Creates object for manipulating TREZOR
debug_transport = HidTransport(devices[0], **{'debug_link': True})
client = TrezorClient(transport)
debug = DebugLink(debug_transport)

View File

@ -18,10 +18,10 @@ def main():
return
# Use first connected device
transport = HidTransport(devices[0])
transport = devices[0]
debug_transport = devices[0].find_debug()
# Creates object for manipulating TREZOR
debug_transport = HidTransport(devices[0], **{'debug_link': True})
client = TrezorClient(transport)
debug = DebugLink(debug_transport)

View File

@ -15,7 +15,7 @@ def get_client():
devices = HidTransport.enumerate() # list all connected TREZORs on USB
if len(devices) == 0: # check whether we found any
return None
transport = HidTransport(devices[0]) # use first connected device
transport = devices[0] # use first connected device
return TrezorClient(transport) # creates object for communicating with TREZOR

View File

@ -161,9 +161,8 @@ def main():
return
# Use first connected device
print(devices[0][0])
# transport = BridgeTransport(devices[0][0])
transport = HidTransport(devices[0])
transport = devices[0]
print(transport)
txstore = MyTxApiBitcoin()

View File

@ -34,7 +34,7 @@ def get_client():
devices = HidTransport.enumerate() # list all connected TREZORs on USB
if len(devices) == 0: # check whether we found any
return None
transport = HidTransport(devices[0]) # use first connected device
transport = devices[0] # use first connected device
return TrezorClient(transport) # creates object for communicating with TREZOR