online.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:badge-o-matic 作者: markuslindenberg 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号