diff --git a/addons/hw_drivers/iot_handlers/drivers/PrinterDriver_L.py b/addons/hw_drivers/iot_handlers/drivers/PrinterDriver_L.py index 0ee38a68a03..c17b30c8e2a 100644 --- a/addons/hw_drivers/iot_handlers/drivers/PrinterDriver_L.py +++ b/addons/hw_drivers/iot_handlers/drivers/PrinterDriver_L.py @@ -164,6 +164,10 @@ class PrinterDriver(Driver): def print_raw(self, data): process = subprocess.Popen(["lp", "-d", self.device_identifier], stdin=subprocess.PIPE) process.communicate(data) + if process.returncode != 0: + # The stderr isn't meaningful so we don't log it ('No such file or directory') + _logger.error('Printing failed: printer with the identifier "%s" could not be found', + self.device_identifier) def print_receipt(self, data): receipt = b64decode(data['receipt']) diff --git a/addons/hw_drivers/iot_handlers/interfaces/PrinterInterface_L.py b/addons/hw_drivers/iot_handlers/interfaces/PrinterInterface_L.py index 4484f0d0c24..994a2d3d5cd 100644 --- a/addons/hw_drivers/iot_handlers/interfaces/PrinterInterface_L.py +++ b/addons/hw_drivers/iot_handlers/interfaces/PrinterInterface_L.py @@ -51,10 +51,11 @@ class PrinterInterface(Interface): return dict(self.printer_devices) def get_identifier(self, path): + allowed_characters = '[^a-zA-Z0-9_-]' if 'uuid=' in path: - identifier = sub('[^a-zA-Z0-9_]', '', path.split('uuid=')[1]) + identifier = sub(allowed_characters, '', path.split('uuid=')[1]) elif 'serial=' in path: - identifier = sub('[^a-zA-Z0-9_]', '', path.split('serial=')[1]) + identifier = sub(allowed_characters, '', path.split('serial=')[1]) else: - identifier = sub('[^a-zA-Z0-9_]', '', path) + identifier = sub(allowed_characters, '', path) return identifier