Exemple #1
0
def take_survey(s):
    c = ado.commands.conn()
    if s < 0:
        Survey.printall(c)
        raw_s = ado.commands.clean_input("Choose a survey number: ")
        if raw_s:
            s = int(raw_s)
        else:
            sys.stderr.write("No survey chosen.\n")
            sys.exit(1)

    survey = Survey.get(c, s)
    print "Taking Survey %s) %s" % (survey.id, survey.name)
    print survey.description
    value = ado.commands.clean_input("> ")

    SurveyData.create(c, survey_id=s, value=value, created_at=datetime.now())
Exemple #2
0
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 ""