fixed barcode generators

workspace
Brendan Howell 5 years ago
parent def8c6c16b
commit 2211378651

@ -74,7 +74,7 @@ class InhumanResources(Bureau):
cmd_code = prefix + cmd + "." cmd_code = prefix + cmd + "."
# barcode = clean_svg(code128.svg(prefix + cmd + ".")) # barcode = clean_svg(code128.svg(prefix + cmd + "."))
barcode_png = os.path.join(self.datadir, cmd_code) barcode_png = os.path.join(self.datadir, cmd_code)
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)
except KeyError as e: except KeyError as e:
print("cannot add invalid command:", str(e)) print("cannot add invalid command:", str(e))
return return

@ -171,22 +171,22 @@ class MailRoom(Bureau):
# make action barcodes # make action barcodes
msg.un_bc = os.path.join("/tmp", "POun." + shortcode + ".png") msg.un_bc = os.path.join("/tmp", "POun." + shortcode + ".png")
barcode.generate("code128", "POun." + shortcode, barcode.generate("code128", "POun." + shortcode,
writer=barcode.writer.ImageWriter, output=msg.un_bc) writer=barcode.writer.ImageWriter(), output=msg.un_bc)
msg.d_bc = os.path.join("/tmp", "POd." + shortcode + ".png") msg.d_bc = os.path.join("/tmp", "POd." + shortcode + ".png")
barcode.generate("code128", "POd." + shortcode, barcode.generate("code128", "POd." + shortcode,
writer=barcode.writer.ImageWriter, output=msg.d_bc) writer=barcode.writer.ImageWriter(), output=msg.d_bc)
msg.sp_bc = os.path.join("/tmp", "POsp." + shortcode + ".png") msg.sp_bc = os.path.join("/tmp", "POsp." + shortcode + ".png")
barcode.generate("code128", "POsp." + shortcode, barcode.generate("code128", "POsp." + shortcode,
writer=barcode.writer.ImageWriter, output=msg.sp_bc) writer=barcode.writer.ImageWriter(), output=msg.sp_bc)
msg.re_bc = os.path.join("/tmp", "POre." + shortcode + ".png") msg.re_bc = os.path.join("/tmp", "POre." + shortcode + ".png")
barcode.generate("code128", "POre." + shortcode, barcode.generate("code128", "POre." + shortcode,
writer=barcode.writer.ImageWriter, output=msg.re_bc) writer=barcode.writer.ImageWriter(), output=msg.re_bc)
msg.rea_bc = os.path.join("/tmp", "POrea." + shortcode + ".png") msg.rea_bc = os.path.join("/tmp", "POrea." + shortcode + ".png")
barcode.generate("code128", "POrea." + shortcode, barcode.generate("code128", "POrea." + shortcode,
writer=barcode.writer.ImageWriter, output=msg.rea_bc) writer=barcode.writer.ImageWriter(), output=msg.rea_bc)
msg.r_bc = os.path.join("/tmp", "POr." + shortcode + ".png") msg.r_bc = os.path.join("/tmp", "POr." + shortcode + ".png")
barcode.generate("code128", "POr." + shortcode, barcode.generate("code128", "POr." + shortcode,
writer=barcode.writer.ImageWriter, output=msg.r_bc) writer=barcode.writer.ImageWriter(), output=msg.r_bc)
self.print_full("email.html", msg=msg, shortcode=shortcode) self.print_full("email.html", msg=msg, shortcode=shortcode)

@ -276,7 +276,7 @@ class Publications(Bureau):
entry.source = feed.feed.title entry.source = feed.feed.title
entry.dbhash = self._make_shorturl(entry.link) entry.dbhash = self._make_shorturl(entry.link)
entry.svg = barcode.get("CODE128", "PBr." + tmpcode).raw entry.svg = barcode.get("CODE128", "PBr." + entry.dbhash).raw
encoded_svg = b64encode(entry.svg).decode() encoded_svg = b64encode(entry.svg).decode()
encoded_data = "data:image/svg+xml;charset=utf-8;base64," + encoded_svg encoded_data = "data:image/svg+xml;charset=utf-8;base64," + encoded_svg
entry.svg = '<img src="%s"/>' % encoded_data entry.svg = '<img src="%s"/>' % encoded_data

Loading…
Cancel
Save