diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-01-27 12:24:41 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-01-27 12:24:41 +0000 |
| commit | 487fcf990f3c536d7e1d2f66daa0c34c0407eac5 (patch) | |
| tree | 4f0dd5aa9d74af5e3e7628fbe20e1f0af60f512a /NT/httplot | |
| parent | 1f2bc21fd5ee9bff4fce190d7bb0ee4462e76e87 (diff) | |
NT resinstated as HTTP server
Diffstat (limited to 'NT/httplot')
| -rwxr-xr-x | NT/httplot | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/NT/httplot b/NT/httplot new file mode 100755 index 0000000..8f48dce --- /dev/null +++ b/NT/httplot @@ -0,0 +1,45 @@ +#!/usr/bin/python +import httplib +import argparse +parser = argparse.ArgumentParser() +parser.add_argument("method",default="GET",nargs='?') +parser.add_argument("path",default="/",nargs='?') +parser.add_argument("body",default="body",nargs='?') +parser.add_argument("ip",default="127.0.0.1:9000",nargs='?') +args=parser.parse_args() +connection = httplib.HTTPConnection(args.ip) +connection.request(args.method, args.path, args.body) +response= connection.getresponse().read() + +import xml.etree.ElementTree as ET +import sys +root = ET.fromstring(response) +try: + signal= root.find("signal").text +except AttributeError: + print "Error: no data found. check node ID" + sys.exit(0) + +o1 =signal.split(",") +x=[] +y=[] +for item in o1: + op=[] + o2 = item.split() + for s in o2: + op.append(float(s)) + if len(o2) > 1: + x.append(float(o2[0])) + y.append(float(o2[1])) + +import matplotlib.pyplot as plt +plt.plot(x,y) +plt.ylabel('signal') +plt.xlabel('time') +plt.show() + +#print response +#connection = httplib.HTTPConnection('54.228.219.55:80') +#connection = httplib.HTTPConnection('127.0.0.1:9000') + + |
