|
|
@ -66,9 +66,11 @@ class InhumanResources(Bureau):
|
|
|
|
cmdname = data["cmdname"]
|
|
|
|
cmdname = data["cmdname"]
|
|
|
|
desc = data["desc"]
|
|
|
|
desc = data["desc"]
|
|
|
|
cmd_code = prefix + cmd + "."
|
|
|
|
cmd_code = prefix + cmd + "."
|
|
|
|
barcode_png = os.path.join(self.datadir, cmd_code + "png")
|
|
|
|
|
|
|
|
#bc = barcode.generate("code128", prefix + cmd + ".", writer=barcode.writer.ImageWriter(), output=barcode_png)
|
|
|
|
#bc = barcode.generate("code128", prefix + cmd + ".", writer=barcode.writer.ImageWriter(), output=barcode_png)
|
|
|
|
bc = kode256.image(cmd_code).save(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 = '<img src="%s" />' % encoded_data
|
|
|
|
except KeyError as e:
|
|
|
|
except KeyError as e:
|
|
|
|
print("cannot add invalid command:", str(e))
|
|
|
|
print("cannot add invalid command:", str(e))
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -79,8 +81,7 @@ class InhumanResources(Bureau):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.menu[prefix]["commands"][cmd] = {"name": cmdname,
|
|
|
|
self.menu[prefix]["commands"][cmd] = {"name": cmdname,
|
|
|
|
"desc": desc,
|
|
|
|
"desc": desc,
|
|
|
|
"barcode": bc,
|
|
|
|
"barcode": bc }
|
|
|
|
"barcode_png": barcode_png}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_api("addapi", "Register API Method")
|
|
|
|
@add_api("addapi", "Register API Method")
|
|
|
|
def add_api_method(self, data):
|
|
|
|
def add_api_method(self, data):
|
|
|
|