def print_test_page(printer_id, apikey): if apikey != cfg.api_key: abort(403, "Access Denied") p = printer.get_printer(printer_id, cfg) if p is None: abort(400, "Unknown printer " + printer_id) commands = [ {"command": "set", "align": "center", "type": "b", "width": 2, "height": 2}, {"command": "text", "text": "Printer Test"}, {"command": "set", "align": "center"}, {"command": "text", "text": " "}, {"command": "image", "path": "{0}/api/printer/logo/{1}/{2}".format(cfg.app_url, cfg.organization_id, ping_thing.key)}, {"command": "text", "text": " "}, {"command": "set", "align": "left"}, {"command": "text", "text": "Printer: {0}".format(p.config.get('name'))}, {"command": "text", "text": "Printer type: {0} {1}".format(p.config.get('manufacturer'), p.config.get('model'))}, {"command": "text", "text": "Printer serial #: {0}".format(p.config.get('serial'))}, {"command": "text", "text": " "}, {"command": "qr", "data": "Printer Test Data Encoded"}, {"command": "cut"} ] p.print_receipt(commands) return "done"
def print_something(printer_id, apikey): if apikey != cfg.api_key: abort(403, "Access Denied") p = printer.get_printer(printer_id, cfg) if p is None: abort(400, "Unknown printer " + printer_id) data = request.json try: p.print_receipt(data) return "success" except Exception as ex: return "failure " + str(ex)
def open_cash_box(printer_id, apikey): if apikey != cfg.api_key: abort(403, "Access Denied") p = printer.get_printer(printer_id, cfg) if p is None: abort(400, "Unknown printer " + printer_id) commands = [ {"command": "cashdraw", "pin": 2}, {"command": "reset"} ] p.print_receipt(commands) return "done"
def hello_printer(printer_id, api_key): if api_key != cfg.api_key: abort(403, "Access Denied") p = printer.get_printer(printer_id, cfg) if p is None: abort(400, "Unknown printer " + printer_id) commands = [ {"command": "text", "text": "Printer: %s" % p.config["name"]}, {"command": "cut"} ] p.print_receipt(commands) return "done"