Created
March 6, 2013 19:51
-
-
Save zacharyvoase/5102470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import subprocess | |
import tempfile | |
import urllib | |
text = sys.stdin.read() | |
chart_url_template = ('http://chart.apis.google.com/chart?' | |
'cht=qr&chs=300x300&chl={data}&chld=H|0') | |
chart_url = chart_url_template.format(data=urllib.quote(text)) | |
with tempfile.NamedTemporaryFile(mode='w', suffix='.png') as f: | |
subprocess.check_call(['curl', '-L', chart_url], | |
stdout=f, stderr=sys.stderr) | |
subprocess.check_call(['qlmanage', '-p', f.name]) |
Nice idea.
Could not get the qrencode module to install in OS X mavericks
FWIW, I've put together this little script instead
#!/bin/bash
# Author: Rasmus Stougaard
# requrements:
# install qrencode
#
# brew install qrencode
tmpQrFile=/tmp/qr-tmp.png
qrencode -o $tmpQrFile && qlmanage -p $tmpQrFile && rm $tmpQrFile
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@zacharyvoase most impressive!