Beispiel #1
0
 def test_is_aereal_qhawax_valid(self):
     self.assertAlmostEqual(get_business_helper.isAerealQhawax('qH006'),
                            True)
     self.assertAlmostEqual(get_business_helper.isAerealQhawax('qH004'),
                            False)
     self.assertAlmostEqual(get_business_helper.isAerealQhawax('qH244'),
                            None)
def recordDroneTakeoff():
    req_json = request.get_json()
    try:
        flight_start, qhawax_name = exception_helper.getJsonOfTakeOff(req_json)
        if (get_business_helper.isAerealQhawax(qhawax_name) == True):
            post_data_helper.recordDroneTakeoff(flight_start, qhawax_name)
            socketio.emit(qhawax_name + '_takeoff', flight_start)
            return make_response(
                {'Success': 'The drone takeoff has been recorded'}, 200)
        return make_response({'Warning': 'This is not an andean drone'}, 400)
    except (TypeError, ValueError) as e:
        json_message = jsonify({'error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
    except (Exception) as e:
        json_message = jsonify({'database error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
def recordDroneTakeoff():
    req_json = request.get_json()
    try:
        flight_start, qhawax_name = exception_helper.getJsonOfTakeOff(req_json)
        if get_business_helper.isAerealQhawax(qhawax_name) == True:
            post_data_helper.recordDroneTakeoff(flight_start, qhawax_name)
            socketio.emit(qhawax_name + "_takeoff", flight_start)
            return make_response(
                {"Success": "The drone takeoff has been recorded"}, 200)
        return make_response({"Warning": "This is not an andean drone"}, 400)
    except (TypeError, ValueError) as e:
        json_message = jsonify({"error": "'%s'" % (e)})
        return make_response(json_message, 400)
    except (Exception) as e:
        json_message = jsonify({"database error": "'%s'" % (e)})
        return make_response(json_message, 400)
def recordDroneLanding():
    req_json = request.get_json()
    try:
        flight_end, qhawax_name, flight_detail, location = exception_helper.getJsonOfLanding(
            req_json)
        if (get_business_helper.isAerealQhawax(qhawax_name) == True):
            post_data_helper.recordDroneLanding(flight_end, qhawax_name,
                                                flight_detail)
            post_business_helper.updateLastLocation(qhawax_name, location)
            socketio.emit(qhawax_name + '_landing', flight_end)
            return make_response(
                {'Success': 'The drone landing has been recorded'}, 200)
        return make_response({'Warning': 'This is not an andean drone'}, 400)
    except (TypeError, ValueError) as e:
        json_message = jsonify({'error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
    except (Exception) as e:
        json_message = jsonify({'database error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
def handleTelemetry():
    global drone_telemetry
    try:
        data_json = request.get_json()
        token = (data_json["token"] if
                 (data_json["token"] == "droneandino123") else None)
        room = data_json["room"]  # El room es el qhawax ID
        telemetry = data_json["telemetry"]
    except KeyError as e:
        json_message = jsonify({"error": "'%s'" % (e)})
        return make_response(json_message, 400)
    if get_business_helper.isAerealQhawax(room) == True:
        telemetry["ID"] = room
        socketio.emit(room + "_telemetry", telemetry)
        drone_telemetry = telemetry
        post_data_helper.storeLogs(telemetry, room)
        return make_response(
            {"success": "Telemetry sent from drone: " + str(room)}, 200)
    return make_response(
        {"warning": "qHAWAX " + str(room) + " is not aereal "}, 400)
def handleTelemetry():
    global drone_telemetry
    try:
        data_json = request.get_json()
        token = data_json['token'] if (data_json['token']
                                       == 'droneandino123') else None
        room = data_json['room']  #El room es el qhawax ID
        telemetry = data_json['telemetry']
    except KeyError as e:
        json_message = jsonify({'error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
    if (get_business_helper.isAerealQhawax(room) == True):
        telemetry['ID'] = room
        socketio.emit(room + '_telemetry', telemetry)
        drone_telemetry = telemetry
        post_data_helper.storeLogs(telemetry, room)
        return make_response(
            {'success': 'Telemetry sent from drone: ' + str(room)}, 200)
    return make_response(
        {'warning': 'qHAWAX ' + str(room) + ' is not aereal '}, 400)
def recordDroneLanding():
    req_json = request.get_json()
    try:
        (
            flight_end,
            qhawax_name,
            flight_detail,
            location,
        ) = exception_helper.getJsonOfLanding(req_json)
        if get_business_helper.isAerealQhawax(qhawax_name) == True:
            post_data_helper.recordDroneLanding(flight_end, qhawax_name,
                                                flight_detail)
            post_business_helper.updateLastLocation(qhawax_name, location)
            socketio.emit(qhawax_name + "_landing",
                          flight_end)  # insert qhawax_name
            return make_response(
                {"Success": "The drone landing has been recorded"}, 200)
        return make_response({"Warning": "This is not an andean drone"}, 400)
    except (TypeError, ValueError) as e:
        json_message = jsonify({"error": "'%s'" % (e)})
        return make_response(json_message, 400)
    except (Exception) as e:
        json_message = jsonify({"database error": "'%s'" % (e)})
        return make_response(json_message, 400)