Ejemplo n.º 1
0
def list_functions():
    str = urllib2.urlopen(get_server() + 'client/list_functions/').read()
    if str == "None":
        raise ValueError('no functions')
        return
    f_dict = json.loads(str)
    f_list = []
    for f in f_dict:
        f_class = function(f["id"], f["fully_qualified_name"], f["property"])
        f_list.append(f_class)
    return f_list
Ejemplo n.º 2
0
def list_observations():
    str = urllib2.urlopen(get_server() + 'client/list_observations/').read()
    if str == "None":
        raise ValueError('no observations')
        return
    obs_dict = json.loads(str)
    obs_list = []
    for o in obs_dict:
        obs_class = observation(o["id"], o["instrumentation_point"],
                                o["verdict"], o["observed_value"],
                                o["atom_index"], o["previous_condition"])
        obs_list.append(obs_class)
    return obs_list
Ejemplo n.º 3
0
def get_parametric_path(obs_id_list, instrumentation_point_id=None):
    # instrumentation_point optional -> get it from an observation in the list
    if instrumentation_point_id == None:
        instrumentation_point_id = observation(obs_id_list[0]).instrumentation_point

    # checking if all the observations are made at the same point
    for id in obs_id_list:
        obs = observation(id)
        if obs.instrumentation_point != instrumentation_point_id:
            raise ValueError('the observations must have the same instrumentation point')

    data1 = {"observation_ids": obs_id_list, "instrumentation_point_id": instrumentation_point_id}
    req = requests.post(url=get_server() + 'client/get_parametric_path/', data=json.dumps(data1))

    return req.text
Ejemplo n.º 4
0
def get_parametric_path(obs_id_list, instrumentation_point_id):
    #instrumentation_point optional -> get it from an observation in the list??
    for id in obs_id_list:
        obs = observation(id)
        if obs.instrumentation_point != instrumentation_point_id:
            raise ValueError(
                'the observations must have the same instrumentation point')

    data1 = {
        "observation_ids": obs_id_list,
        "instrumentation_point_id": instrumentation_point_id
    }
    req = requests.post(url=get_server() + 'get_parametric_path/',
                        data=json.dumps(data1))

    return req.text
Ejemplo n.º 5
0
def get_atom_list(verdict_value):
    """
    the idea is to list all atoms for which verdict is ture or false
    """

    connection = get_connection()

    str = connection.request(get_server() +
                             'client/list_atoms_where_verdict/%d/' %
                             verdict_value)
    if str == "None":
        raise ValueError('there are no verdicts with given value')
        return
    atoms_dict = json.loads(str)
    atoms_list = []
    for atom_elem in atoms_dict:
        atom_class = atom(atom_elem["id"], atom_elem["property_hash"],
                          atom_elem["serialised_structure"],
                          atom_elem["index_in_atoms"])
        atoms_list.append(atom_class)
    return atoms_list