1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-02 03:20:59 +00:00

make device tests work without hid

This commit is contained in:
Pavol Rusnak 2017-04-25 16:37:27 +02:00
parent 9c744a1c3d
commit 4999056678
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -21,9 +21,25 @@ from __future__ import print_function
import sys import sys
sys.path = ['../../'] + sys.path sys.path = ['../../'] + sys.path
from trezorlib.transport_pipe import PipeTransport
try:
from trezorlib.transport_hid import HidTransport from trezorlib.transport_hid import HidTransport
HID_ENABLED = True
except:
HID_ENABLED = False
try:
from trezorlib.transport_pipe import PipeTransport
PIPE_ENABLED = True
except:
PIPE_ENABLED = False
try:
from trezorlib.transport_udp import UdpTransport from trezorlib.transport_udp import UdpTransport
UDP_ENABLED = True
except:
UDP_ENABLED = False
def pipe_exists(path): def pipe_exists(path):
import os import os
@ -33,8 +49,9 @@ def pipe_exists(path):
except: except:
return False return False
devices = HidTransport.enumerate() if HID_ENABLED:
devices = HidTransport.enumerate()
if len(devices) > 0: if len(devices) > 0:
print('Using TREZOR') print('Using TREZOR')
TRANSPORT = HidTransport TRANSPORT = HidTransport
@ -44,7 +61,9 @@ if len(devices) > 0:
DEBUG_TRANSPORT_ARGS = (devices[0],) DEBUG_TRANSPORT_ARGS = (devices[0],)
DEBUG_TRANSPORT_KWARGS = {'debug_link': True} DEBUG_TRANSPORT_KWARGS = {'debug_link': True}
elif pipe_exists('/tmp/pipe.trezor.to'): elif PIPE_ENABLED:
if pipe_exists('/tmp/pipe.trezor.to'):
print('Using Emulator (v1=pipe)') print('Using Emulator (v1=pipe)')
TRANSPORT = PipeTransport TRANSPORT = PipeTransport
TRANSPORT_ARGS = ('/tmp/pipe.trezor', False) TRANSPORT_ARGS = ('/tmp/pipe.trezor', False)
@ -53,7 +72,8 @@ elif pipe_exists('/tmp/pipe.trezor.to'):
DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False) DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False)
DEBUG_TRANSPORT_KWARGS = {} DEBUG_TRANSPORT_KWARGS = {}
elif True: elif UDP_ENABLED:
print('Using Emulator (v2=udp)') print('Using Emulator (v2=udp)')
TRANSPORT = UdpTransport TRANSPORT = UdpTransport
TRANSPORT_ARGS = ('', ) TRANSPORT_ARGS = ('', )