encode string

This commit is contained in:
Simon Pirkelmann 2021-08-23 21:10:43 +02:00
parent 4307d54505
commit 79b9b69ef8

View File

@ -92,15 +92,15 @@ class DoorHandle:
if self.nfc_sock is not None: if self.nfc_sock is not None:
self.nfc_sock.send(b'rld\n') self.nfc_sock.send(b'rld\n')
def open_door(self, user=b''): def open_door(self, user=''):
if self.nfc_sock is not None: if self.nfc_sock is not None:
self.nfc_sock.send(b'open ' + user + b'\n') self.nfc_sock.send(b'open ' + user.encode() + b'\n')
else: else:
raise Exception("No connection to NFC socket. Cannot close door!") raise Exception("No connection to NFC socket. Cannot close door!")
def close_door(self, user=b''): def close_door(self, user=''):
if self.nfc_sock is not None: if self.nfc_sock is not None:
self.nfc_sock.send(b'close ' + user + b'\n') self.nfc_sock.send(b'close ' + user.encode() + b'\n')
else: else:
raise Exception("No connection to NFC socket. Cannot close door!") raise Exception("No connection to NFC socket. Cannot close door!")