|
|
|
@ -145,7 +145,8 @@ class PublicRelations(Bureau):
|
|
|
|
|
else:
|
|
|
|
|
count = 10
|
|
|
|
|
|
|
|
|
|
prn = printer.Usb(0x416, 0x5011, in_ep=0x81, out_ep=0x03)
|
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
|
# TODO: abstract this to use a simple templating system instead of raw
|
|
|
|
|
prn.codepage = "cp437"
|
|
|
|
|
|
|
|
|
|
# TODO: add fancier formatting i.e. inverted text for username/handle
|
|
|
|
@ -159,7 +160,8 @@ class PublicRelations(Bureau):
|
|
|
|
|
prn.text("\r\n")
|
|
|
|
|
prn.set(text_type="NORMAL")
|
|
|
|
|
twtext = html.unescape(t["full_text"])
|
|
|
|
|
t_wrapped = textwrap.fill(twtext, width=48) + "\r\n"
|
|
|
|
|
t_wrapped = textwrap.fill(twtext, width=self.smprint["textwidth"])\
|
|
|
|
|
+ "\r\n"
|
|
|
|
|
t_enc = t_wrapped.encode("cp437", "ignore")
|
|
|
|
|
prn._raw(t_enc)
|
|
|
|
|
|
|
|
|
@ -173,7 +175,7 @@ class PublicRelations(Bureau):
|
|
|
|
|
im = PIL.Image.open(filename)
|
|
|
|
|
if im.mode in ("L", "RGB", "P"):
|
|
|
|
|
im = PIL.ImageOps.equalize(im)
|
|
|
|
|
im.thumbnail((576, 576), PIL.Image.ANTIALIAS)
|
|
|
|
|
im.thumbnail((self.smprint["width"], 576), PIL.Image.ANTIALIAS)
|
|
|
|
|
prn.image(im, impl="bitImageColumn")
|
|
|
|
|
|
|
|
|
|
tw_shortcode = self.short_tweet_id(t["id_str"])
|
|
|
|
@ -190,7 +192,7 @@ class PublicRelations(Bureau):
|
|
|
|
|
shortcode, _ = data.split(".")
|
|
|
|
|
tweet_id = self.get_tweet_id(shortcode)
|
|
|
|
|
tweet = self.t.t.statuses.show(id=tweet_id, tweet_mode="extended")
|
|
|
|
|
prn = printer.Usb(0x416, 0x5011, in_ep=0x81, out_ep=0x03)
|
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
|
prn.codepage = "cp437"
|
|
|
|
|
|
|
|
|
|
prn.set(text_type="U")
|
|
|
|
@ -199,7 +201,8 @@ class PublicRelations(Bureau):
|
|
|
|
|
prn.text("\r\n")
|
|
|
|
|
prn.set(text_type="NORMAL")
|
|
|
|
|
twtext = html.unescape(tweet["full_text"])
|
|
|
|
|
t_wrapped = textwrap.fill(twtext, width=48) + "\r\n"
|
|
|
|
|
t_wrapped = textwrap.fill(twtext, width=self.smprint["textwidth"])\
|
|
|
|
|
+ "\r\n"
|
|
|
|
|
t_enc = t_wrapped.encode("cp437", "ignore")
|
|
|
|
|
prn._raw(t_enc)
|
|
|
|
|
|
|
|
|
@ -213,7 +216,7 @@ class PublicRelations(Bureau):
|
|
|
|
|
im = PIL.Image.open(filename)
|
|
|
|
|
if im.mode in ("L", "RGB", "P"):
|
|
|
|
|
im = PIL.ImageOps.equalize(im)
|
|
|
|
|
im.thumbnail((576, 576), PIL.Image.ANTIALIAS)
|
|
|
|
|
im.thumbnail((self.smprint["width"], 576), PIL.Image.ANTIALIAS)
|
|
|
|
|
prn.image(im, impl="bitImageColumn")
|
|
|
|
|
|
|
|
|
|
tw_shortcode = self.short_tweet_id(tweet["id_str"])
|
|
|
|
@ -297,7 +300,7 @@ class PublicRelations(Bureau):
|
|
|
|
|
else:
|
|
|
|
|
count = 10
|
|
|
|
|
|
|
|
|
|
prn = printer.Usb(0x416, 0x5011, in_ep=0x81, out_ep=0x03)
|
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
|
prn.codepage = "cp437"
|
|
|
|
|
|
|
|
|
|
# TODO: add fancier formatting i.e. inverted text for username/handle
|
|
|
|
@ -313,7 +316,8 @@ class PublicRelations(Bureau):
|
|
|
|
|
prn.set(text_type="NORMAL")
|
|
|
|
|
ttext = bleach.clean(t.content, tags=[], strip=True)
|
|
|
|
|
ttext = html.unescape(ttext)
|
|
|
|
|
t_wrapped = textwrap.fill(ttext, width=48) + "\r\n"
|
|
|
|
|
t_wrapped = textwrap.fill(ttext, width=self.smprint["textwidth"])\
|
|
|
|
|
+ "\r\n"
|
|
|
|
|
t_enc = t_wrapped.encode("cp437", "ignore")
|
|
|
|
|
prn._raw(t_enc)
|
|
|
|
|
|
|
|
|
@ -331,7 +335,7 @@ class PublicRelations(Bureau):
|
|
|
|
|
im = PIL.Image.open(io.BytesIO(req_data.content))
|
|
|
|
|
if im.mode in ("L", "RGB", "P"):
|
|
|
|
|
im = PIL.ImageOps.equalize(im)
|
|
|
|
|
im.thumbnail((576, 576), PIL.Image.ANTIALIAS)
|
|
|
|
|
im.thumbnail((self.smprint["width"], 576), PIL.Image.ANTIALIAS)
|
|
|
|
|
prn.image(im, impl="bitImageColumn")
|
|
|
|
|
|
|
|
|
|
tw_shortcode = self.short_tweet_id(str(t["id"]))
|
|
|
|
|