1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 08:08:51 +00:00
trezor-firmware/trezorlib/transport
matejcik 69ef1f0acd transport: cleaner Transport list instantiation
Previously if an import of a dependent module (usb1, hid) failed, import
of the whole transport module would fail. This was resolved by catching
ImportErrors in the all_transports method.

This had two drawbacks:
- if something other than ImportError happened - e.g., libusb would
raise OSError if it couldn't find libusb.so - all_transports would crash
anyway
- at the same time, if a legitimately needed dependency
(typing_extensions) was missing, this would be masked by the ImportError
handling.

Instead, we unconditionally import the modules, and inside each one,
wrap dependencies in a try-except.

As an added benefit, it is now possible to disable a transport just by
setting SomeTransport.ENABLED = False
2018-11-26 15:30:42 +01:00
..
__init__.py transport: cleaner Transport list instantiation 2018-11-26 15:30:42 +01:00
bridge.py transport: cleaner Transport list instantiation 2018-11-26 15:30:42 +01:00
hid.py transport: cleaner Transport list instantiation 2018-11-26 15:30:42 +01:00
protocol.py trezorlib: reentrant session handling 2018-11-12 12:22:32 +01:00
udp.py transport: cleaner Transport list instantiation 2018-11-26 15:30:42 +01:00
webusb.py transport: cleaner Transport list instantiation 2018-11-26 15:30:42 +01:00