mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-18 19:31:04 +00:00
Better exception handling
This commit is contained in:
parent
68d46cb2f9
commit
842720052a
@ -1,25 +1,28 @@
|
|||||||
import struct
|
import struct
|
||||||
import mapping
|
import mapping
|
||||||
|
|
||||||
|
class NotImplementedException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class Transport(object):
|
class Transport(object):
|
||||||
def __init__(self, device, *args, **kwargs):
|
def __init__(self, device, *args, **kwargs):
|
||||||
self.device = device
|
self.device = device
|
||||||
self._open()
|
self._open()
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
raise NotImplemented
|
raise NotImplementedException("Not implemented")
|
||||||
|
|
||||||
def _close(self):
|
def _close(self):
|
||||||
raise NotImplemented
|
raise NotImplementedException("Not implemented")
|
||||||
|
|
||||||
def _write(self, msg):
|
def _write(self, msg):
|
||||||
raise NotImplemented
|
raise NotImplementedException("Not implemented")
|
||||||
|
|
||||||
def _read(self):
|
def _read(self):
|
||||||
raise NotImplemented
|
raise NotImplementedException("Not implemented")
|
||||||
|
|
||||||
def ready_to_read(self):
|
def ready_to_read(self):
|
||||||
raise NotImplemented
|
raise NotImplementedException("Not implemented")
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._close()
|
self._close()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
|
# Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
|
||||||
|
|
||||||
from transport import Transport
|
from transport import Transport, NotImplementedException
|
||||||
|
|
||||||
class FakeTransport(Transport):
|
class FakeTransport(Transport):
|
||||||
def __init__(self, device, *args, **kwargs):
|
def __init__(self, device, *args, **kwargs):
|
||||||
@ -21,4 +21,4 @@ class FakeTransport(Transport):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _read(self):
|
def _read(self):
|
||||||
raise NotImplemented
|
raise NotImplementedException("Not implemented")
|
Loading…
Reference in New Issue
Block a user