def reportImg(course=None, teamCode=None):
    '''Funcion para reportar forma de imagen'''
    if course is None or teamCode is None:
        return jsonify(status=400, message="Request is malformed")

    if course in COURSES:
        if TEAM_PATTERN.match(teamCode):
            eprint(request.data["shape"])
            return make_response(jsonify(success=True), 200)
    return make_response(jsonify(success=False, msg="Cannot find course or team"), 404)
Beispiel #2
0
def start(course, teamCode):
    '''Funcion para iniciar el run del concurso'''
    if course is None or teamCode is None:
        return make_response(
            jsonify(success=False, msg="Request is malformed"), 400)

    if course in COURSES:
        if TEAM_PATTERN.match(teamCode):
            eprint("Start " + course)
            return make_response(jsonify(success=True), 200)
    return make_response(
        jsonify(success=False, msg="Cannot find team or course"), 404)
Beispiel #3
0
def obstacleAvoidance(course=None, teamCode=None):
    '''Funcion para evadir obstaculo por un gate'''
    # validar llamada
    if course is None or teamCode is None:
        return make_response(jsonify(success=False, msg="Request is malformed"), 400)

    # validar curso
    if course in COURSES:
        # validate team
        if TEAM_PATTERN.match(teamCode):
            # status 200
            num = NUMS[randint(0, NUMS_LEN)]
            letter = LETTERS[randint(0, LETTERS_LEN)]
            gate_code = "(" + num + "," + letter + ")"
            return make_response(jsonify(gateCode=gate_code), 200)
    return make_response(jsonify(success=False, msg="Cannot find team or course"), 404)
Beispiel #4
0
def logHeart(course, teamCode):
    '''Funcion para hacer log de heartbeat'''
    if course is None or teamCode is None:
        return make_response(jsonify(success=False, msg="Request malformed"),
                             400)

    if course in COURSES:
        if TEAM_PATTERN.match(teamCode):
            # data = request.data
            # dataDict = json.loads(data)
            print('--------- HEARTBEAT ---------')
            print(request.form)
            print('-----------------------------')
            return make_response(jsonify(success=True), 200)
    return make_response(
        jsonify(success=False, msg="Cannot find team or course"), 404)
Beispiel #5
0
def pingLoc(course, teamCode):
    '''Funcion para ping de localizacion'''
    if course is None or teamCode is None:
        return jsonify(status=400, msg="Request is malformed")

    if course in COURSES:
        if TEAM_PATTERN.match(teamCode):
            buoyColor1Flag = request.data.get("buoyColor1", 0) in COLORS
            buoyColor2Flag = request.data.get("buoyColor2", 0) in COLORS
            frequency1Flag = 25 <= int(request.data.get("frequency1", 0)) <= 40
            frequency2Flag = 25 <= int(request.data.get("frequency2", 0)) <= 40
            if buoyColor1Flag and buoyColor2Flag and frequency1Flag and frequency2Flag:
                return make_response(jsonify(success=True), 200)
            return make_response(
                jsonify(success=False, msg="Invalid color or freq"), 503)

    return make_response(
        jsonify(success=False, msg="Cannot find team or course"), 404)
def interopImg(course=None, teamCode=None):
    '''Funcion para subir imagen'''
    # validar llamada
    if course is None or teamCode is None:
        return make_response(jsonify(success=False, msg="Request is malformed"), 400)

    if 'file' not in request.files:
        flash('No incluye archivo')
        return make_response(jsonify(succes=False, msg="No incluye archivo"), 400)

    file = request.files['file']

    # validar curso
    if course in COURSES:
        # validar team
        if TEAM_PATTERN.match(teamCode):
            # status 200
            return upload_file(file)
    return make_response(jsonify(success=False, msg="Cannot find team or course"), 404)
def automatedDocking(course=None, teamCode=None):
    '''Funcion con curso para automated docking'''
    # validar llamada
    if course is None or teamCode is None:
        return make_response(
            jsonify(success=False, msg="Request is malformed"), 400)

    # validar curso
    if course in COURSES:
        # validate team
        if TEAM_PATTERN.match(teamCode):
            return json.dumps({
                "dockingBaySequence": [{
                    "symbol": SYMBOLS[randint(0, SYM_LEN)],
                    "color": COLORS[randint(0, COLORS_LEN)]
                }, {
                    "symbol": SYMBOLS[randint(0, SYM_LEN)],
                    "color": COLORS[randint(0, COLORS_LEN)]
                }]
            }), 200, {
                "ContentType": "application/json"
            }
    return make_response(
        jsonify(success=False, msg="Cannot find team or course"), 404)