Example #1
0
def sendQhawaxStatusOff():
    """
    Endpoint to set qHAWAX OFF because script detect no new data within five minutes

    """
    jsonsend = {}
    try:
        req_json = request.get_json()
        exception_helper.getStatusOffTargetofJson(req_json)
        name = str(req_json['qhawax_name']).strip()
        qhawax_time_off = req_json['qhawax_lost_timestamp']
        description = req_json['description']
        person_in_charge = req_json['person_in_charge']
        post_business_helper.saveStatusOffQhawaxTable(name)
        if (same_helper.getQhawaxMode(name) == 'Cliente'):
            post_business_helper.saveStatusOffQhawaxInstallationTable(
                name, qhawax_time_off)
        post_business_helper.writeBinnacle(name, description, person_in_charge)
        jsonsend['main_inca'] = -1
        jsonsend['name'] = name
        socketio.emit('update_inca', jsonsend)
        return make_response({'Success': 'qHAWAX off'}, 200)
    except (ValueError, TypeError) as e:
        json_message = jsonify({'error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
Example #2
0
def sendQhawaxStatusOff():
    """ Server Open Source lo apagara / Web Comercial lo pagara y enviara correo- Endpoint to set qHAWAX OFF because script detect no new data within five minutes  """
    jsonsend = {}
    req_json = request.get_json()
    description = "qHAWAX off"
    try:
        qH_name = exception_helper.getStatusOffTargetofJson(req_json)
        post_business_helper.saveStatusQhawaxTable(qH_name, 'OFF', -1)
        lessfive = get_data_helper.getQhawaxLatestTimestampProcessedMeasurement(
            qhawax_name)
        post_business_helper.saveStatusOffQhawaxInstallationTable(
            qH_name, lessfive)
        post_business_helper.writeBinnacle(qH_name, description, None)
        jsonsend['main_inca'] = -1
        jsonsend['name'] = qH_name
        socketio.emit('update_inca', jsonsend)
        return make_response({'Success': 'qHAWAX OFF'}, 200)
    except (ValueError, TypeError) as e:
        json_message = jsonify({'error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
Example #3
0
def sendQhawaxStatusOff():
    """Server Open Source lo apagara / Web Comercial lo pagara y enviara correo- Endpoint to set qHAWAX OFF because script detect no new data within five minutes"""
    jsonsend = {}
    req_json = request.get_json()
    description = "qHAWAX off"
    try:
        qH_name = exception_helper.getStatusOffTargetofJson(req_json)
        comercial_name = same_helper.getComercialName(qH_name)
        post_business_helper.saveStatusQhawaxTable(qH_name, "OFF", -1)
        lessfive = (
            get_data_helper.getQhawaxLatestTimestampProcessedMeasurement(
                qH_name
            )
        )  # obtuve la ultima medida enviada a la tabla procesed open
        post_business_helper.saveStatusOffQhawaxInstallationTable(
            qH_name, lessfive
        )
        post_business_helper.writeBinnacle(qH_name, description, "API")
        jsonsend["main_inca"] = -1
        jsonsend["name"] = qH_name
        socketio.emit("update_inca", jsonsend)
        type = same_helper.queryQhawaxType(qH_name)
        if type == "MOBILE_EXT":
            post_data_helper.recordEndTrip(qH_name, str(comercial_name))
            jsonLatLon = (
                get_data_helper.getMobileLatestLatLonValidProcessedMeasurement(
                    qH_name
                )
            )
            if jsonLatLon != None:
                post_data_helper.updateLastestLatLonMobile(qH_name, jsonLatLon)

        return make_response({"Success": "qHAWAX OFF"}, 200)
    except (ValueError, TypeError) as e:
        json_message = jsonify({"error": "'%s'" % (e)})
        return make_response(json_message, 400)
Example #4
0
 def test_query_off_target_json_valid(self):
     data = {'qhawax_name': 'test'}
     self.assertAlmostEqual(exception_helper.getStatusOffTargetofJson(data),
                            (str(data['qhawax_name']).strip()))
 def test_query_off_target_json_valid(self):
     data = {"qhawax_name": "test"}
     self.assertAlmostEqual(
         exception_helper.getStatusOffTargetofJson(data),
         (str(data["qhawax_name"]).strip()),
     )