Ejemplo n.º 1
0
def answer():
    q = request.args.get("q", "")

    leader_ans = None

    while leader_ans == None:
        leading_team = team_finder.get_best_team('http://192.168.3.32:3000/', 'team_kickstarter')
        print "The leader is {} with ip: {}".format(leading_team.team, leading_team.url)
        print "The question was: " + q
        try:
            leader_ans = crowdsourcer.ask_question(q, leading_team.url)
        except Exception as e:
            return ""
        print "They replied with: " + str(leader_ans)

    return leader_ans
Ejemplo n.º 2
0
    "Who is Luke's father?",
    "How tall is Huw?",
    "What is 1 plus 1?",
    "What is 0 really?",
    "How much wood could a woodchuck chuck if a wood chuck could chuck wood?",
    "Which position is your team in?" "What is your score?",
    "FDE or Dev?",
    "What is the meaning of life?",
    "What is FRP?",
    "Which has been the best session so far?",
    "Karp or Thiel?",
]


def get_random_question():
    return random.choice(RANDOM_QUESTIONS)


if __name__ == "__main__":
    while True:
        time.sleep(0.1)
        teams = team_finder.get_ranked_teams("http://192.168.3.32:3000/", "team_kickstarter")
        random_team = random.choice(teams)
        leader_ans = crowdsourcer.ask_question(q, random_team.url)
        try:
            print "Asking " + str(q) + " to " + random_team.team
            q = get_random_question()
            print "Received " + str(leader_ans)
        except Exception as e:
            print "Failed to ask " + str(random_team.team) + " question " + str(q) + ". Got exception " + str(e)