You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: trezorlib/transport.py
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -32,28 +32,47 @@ def _session_end(self):
32
32
pass
33
33
34
34
defready_to_read(self):
35
+
"""
36
+
Returns True if there is data to be read from the transport. Otherwise, False.
37
+
"""
35
38
raiseNotImplementedException("Not implemented")
36
39
37
40
defsession_begin(self):
41
+
"""
42
+
Apply a lock to the device in order to preform synchronous multistep "conversations" with the device. For example, before entering the transaction signing workflow, one begins a session. After the transaction is complete, the session may be ended.
43
+
"""
38
44
ifself.session_depth==0:
39
45
self._session_begin()
40
46
self.session_depth+=1
41
47
42
48
defsession_end(self):
49
+
"""
50
+
End a session. Se session_begin for an in depth description of TREZOR sessions.
51
+
"""
43
52
self.session_depth-=1
44
53
self.session_depth=max(0, self.session_depth)
45
54
ifself.session_depth==0:
46
55
self._session_end()
47
56
48
57
defclose(self):
58
+
"""
59
+
Close the connection to the physical device or file descriptor represented by the Transport.
60
+
"""
49
61
self._close()
50
62
51
63
defwrite(self, msg):
64
+
"""
65
+
Write mesage to tansport. msg should be a member of a valid `protobuf class <https://developers.google.com/protocol-buffers/docs/pythontutorial>`_ with a SerializeToString() method.
If there is data available to be read from the transport, reads the data and tries to parse it as a protobuf message. If the parsing succeeds, return a protobuf object.
74
+
Otherwise, returns None.
75
+
"""
57
76
ifnotself.ready_to_read():
58
77
returnNone
59
78
@@ -64,6 +83,9 @@ def read(self):
64
83
returnself._parse_message(data)
65
84
66
85
defread_blocking(self):
86
+
"""
87
+
Same as read, except blocks untill data is available to be read.
0 commit comments