comparison withdraw.py @ 0:fee51ab07d09

blanket publication of all existing python files in lib/python on maritain
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Mon, 09 Mar 2020 14:58:04 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fee51ab07d09
1 #!/bin/python
2 from sys import stdin,argv
3 from urllib2 import Request,urlopen, HTTPError
4 from base64 import b64encode
5 type='xyzzy'
6 l=''
7 year='2014'
8
9 def cc(names):
10 return ' '.join(map(lambda n:n[0]+n[1:].lower(),names.split()))
11
12 eargs=['uun']
13 eargs.extend(argv[1:])
14
15 while l=='':
16 l=stdin.readline().rstrip()
17 for l in stdin:
18 l=l.rstrip().decode('latin-1');
19 if l=='':
20 continue
21 try: #uun,...
22 vals=l.split("\t")
23 except ValueError:
24 print "Bad input: %s"%l
25 continue
26 attrs=" ".join(map(lambda n,v:'%s="%s"'%(n,v),zip(eargs,vals)))
27 req='<update year="%s" %s/>'%(year,attrs)
28 print req
29 continue
30 r=Request("http://localhost:8080/exist/apps/phd/updateApp.xq",
31 req.encode('utf-8'),headers={'Content-Type':'application/xml;charset=UTF-8'})
32 try:
33 res=urlopen(r)
34 except HTTPError as err:
35 print "Error:",err.read()
36 print req
37 exit(1)
38 print res.read()