From a732fb3d4a09476579a6cd2d2ef0328ce88ece0c Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Thu, 18 Apr 2024 01:04:11 -0400 Subject: [PATCH] fix(label): Socket sending --- inventree_phomemo/phomemo_label.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inventree_phomemo/phomemo_label.py b/inventree_phomemo/phomemo_label.py index 5b2141b..456948e 100644 --- a/inventree_phomemo/phomemo_label.py +++ b/inventree_phomemo/phomemo_label.py @@ -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))