summaryrefslogtreecommitdiff
path: root/NT/httplot
diff options
context:
space:
mode:
Diffstat (limited to 'NT/httplot')
-rwxr-xr-xNT/httplot45
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')
+
+