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:
parent
9c744a1c3d
commit
4999056678
@ -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
|
|
||||||
from trezorlib.transport_hid import HidTransport
|
try:
|
||||||
from trezorlib.transport_udp import UdpTransport
|
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):
|
def pipe_exists(path):
|
||||||
import os
|
import os
|
||||||
@ -33,9 +49,10 @@ def pipe_exists(path):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
devices = HidTransport.enumerate()
|
if HID_ENABLED:
|
||||||
|
|
||||||
if len(devices) > 0:
|
devices = HidTransport.enumerate()
|
||||||
|
if len(devices) > 0:
|
||||||
print('Using TREZOR')
|
print('Using TREZOR')
|
||||||
TRANSPORT = HidTransport
|
TRANSPORT = HidTransport
|
||||||
TRANSPORT_ARGS = (devices[0],)
|
TRANSPORT_ARGS = (devices[0],)
|
||||||
@ -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 = ('', )
|
||||||
|
Loading…
Reference in New Issue
Block a user