def ts_command(m=-1): # The metric id to print data for. c = conn() if m > 0: metric = Metric.get(c, m) datetimes, values = metric.ts(c) for i, value in enumerate(values): print "%s: %s" % (datetimes[i], value)
def values_command(m=-1, s=-1): # The metric id to print data for. # The survey id to print data for. """ Returns space-separated data for a metric, or longer form data for a survey. Metric output can be piped to spark. https://github.com/holman/spark """ c = conn() if m > 0: metric = Metric.get(c, m) datetimes, values = metric.ts(c) print " ".join("%s" % v for v in values) elif s > 0: survey = Survey.get(c, s) for row in survey.data(c): print row["created_at"] print row["value"] print ""
def record_metric(m, value="None"): c = ado.commands.conn() if m < 0: Metric.printall(c) raw_m = ado.commands.clean_input("Choose a metric number: ") if raw_m: m = int(raw_m) else: sys.stderr.write("No metric chosen.\n") sys.exit(1) if value == "None": metric = Metric.get(c, m) print "Record Metric %s) %s" % (metric.id, metric.name) print metric.description value = float(ado.commands.clean_input("> ")) md = MetricData.create(c, metric_id=m, value=value, created_at=datetime.now()) print md.display_line()