1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 23:08:14 +00:00
trezor-firmware/tests/device_tests/config.py

64 lines
2.0 KiB
Python
Raw Normal View History

2017-01-03 18:40:05 +00:00
# This file is part of the TREZOR project.
#
# Copyright (C) 2012-2016 Marek Palatinus <slush@satoshilabs.com>
# Copyright (C) 2012-2016 Pavol Rusnak <stick@satoshilabs.com>
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
2016-05-20 20:27:20 +00:00
from __future__ import print_function
2012-11-15 20:05:57 +00:00
import sys
sys.path = ['../../'] + sys.path
2012-11-15 20:05:57 +00:00
2013-09-13 03:28:56 +00:00
from trezorlib.transport_pipe import PipeTransport
from trezorlib.transport_hid import HidTransport
2016-11-11 17:57:59 +00:00
from trezorlib.transport_udp import UdpTransport
def pipe_exists(path):
import os
try:
os.stat(path)
return True
except:
return False
2012-11-15 20:05:57 +00:00
2014-02-08 16:53:32 +00:00
devices = HidTransport.enumerate()
if len(devices) > 0:
2016-11-11 17:42:02 +00:00
print('Using TREZOR')
TRANSPORT = HidTransport
TRANSPORT_ARGS = (devices[0],)
TRANSPORT_KWARGS = {'debug_link': False}
DEBUG_TRANSPORT = HidTransport
DEBUG_TRANSPORT_ARGS = (devices[0],)
DEBUG_TRANSPORT_KWARGS = {'debug_link': True}
2016-11-11 17:57:59 +00:00
elif pipe_exists('/tmp/pipe.trezor.to'):
print('Using Emulator (v1=pipe)')
2013-10-08 18:34:38 +00:00
TRANSPORT = PipeTransport
TRANSPORT_ARGS = ('/tmp/pipe.trezor', False)
2014-01-20 12:21:49 +00:00
TRANSPORT_KWARGS = {}
2013-10-08 18:34:38 +00:00
DEBUG_TRANSPORT = PipeTransport
DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False)
2014-01-20 12:21:49 +00:00
DEBUG_TRANSPORT_KWARGS = {}
2016-11-11 17:57:59 +00:00
elif True:
print('Using Emulator (v2=udp)')
TRANSPORT = UdpTransport
2016-11-12 14:06:32 +00:00
TRANSPORT_ARGS = ('', )
2016-11-11 17:57:59 +00:00
TRANSPORT_KWARGS = {}
2016-11-14 17:54:02 +00:00
DEBUG_TRANSPORT = UdpTransport
DEBUG_TRANSPORT_ARGS = ('', )
DEBUG_TRANSPORT_KWARGS = {}