コード例 #1
0
ファイル: endpoints.py プロジェクト: austincawley/pop
def shutStop():
    """
        For emergency shutoff
    :return:
    """
    stopper.start_listening()
    stopper.shutoff()
    return make_response(jsonify(status="Great Success",
                                 maker_status=maker.get_status(),
                                 robot_status=robot.current_command()), 200)
コード例 #2
0
ファイル: endpoints.py プロジェクト: austincawley/pop
def make():
    """
        Baddies:
            Maker is already running
            Robot is not back at the station

        Options:
            in request args
                pop_time
                sentiment
    :return:
    """

    pop_time = request.args.get('pop_time', None)
    sentiment = str(request.args.get('sentiment', 'neutral'))
    print "sentiment " + sentiment
    if maker.is_making():
        return make_response(jsonify(status="Failure",
                                     maker_status=maker.get_status(),
                                     robot_status=robot.current_command(),
                                     error="Maker is busy dog",
                                     error_type="busy",
                                     time_left=maker.time_until_done()), 400)

    if pop_time is None:
        pop_time = maker.default_pop_time
    else:
        pop_time = float(pop_time)

    # Send the robot on finish
    robot.set_message(make_message(sentiment))
    maker.make_popcorn(pop_time, on_finish_function=robot.deliver)
    stopper.start_listening()

    return make_response(jsonify(status="Great Success",
                                 maker_status=maker.get_status(),
                                 robot_status=robot.current_command(),
                                 pop_time=pop_time), 200)