first commit
This commit is contained in:
parent
364b37308c
commit
d289d37a1d
1 changed files with 6 additions and 5 deletions
11
unhb-mqtt.py
11
unhb-mqtt.py
|
@ -2,26 +2,26 @@
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import sys
|
|
||||||
import pyqrcode
|
import pyqrcode
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
import cups
|
import cups
|
||||||
from matrix_client.client import MatrixClient
|
from matrix_client.client import MatrixClient
|
||||||
|
|
||||||
|
#Druckerinitialisierung
|
||||||
conn = cups.Connection()
|
conn = cups.Connection()
|
||||||
printers = conn.getPrinters()
|
printers = conn.getPrinters()
|
||||||
|
|
||||||
|
#formatiert uns hex in der notation 0x0000
|
||||||
def padhexa(s):
|
def padhexa(s):
|
||||||
return '0x' + s[2:].zfill(4)
|
return '0x' + s[2:].zfill(4)
|
||||||
|
|
||||||
|
|
||||||
def create_qrcode(newcode,hexid):
|
def create_qrcode(newcode,hexid):
|
||||||
qrobj = pyqrcode.create(newcode)
|
qrobj = pyqrcode.create(newcode)
|
||||||
with open('test.png', 'wb') as f:
|
with open('qr.png', 'wb') as f:
|
||||||
qrobj.png(f, scale=10)
|
qrobj.png(f, scale=10)
|
||||||
bg = Image.open('bg.png')
|
bg = Image.open('bg.png')
|
||||||
img = Image.open('test.png')
|
img = Image.open('qr.png')
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
logo_size = 140
|
logo_size = 140
|
||||||
logo = Image.open('unhb.png')
|
logo = Image.open('unhb.png')
|
||||||
|
@ -36,7 +36,8 @@ def create_qrcode(newcode,hexid):
|
||||||
outimage = "./qrcodes/" + hexid + ".png"
|
outimage = "./qrcodes/" + hexid + ".png"
|
||||||
bg.save(outimage)
|
bg.save(outimage)
|
||||||
print("qrcode erfolgreich generiert: " +newcode)
|
print("qrcode erfolgreich generiert: " +newcode)
|
||||||
# conn.printFile("gk420d", outimage, "foo", {})
|
# druckername hardcoded!
|
||||||
|
conn.printFile("gk420d", outimage, "Labelausdruck", {})
|
||||||
|
|
||||||
|
|
||||||
def get_lastkey():
|
def get_lastkey():
|
||||||
|
|
Loading…
Reference in a new issue