-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQRstuff.py
38 lines (34 loc) · 1.03 KB
/
QRstuff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from qrcode import make
from climage import convert
from random import randint
from time import sleep
import argparse
import subprocess
rand = str(randint(0,10000000))
parser = argparse.ArgumentParser(description='Create QR codes')
parser.add_argument('-s', '--string', help='String to be encoded', required=True)
parser.add_argument('-sh', '--show', help='Show QR code', default=False)
args = parser.parse_args()
def createQR(string):
qr = make(string)
if('http' not in string):
qr.save(string[:9] + '.png')
else:
qr.save(rand + '.png')
return qr
def showQR():
if(args.show):
if('http' in args.string):
output = convert(rand + '.png')
print("Saved as: "+ rand + '.png')
else:
output = convert(args.string + '.png')
print("Saved as: "+ args.string + '.png')
print(output)
createQR(args.string)
if('http' in args.string):
print("Saved as: "+ rand + '.png')
else:
print("Saved as: "+ args.string[:9] + '.png')
if(args.show):
showQR()