Merge pull request #33 from timgunter/with_context

Added support for context management
This commit is contained in:
Kevin Hester authored and GitHub committed 2020-10-28 18:40:52 -07:00
commit 7ac8ab1a0f
1 file changed
+10
+10
View File
@@ -105,6 +105,16 @@ class MeshInterface:
if not noProto:
self._startConfig()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
if exc_type is not None and exc_value is not None:
logging.error(f'An exception of type {exc_type} with value {exc_value} has occurred')
if traceback is not None:
logging.error(f'Traceback: {traceback}')
self.close()
def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False, wantResponse=False):
"""Send a utf8 string to some other node, if the node has a display it will also be shown on the device.