Sprtch / victoria

🖨️ Printer daemon interface for Zebra printer
GNU General Public License v3.0
0 stars 0 forks source link

More verification from the incoming data from the redis channels #4

Closed tperale closed 3 years ago

tperale commented 4 years ago

Use some kind of "modeling" of the incoming data. The type of message has to be detected. So far only the print messages transmission is supported but we could imagine in the future message formatted to change the settings of the printer to support different type of printing size.

tperale commented 3 years ago

Progress toward verification is in work in progress with the help of the shared library sprtch/despinassy. A shared structure between the application is used:

IpcPrintMessage = namedtuple('PrintMessage', 'barcode, origin, name, number', defaults=(None, None, '', 1))

Each message passed through redis is in 'json' format and is converted to PrintMessage in the following way:

try:
    info = json.loads(content)
except json.decoder.JSONDecodeError as e:
    self.error("Failed to decode json data from redis: %s" % e)
    return
try:
    self.handle_print_msg(ipc_create_print_message(info))
except TypeError as e:
    self.error("Invalid message format: %s" % e)