...
| 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 ('bonamvin@univ-rouen.fr', 'lemaida3@univ-rouen.fr', 'esupdem@univ-rouen.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 suffix = '' file = open('/var/www/log/goodies.txt',"r") for line in file: if re.search(csn, linecsn==line.rstrip('\r\n'): alreadyChecked = True suffix = '[RE]' file.close() csnAsInt = int(csn, 16) modCsn = csnAsInt%51 if modCsn in range(0,1): print('{"csn":"-", "eppn":"parapluie", "firstname":"%s", "lastname":"Parapluie !", "locations":"esup-goodies"}' % (suffix)) elif modCsn in range(1,4): print('{"csn":"-", "eppn":"couteau", "firstname":"%s", "lastname":"Couteau !", "locations":"esup-goodies"}' % (suffix)) elif modCsn in range(4,11): print('{"csn":"-", "eppn":"porte-cartes", "firstname":"%s", "lastname":" Porte cartes !", "locations":"esup-goodies"}' % (suffix)) elif modCsn in range(11,28): print('{"csn":"-", "eppn":"mystere", "firstname":"%s", "lastname":"Goodies 20 ans !", "locations":"esup-goodies"}' % (suffix)) # range(28,51): else : print('{"csn":"-", "eppn":"porte-carte-simple", "firstname":"%s", "lastname":"Porte carte simple", "locations":"esup-goodies"}' % (suffix)) if not alreadyChecked: file = open('/var/www/log/goodies.txt',"a") file.write(csn + "\n") file.close() else: print '[]' |
...