def main():
pdf = BytesIO()
# Find all IPv6 addresses with global scope
ips = [dict(a['attrs'])['IFA_ADDRESS'] for a in IPRoute().get_addr() if a['scope'] == 0 and a['family'] == 10]
if ips:
c = Canvas(pdf, pagesize=(PAGE_W, PAGE_H))
hello(c, 'http://[%s]/badge' % ips[0])
else:
# ToDo: Legacy IP bild
c = Canvas(pdf, pagesize=(PAGE_W, PAGE_H))
c.showPage()
c.save()
lpr = subprocess.Popen(['lpr', '-P', PRINTER], stdin=subprocess.PIPE)
lpr.communicate(pdf.getvalue())
if lpr.returncode != 0:
pass
评论列表
文章目录