frank@74: #!/usr/bin/env python frank@74: # -*- coding: utf-8 -*- frank@74: frank@74: import optparse frank@74: import sys frank@74: frank@74: import requests frank@74: frank@74: frank@74: def main(): frank@74: usage = "usage: %prog [options] infile" frank@74: parser = optparse.OptionParser(usage=usage) frank@74: parser.add_option("-s", "--host", default="localhost") frank@74: parser.add_option("-p", "--port", default="5000") frank@74: (options, args) = parser.parse_args() frank@74: frank@75: if len(args) < 1: frank@74: parser.print_usage() frank@74: sys.exit(1) frank@74: frank@74: url = "http://%s:%s/check/" % (options.host, options.port) frank@74: infilename = args[0] frank@74: frank@74: files = {'file': open(infilename, 'rb')} frank@74: frank@75: r = requests.post(url, files=files) frank@74: frank@74: if r.status_code == 200: frank@74: print "OK" frank@74: else: frank@74: print "An error has occured" frank@74: print r.status_code, r.headers frank@74: print r.text frank@74: sys.exit(2) frank@74: frank@74: frank@74: if __name__ == "__main__": frank@74: main()