comparison checkclient.py @ 81:9ad8421dafb4 1.1

merge
author Bernhard Herzog <bh@intevation.de>
date Mon, 09 Mar 2015 17:07:48 +0100
parents 3928af61b4ce
children 349d49bb69f4
comparison
equal deleted inserted replaced
80:ae2f4e1c4ab0 81:9ad8421dafb4
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import optparse
5 import sys
6
7 import requests
8
9
10 def main():
11 usage = "usage: %prog [options] infile"
12 parser = optparse.OptionParser(usage=usage)
13 parser.add_option("-s", "--host", default="localhost")
14 parser.add_option("-p", "--port", default="5000")
15 (options, args) = parser.parse_args()
16
17 if len(args) < 1:
18 parser.print_usage()
19 sys.exit(1)
20
21 url = "http://%s:%s/check/" % (options.host, options.port)
22 infilename = args[0]
23
24 files = {'file': open(infilename, 'rb')}
25
26 r = requests.post(url, files=files)
27
28 if r.status_code == 200:
29 print "OK"
30 else:
31 print "An error has occured"
32 print r.status_code, r.headers
33 print r.text
34 sys.exit(2)
35
36
37 if __name__ == "__main__":
38 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)