def get_drone(id_):
    """Get the drone from the server given the drone ID."""
    RES = Resource(IRI_CS + "/DroneCollection/" + str(id_))
    get_drone_ = RES.find_suitable_operation(None, None, CENTRAL_SERVER.Drone)
    resp, body = get_drone_()
    assert resp.status in [200, 201], "%s %s" % (resp.status, resp.reason)
    body = json.loads(body.decode('utf-8'))

    body.pop("@context")
    body.pop("@type")
    return body
Exemple #2
0
def get_anomaly(id_):
    """Get the anomaly from central server."""
    try:
        RES = Resource(IRI_CS + "/AnomalyCollection/" + str(id_))
        get_anomaly_ = RES.find_suitable_operation(None, None,
                                                   CENTRAL_SERVER.Anomaly)
        resp, body = get_anomaly_()
        assert resp.status in [200, 201], "%s %s" % (resp.status, resp.reason)

        anomaly = json.loads(body.decode('utf-8'))
        anomaly.pop("@context", None)
        anomaly.pop("@id", None)
        return anomaly
    except ConnectionRefusedError:
        raise ConnectionRefusedError(
            "Connection Refused! Please check the drone server.")