4 Python has a different style of documentation which will break doxygen...
9 import matplotlib.pyplot as plt
15 #TODO: Replace with URL of testing server
16 api_url = "https://daedalus/api"
19 sys.stderr.write("%s: %s : %s\n" % (sys.argv[0], str(datetime.datetime.now()), message))
21 def update_plot(plot, axes, data_x, data_y):
23 Update data to plot, allegedly this is faster than just replotting everything
25 plot.set_xdata(numpy.append(plot.get_xdata(), data_x))
26 plot.set_ydata(numpy.append(plot.get_ydata(), data_y))
33 sys.stderr.write("Usage: %s sensor_id\n" % argv[0])
34 sys.stderr.write("Identifying sensors...\n\n")
35 r = requests.get(api_url + "?sensors", verify=False)
42 axes = fig.add_subplot(111)
43 #NOTE: Comma here is *not* a typo and is extremely important and some kind of mysterious python magical tuple thing
44 # Do not remove the comma or things will break. Horribly.
45 plot, = axes.plot([],[])
50 params = { "id" : argv[1], "start_time" : "-1", "format" : "tsv"}
52 r = requests.get(api_url + "/sensors", params=params, verify=False)
54 log("Failed to make request for data");
57 if r.status_code != 200:
58 log("Bad status code %d" % r.status_code)
68 for line in r.text.split("\n"):
72 point = map(float, line.split("\t"))
74 if point[0] > start_time:
75 data_x.append(point[0])
76 data_y.append(point[1])
80 update_plot(plot, axes, data_x, data_y)
85 # ... This is how you make main work in python. With string comparisons.
86 if __name__ == "__main__":