mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-30 10:08:18 +00:00
make device tests work without hid
This commit is contained in:
parent
9c744a1c3d
commit
4999056678
@ -21,9 +21,25 @@ from __future__ import print_function
|
||||
import sys
|
||||
sys.path = ['../../'] + sys.path
|
||||
|
||||
from trezorlib.transport_pipe import PipeTransport
|
||||
from trezorlib.transport_hid import HidTransport
|
||||
from trezorlib.transport_udp import UdpTransport
|
||||
|
||||
try:
|
||||
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
|
||||
UDP_ENABLED = True
|
||||
except:
|
||||
UDP_ENABLED = False
|
||||
|
||||
|
||||
def pipe_exists(path):
|
||||
import os
|
||||
@ -33,9 +49,10 @@ def pipe_exists(path):
|
||||
except:
|
||||
return False
|
||||
|
||||
devices = HidTransport.enumerate()
|
||||
if HID_ENABLED:
|
||||
|
||||
if len(devices) > 0:
|
||||
devices = HidTransport.enumerate()
|
||||
if len(devices) > 0:
|
||||
print('Using TREZOR')
|
||||
TRANSPORT = HidTransport
|
||||
TRANSPORT_ARGS = (devices[0],)
|
||||
@ -44,7 +61,9 @@ if len(devices) > 0:
|
||||
DEBUG_TRANSPORT_ARGS = (devices[0],)
|
||||
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)')
|
||||
TRANSPORT = PipeTransport
|
||||
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_KWARGS = {}
|
||||
|
||||
elif True:
|
||||
elif UDP_ENABLED:
|
||||
|
||||
print('Using Emulator (v2=udp)')
|
||||
TRANSPORT = UdpTransport
|
||||
TRANSPORT_ARGS = ('', )
|
||||
|
Loading…
Reference in New Issue
Block a user