1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 16:18:22 +00:00

Make examples working for all available transports.

This commit is contained in:
slush 2018-02-02 18:29:52 +01:00
parent a4cdae39af
commit 562a19c812
4 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function
'''
@ -16,7 +16,7 @@ import hashlib
import binascii
from trezorlib.client import TrezorClient
from trezorlib.transport_hid import HidTransport
from trezorlib.device import TrezorDevice
# Python2 vs Python3
try:
@ -26,11 +26,11 @@ except NameError:
def wait_for_devices():
devices = HidTransport.enumerate()
devices = TrezorDevice.enumerate()
while not len(devices):
sys.stderr.write("Please connect TREZOR to computer and press Enter...")
input()
devices = HidTransport.enumerate()
devices = TrezorDevice.enumerate()
return devices

View File

@ -1,13 +1,13 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function
from trezorlib.client import TrezorClient
from trezorlib.transport_hid import HidTransport
from trezorlib.device import TrezorDevice
def main():
# List all connected TREZORs on USB
devices = HidTransport.enumerate()
# List all connected TREZORs on USB/UDP
devices = TrezorDevice.enumerate()
# Check whether we found any
if len(devices) == 0:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function
import binascii
import hashlib

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# example usage: ./rng_entropy_collector.py stm32_rng_1.dat 1048576
# note: for reading large amounts of entropy, compile a firmware
# that has DEBUG_RNG == 1 as that will disable the user button
@ -8,11 +8,11 @@ from __future__ import print_function
import io
import sys
from trezorlib.client import TrezorClient
from trezorlib.transport_hid import HidTransport
from trezorlib.device import TrezorDevice
def get_client():
devices = HidTransport.enumerate() # list all connected TREZORs on USB
devices = TrezorDevice.enumerate() # list all connected TREZORs on USB
if len(devices) == 0: # check whether we found any
return None
transport = devices[0] # use first connected device
@ -30,7 +30,7 @@ def main():
step = 1024 if arg2 >= 1024 else arg2 # trezor will only return 1KB at a time
with io.open(arg1, 'wb') as f:
for i in xrange(0, arg2, step):
for i in range(0, arg2, step):
entropy = client.get_entropy(step)
f.write(entropy)