mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 02:48:18 +00:00
Make examples working for all available transports.
This commit is contained in:
parent
a4cdae39af
commit
562a19c812
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -16,7 +16,7 @@ import hashlib
|
|||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.device import TrezorDevice
|
||||||
|
|
||||||
# Python2 vs Python3
|
# Python2 vs Python3
|
||||||
try:
|
try:
|
||||||
@ -26,11 +26,11 @@ except NameError:
|
|||||||
|
|
||||||
|
|
||||||
def wait_for_devices():
|
def wait_for_devices():
|
||||||
devices = HidTransport.enumerate()
|
devices = TrezorDevice.enumerate()
|
||||||
while not len(devices):
|
while not len(devices):
|
||||||
sys.stderr.write("Please connect TREZOR to computer and press Enter...")
|
sys.stderr.write("Please connect TREZOR to computer and press Enter...")
|
||||||
input()
|
input()
|
||||||
devices = HidTransport.enumerate()
|
devices = TrezorDevice.enumerate()
|
||||||
|
|
||||||
return devices
|
return devices
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.device import TrezorDevice
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# List all connected TREZORs on USB
|
# List all connected TREZORs on USB/UDP
|
||||||
devices = HidTransport.enumerate()
|
devices = TrezorDevice.enumerate()
|
||||||
|
|
||||||
# Check whether we found any
|
# Check whether we found any
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import binascii
|
import binascii
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# example usage: ./rng_entropy_collector.py stm32_rng_1.dat 1048576
|
# example usage: ./rng_entropy_collector.py stm32_rng_1.dat 1048576
|
||||||
# note: for reading large amounts of entropy, compile a firmware
|
# note: for reading large amounts of entropy, compile a firmware
|
||||||
# that has DEBUG_RNG == 1 as that will disable the user button
|
# that has DEBUG_RNG == 1 as that will disable the user button
|
||||||
@ -8,11 +8,11 @@ from __future__ import print_function
|
|||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.device import TrezorDevice
|
||||||
|
|
||||||
|
|
||||||
def get_client():
|
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
|
if len(devices) == 0: # check whether we found any
|
||||||
return None
|
return None
|
||||||
transport = devices[0] # use first connected device
|
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
|
step = 1024 if arg2 >= 1024 else arg2 # trezor will only return 1KB at a time
|
||||||
|
|
||||||
with io.open(arg1, 'wb') as f:
|
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)
|
entropy = client.get_entropy(step)
|
||||||
f.write(entropy)
|
f.write(entropy)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user