Created
August 25, 2012 13:16
-
-
Save almorel/3465527 to your computer and use it in GitHub Desktop.
Créer un qrcode
This file contains 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
# -*- 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