comparison checkclient.py @ 75:3928af61b4ce

checkclient final fixes
author Frank Koormann <frank@intevation.de>
date Fri, 06 Mar 2015 15:35:40 +0100
parents 22ce0dc2e71c
children 349d49bb69f4
comparison
equal deleted inserted replaced
74:22ce0dc2e71c 75:3928af61b4ce
12 parser = optparse.OptionParser(usage=usage) 12 parser = optparse.OptionParser(usage=usage)
13 parser.add_option("-s", "--host", default="localhost") 13 parser.add_option("-s", "--host", default="localhost")
14 parser.add_option("-p", "--port", default="5000") 14 parser.add_option("-p", "--port", default="5000")
15 (options, args) = parser.parse_args() 15 (options, args) = parser.parse_args()
16 16
17 if len(args) < 2: 17 if len(args) < 1:
18 parser.print_usage() 18 parser.print_usage()
19 sys.exit(1) 19 sys.exit(1)
20 20
21 url = "http://%s:%s/check/" % (options.host, options.port) 21 url = "http://%s:%s/check/" % (options.host, options.port)
22 infilename = args[0] 22 infilename = args[0]
23 format = options.format
24 23
25 files = {'file': open(infilename, 'rb')} 24 files = {'file': open(infilename, 'rb')}
26 25
27 r = requests.post(url, data=data, files=files) 26 r = requests.post(url, files=files)
28 27
29 if r.status_code == 200: 28 if r.status_code == 200:
30 with open(outfilename, "wb") as f:
31 f.write(r.content)
32 print "OK" 29 print "OK"
33 else: 30 else:
34 print "An error has occured" 31 print "An error has occured"
35 print r.status_code, r.headers 32 print r.status_code, r.headers
36 print r.text 33 print r.text
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)