remove old code128 deps

workspace
Brendan Howell 5 years ago
parent 73d056561f
commit def8c6c16b

@ -1,6 +1,5 @@
appdirs==1.4.0 appdirs==1.4.0
argcomplete==1.6.0 argcomplete==1.6.0
git+git://gitlab.com/bhowell/bc128.git#egg=bc128
backports.ssl==0.0.9 backports.ssl==0.0.9
cffi==1.9.1 cffi==1.9.1
chardet==2.3.0 chardet==2.3.0

@ -4,7 +4,7 @@ import signal
import socket import socket
import subprocess import subprocess
import code128 import barcode
from lxml import etree from lxml import etree
from bureau import Bureau, add_command, add_api from bureau import Bureau, add_command, add_api
@ -72,10 +72,9 @@ class InhumanResources(Bureau):
cmdname = data["cmdname"] cmdname = data["cmdname"]
desc = data["desc"] desc = data["desc"]
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 + "png") barcode_png = os.path.join(self.datadir, cmd_code)
code128.image(cmd_code).save(barcode_png) bc = barcode.generate("code128", prefix + cmd + ".", writer=barcode.writer.ImageWriter, output=barcode_png)
barcode_png = str(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
@ -86,7 +85,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": barcode, "barcode": bc,
"barcode_png": barcode_png} "barcode_png": barcode_png}
@add_api("addapi", "Register API Method") @add_api("addapi", "Register API Method")

@ -9,7 +9,7 @@ import random
import smtplib import smtplib
import string import string
import code128 import barcode
import imapclient import imapclient
from bureau import Bureau, add_command, add_api from bureau import Bureau, add_command, add_api
@ -169,24 +169,24 @@ class MailRoom(Bureau):
# TODO: switch this to inline svgs # TODO: switch this to inline svgs
# make action barcodes # make action barcodes
barcode_png = os.path.join("/tmp", "POun." + shortcode + ".png") msg.un_bc = os.path.join("/tmp", "POun." + shortcode + ".png")
code128.image("POun." + shortcode).save(barcode_png) barcode.generate("code128", "POun." + shortcode,
msg.un_bc = str(barcode_png) writer=barcode.writer.ImageWriter, output=msg.un_bc)
barcode_png = os.path.join("/tmp", "POd." + shortcode + ".png") msg.d_bc = os.path.join("/tmp", "POd." + shortcode + ".png")
code128.image("POd." + shortcode).save(barcode_png) barcode.generate("code128", "POd." + shortcode,
msg.d_bc = str(barcode_png) writer=barcode.writer.ImageWriter, output=msg.d_bc)
barcode_png = os.path.join("/tmp", "POsp." + shortcode + ".png") msg.sp_bc = os.path.join("/tmp", "POsp." + shortcode + ".png")
code128.image("POsp." + shortcode).save(barcode_png) barcode.generate("code128", "POsp." + shortcode,
msg.sp_bc = str(barcode_png) writer=barcode.writer.ImageWriter, output=msg.sp_bc)
barcode_png = os.path.join("/tmp", "POre." + shortcode + ".png") msg.re_bc = os.path.join("/tmp", "POre." + shortcode + ".png")
code128.image("POre." + shortcode).save(barcode_png) barcode.generate("code128", "POre." + shortcode,
msg.re_bc = str(barcode_png) writer=barcode.writer.ImageWriter, output=msg.re_bc)
barcode_png = os.path.join("/tmp", "POrea." + shortcode + ".png") msg.rea_bc = os.path.join("/tmp", "POrea." + shortcode + ".png")
code128.image("POrea." + shortcode).save(barcode_png) barcode.generate("code128", "POrea." + shortcode,
msg.rea_bc = str(barcode_png) writer=barcode.writer.ImageWriter, output=msg.rea_bc)
barcode_png = os.path.join("/tmp", "POr." + shortcode + ".png") msg.r_bc = os.path.join("/tmp", "POr." + shortcode + ".png")
code128.image("POr." + shortcode).save(barcode_png) barcode.generate("code128", "POr." + shortcode,
msg.r_bc = str(barcode_png) 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)
@ -313,9 +313,9 @@ class MailRoom(Bureau):
msg.subject = clean_header(envelope.subject.decode("utf-8")) msg.subject = clean_header(envelope.subject.decode("utf-8"))
# make action barcodes # make action barcodes
msg.d_bc = code128.svg("POd." + shortcode) msg.d_bc = str(barcode.get("code128", "POd." + shortcode).raw)
msg.sp_bc = code128.svg("POsp." + shortcode) msg.sp_bc = str(barcode.get("code128", "POsp." + shortcode).raw)
msg.r_bc = code128.svg("POr." + shortcode) msg.r_bc = str(barcode.get("code128", "POr." + shortcode).raw)
msgs.append(msg.__dict__) msgs.append(msg.__dict__)

@ -9,8 +9,8 @@ import string
import threading import threading
import urllib.request, urllib.parse, urllib.error import urllib.request, urllib.parse, urllib.error
import barcode
import bleach import bleach
import code128
import feedparser import feedparser
import lxml.html import lxml.html
import PIL import PIL
@ -165,7 +165,7 @@ class Publications(Bureau):
continue # skip bogus links continue # skip bogus links
tmpcode = self._make_shorturl(link.attrib["href"]) tmpcode = self._make_shorturl(link.attrib["href"])
svg = code128.svg("PBr." + tmpcode) svg = barcode.get("CODE128", "PBr." + tmpcode).raw
footnote = html.makeelement("div") footnote = html.makeelement("div")
footnote.attrib["class"] = "footnote" footnote.attrib["class"] = "footnote"
@ -173,7 +173,7 @@ class Publications(Bureau):
notetext.text = str(notecount) + ". " + link.attrib["href"] notetext.text = str(notecount) + ". " + link.attrib["href"]
footnote.append(notetext) footnote.append(notetext)
#TODO: make this barcode inline thing a util method #TODO: make this barcode inline thing a util method
encoded_svg = b64encode(bytes(svg, 'utf-8')).decode() encoded_svg = b64encode(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
svg = '<img class="endnotebc" src="%s"/>' % encoded_data svg = '<img class="endnotebc" src="%s"/>' % encoded_data
footnote.append(lxml.html.fromstring(svg)) footnote.append(lxml.html.fromstring(svg))
@ -276,8 +276,8 @@ 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 = code128.svg("PBr." + entry.dbhash) entry.svg = barcode.get("CODE128", "PBr." + tmpcode).raw
encoded_svg = b64encode(bytes(entry.svg, 'utf-8')).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

@ -1,11 +1,11 @@
import random import random
import string import string
import code128 import barcode
chars = string.ascii_letters + string.digits chars = string.ascii_letters + string.digits
for code in range(30): for code in range(30):
code = ''.join(random.choice(chars) for _ in range(5)) code = ''.join(random.choice(chars) for _ in range(5))
code = "SAp." + code code = "SAp." + code
with open("/tmp/" + code + ".svg", "w") as f: out_file = "/tmp/" + code + ".svg"
f.write(code128.svg(code, caption=True)) barcode.generate("code128", code, output=out_file)

Loading…
Cancel
Save