diff options
| author | Antoine Prieels <anp@odoo.com> | 2019-03-18 10:15:19 +0000 |
|---|---|---|
| committer | Antoine Prieels <anp@odoo.com> | 2019-08-08 11:53:37 +0000 |
| commit | 03b2f7b77dc6189bb485e0b834dba5f6d3d4da2c (patch) | |
| tree | 46df5c8eff19ae44692af874dfd136f6cd1ad519 /addons/hw_drivers/controllers/driver.py | |
| parent | dd7de1bcb65d339e5865afcc980cbb4d171fbb74 (diff) | |
[REF] pos: Replace hw_escpos by PrinterDriver
ESCPOS printers are now supported as IoT Devices, just like any other
printer. We now transform the receipts to JPGs, transform these JPGs
into ESCPOS commands and send them via Cups, adding support for network
printers. Since we now print images, we can now print special
characters and therefore add support for other languages such as
Arabic.
The JPG is generated in the browser, with the help of html2canvas.
`hw_escpos` is left untouched to allow backward compatibility and
should be removed when v12 is no longer supported.
In the PoS, all the code for printing has been moved from ProxyDevice
to a separated JS file.
TaskID: 1939455
Diffstat (limited to 'addons/hw_drivers/controllers/driver.py')
| -rwxr-xr-x | addons/hw_drivers/controllers/driver.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/hw_drivers/controllers/driver.py b/addons/hw_drivers/controllers/driver.py index 9a6764b7b23..0bd0286c3d5 100755 --- a/addons/hw_drivers/controllers/driver.py +++ b/addons/hw_drivers/controllers/driver.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 import logging import time -from threading import Thread, Event +from threading import Thread, Event, Lock from usb import core from gatt import DeviceManager as Gatt_DeviceManager import subprocess @@ -353,7 +353,8 @@ class Manager(Thread): def printer_loop(self): printer_devices = {} - devices = conn.getDevices() + with cups_lock: + devices = conn.getDevices() for path in [printer_lo for printer_lo in devices if devices[printer_lo]['device-make-and-model'] != 'Unknown']: if 'uuid=' in path: serial = sub('[^a-zA-Z0-9 ]+', '', path.split('uuid=')[1]) @@ -443,6 +444,7 @@ class SocketManager(Thread): conn = cups_connection() PPDs = conn.getPPDs() printers = conn.getPrinters() +cups_lock = Lock() # We can only make one call to Cups at a time m = Manager() m.daemon = True |
