From a398bc044ee7383d2256aa2650866a00dd04006c Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Sun, 29 Nov 2020 00:19:44 +0100 Subject: [PATCH] add in_menu option to registering commands so that barcodes don't show up in the menu for parameterized methods. --- screenless/bureau/bureau.py | 13 +++++++++---- screenless/bureau/ihr/ihr.py | 12 ++++++++---- screenless/bureau/publications/publications.py | 4 ++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/screenless/bureau/bureau.py b/screenless/bureau/bureau.py index aceea79..5d41256 100644 --- a/screenless/bureau/bureau.py +++ b/screenless/bureau/bureau.py @@ -35,7 +35,7 @@ def update_commands(cls): return cls -def add_command(comstr, name=""): +def add_command(comstr, name="", in_menu=True): """ decorator for making a method into a command """ def decorator(func): """ the decorator itself """ @@ -45,6 +45,7 @@ def add_command(comstr, name=""): return func(*args, **kwargs) func_wrap.command = comstr func_wrap.name = name + func_wrap.in_menu = in_menu return func_wrap return decorator @@ -373,7 +374,8 @@ class Bureau(object): cmd_detail = {"cmdname": method.name, "prefix": self.prefix, "cmd": method.command, - "desc": method.__doc__} + "desc": method.__doc__, + "in_menu": method.in_menu} if self.prefix == "IR": method = getattr(self, "add_cmd") method(cmd_detail) @@ -411,12 +413,15 @@ class Bureau(object): returns an instance of the small escpos printer """ if (self.smprint["inep"] is None) and (self.smprint["outep"] is None): - prn = printer.Usb(self.smprint["vendorid"], self.smprint["productid"]) + prn = printer.Usb(self.smprint["vendorid"], + self.smprint["productid"], + profile=self.smprint["profile"]) else: prn = printer.Usb(self.smprint["vendorid"], self.smprint["productid"], in_ep=self.smprint["inep"], - out_ep=self.smprint["outep"]) + out_ep=self.smprint["outep"], + profile=self.smprint["profile"]) return prn diff --git a/screenless/bureau/ihr/ihr.py b/screenless/bureau/ihr/ihr.py index 0e96edc..2a593b5 100644 --- a/screenless/bureau/ihr/ihr.py +++ b/screenless/bureau/ihr/ihr.py @@ -75,11 +75,15 @@ class InhumanResources(Bureau): cmdname = data["cmdname"] desc = data["desc"] cmd_code = prefix + cmd + "." + in_menu = data["in_menu"] #bc = barcode.generate("code128", prefix + cmd + ".", writer=barcode.writer.ImageWriter(), output=barcode_png) - bc = kode256.svg(cmd_code) - encoded_svg = b64encode(bc.encode()).decode() - encoded_data = "data:image/svg+xml;charset=utf-8;base64," + encoded_svg - bc = '' % encoded_data + if in_menu: + bc = kode256.svg(cmd_code) + encoded_svg = b64encode(bc.encode()).decode() + encoded_data = "data:image/svg+xml;charset=utf-8;base64," + encoded_svg + bc = '' % encoded_data + else: + bc = "" except KeyError as e: print("cannot add invalid command:", str(e)) return diff --git a/screenless/bureau/publications/publications.py b/screenless/bureau/publications/publications.py index b5670db..9443ead 100644 --- a/screenless/bureau/publications/publications.py +++ b/screenless/bureau/publications/publications.py @@ -87,6 +87,10 @@ class Publications(Bureau): the document camera as the index page. Finally, it will print out the main page with commands for working with the site. """ + self.print_small("SORRY! the publication/site feature is not done yet. So this does nothing for now.") + return + #TODO: finish and test this stuff + site_dir = os.path.join(self.db, "1") site_id = 1 while os.path.exists(site_dir):