fix(label): Socket sending

This commit is contained in:
Andreas Mieke 2024-04-18 01:04:11 -04:00
parent 77864ba979
commit a732fb3d4a
Signed by: zenermerps
SSH key fingerprint: SHA256:Ne+hwc5QIgYlqCuLZ0LV3301Wo/p8UoGOrGC+T6S0t8

View file

@ -66,12 +66,14 @@ class PhomemoLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
'ppk': key
}
data = json.dumps(fields)
# Send the label to the printer
try:
print_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print_socket.settimeout(5)
print_socket.connect((ip_address, port))
json.dump(fields, print_socket)
print_socket.sendall(bytes(data,encoding="utf-8"))
print_socket.close()
except Exception as error:
raise ConnectionError('Error connecting to printer server: ' + str(error))