summaryrefslogtreecommitdiff
path: root/modes.py
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-07-07 22:48:49 +0300
committerYuval Adam <yuval@y3xz.com>2015-07-07 22:48:49 +0300
commit8949d60b02b61d31806935baec99277382877f60 (patch)
treec5dbb4a6cd4c6258fd9756849c62035c6f52aa4b /modes.py
parent9b053db734f19f12df1b7d0be93a76f0cb485e12 (diff)
Process serialized message
Diffstat (limited to 'modes.py')
-rw-r--r--modes.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/modes.py b/modes.py
index 9a0fcd7..49812b5 100644
--- a/modes.py
+++ b/modes.py
@@ -1,8 +1,37 @@
import cups
+from PIL import Image, ImageDraw, ImageFont
+
+BASE_IMAGE = 'base.jpg'
+BASE_FONT = 'cutive.ttf'
PRINTER = 'Canon_iP7200_series'
-def printFile():
- conn = cups.Connection()
- conn.printFile(PRINTER, 'base.jpg', 'title', {})
+class ModesPrinter(object):
+
+ def __init__(self, imstr):
+ username, date, dominants, matrix = imstr.split('|')
+ self.username = username
+ self.month = date[:2]
+ self.year = date[2:]
+ self.dominants = [dominants[:6], dominants[6:]]
+ self.matrix = bin(int(matrix, 16))[5:]
+
+ def _debug(self):
+ print(self.username, self.month, self.year, self.dominants, self.matrix)
+
+ def draw_image(self):
+ im = Image.open('base.jpg')
+ draw = ImageDraw.Draw(im)
+ font = ImageFont.truetype('cutive.ttf', 14)
+ draw.text((10, 25), 'world', fonts=font)
+ im.show()
+
+ def do_print():
+ conn = cups.Connection()
+ conn.printFile(PRINTER, 'base.jpg', 'title', {})
+
+if __name__ == '__main__':
+ imstr = 'yuv.adm|062015|9A8D6D736489|eff51f2af82c06071120a'
+ mp = ModesPrinter(imstr)
+ mp._debug()