...
| Bloc de code | ||||
|---|---|---|---|---|
| ||||
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cgi
import re
args = cgi.parse()
print "Content-type: application/json"
print
if 'locations' in args.keys():
if args['eppn'][0] in ('login@univ-ville1.fr', 'autrelogin@univ-ville1.fr', 'login@univ-ville2.fr'):
print '["Esup Goodies"]'
else:
print '[]'
elif 'isTagable' in args.keys():
print 'OK'
elif 'validateTag' in args.keys():
print 'OK'
elif 'tagIdCheck' in args.keys():
csn = args['csn'][0]
alreadyChecked = False
file = open('/var/www/log/goodies.txt',"r")
for line in file:
if re.search(csn, line):
alreadyChecked = True
file.close()
csnAsInt = int(csn, 16)
if csnAsInt%60==32:
print('{"csn":"-", "eppn":"parapluie", "firstname":"%s", "lastname":"Parapluie !", "locations":"esup-goodies"}' % ('Gagné' + ('[RE]' if alreadyChecked else '')))
elif csnAsInt%40==3:
print('{"csn":"-", "eppn":"couteau", "firstname":"%s", "lastname":"Couteau !", "locations":"esup-goodies"}' % ('Gagné' + ('[RE]' if alreadyChecked else '')))
elif csnAsInt%5==2:
print('{"csn":"-", "eppn":"porte-cartes", "firstname":"%s", "lastname":" Porte cartes !", "locations":"esup-goodies"}' % ('Gagné' + ('[RE]' if alreadyChecked else '')))
ifelif csnAsInt%3==0:
print('{"csn":"-", "eppn":"porte-carte-simple", "firstname":"%s", "lastname":"Porte carte simple", "locations":"esup-goodies"}' % ('Gagné' + ('[RE]' if alreadyChecked else '')))
else:
print('{"csn":"-", "eppn":"perdu", "firstname":"%s", "lastname":":''-(", "locations":"esup-goodies"}' % ('Perdu' + ('[RE]' if alreadyChecked else '')))
if not alreadyChecked:
file = open('/var/www/log/goodies.txt',"a")
file.write(csn + "\n")
file.close()
else:
print '??' |
...