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

Refactored choosing of devices

This commit is contained in:
slush0 2014-06-12 19:16:30 +02:00
parent 461380e9d2
commit 430362bd31

View File

@ -27,7 +27,7 @@ def wait_for_devices():
return devices
def list_devices(devices):
def choose_device(devices):
i = 0
sys.stderr.write("----------------------------\n")
sys.stderr.write("Available devices:\n")
@ -52,23 +52,21 @@ def list_devices(devices):
try:
device_id = int(raw_input())
t = HidTransport(devices[device_id])
t.close()
transport = HidTransport(devices[device_id])
except:
raise Exception("Invalid choice, exiting...")
return device_id
return transport
def main():
devices = wait_for_devices()
if len(devices) > 1:
device_id = list_devices(devices)
transport = choose_device(devices)
else:
device_id = 0
transport = HidTransport(devices[0])
transport = HidTransport(devices[device_id])
client = TrezorClient(transport)
rootdir = os.environ['encfs_root'] # Read "man encfs" for more