Skip to content

Instantly share code, notes, and snippets.

@almorel
Created August 25, 2012 13:16
Show Gist options
  • Save almorel/3465527 to your computer and use it in GitHub Desktop.
Save almorel/3465527 to your computer and use it in GitHub Desktop.
Créer un qrcode
# -*- coding:utf-8 -*-
import qrcode
import getopt
import sys
def usage():
print "usage : qrencode.py -m MESSAGE -save=FILE"
print "-m = Message à encoder"
print "-s = Fichier à enregistrer"
sys.exit(1)
try:
opts, args = getopt.getopt(sys.argv[1:], "hm:s:", ["help", "message", "save"])
except getopt.GetoptError, err:
print str(err)
usage()
sys.exit(1)
msg=False
fichier=False
for opt, arg in opts:
if opt in ("-h", "--help"): usage()
elif opt in ("-m", "--message"): msg=arg
elif opt in ("-s", "--save"): fichier=arg
if (msg == False and fichier == False):
usage()
img = qrcode.make(msg)
try:
img.save(fichier)
except getopt.GetoptError, err:
print str(err)
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment