Exemplo n.º 1
0
def get_project(project_id: int):
    import projectmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        return jsonify(project.serialize)
    else:
        abort(500, f"There is no project with project_id={project_id}")
Exemplo n.º 2
0
def get_radargrams(project_id: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        radargrams = radargramsmanager.get_radargrams(project_id)
        return jsonify(
            {"radargrams": [radargram.serialize for radargram in radargrams]})
    else:
        abort(500, f"There is no project with project_id={project_id}")
Exemplo n.º 3
0
def delete_radargram(project_id: int, radargram_id: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        ok = radargramsmanager.delete_radargram(project_id, radargram_id)
        if ok:
            return "Delete successfully"
        else:
            abort(500, "Refuse deleting radargram")
    else:
        return jsonify(
            {"Error": f"There is no project with project_id={project_id}"})
Exemplo n.º 4
0
def get_radargram_link(project_id: int, radargram_id: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        link = radargramsmanager.get_radargram_link(project_id, radargram_id)
        if link is not None:
            return link
        else:
            abort(500,
                  f"There is no radargram with radargram_id={radargram_id}")
    else:
        abort(500, f"There is no project with project_id={project_id}")
Exemplo n.º 5
0
def get_radargram(project_id: int, radargram_id: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        radargram = radargramsmanager.get_radargram(project_id, radargram_id)
        if radargram is not None:
            return jsonify(radargram.serialize)
        else:
            abort(500,
                  f"There is no radargram with radargram_id={radargram_id}")
    else:
        abort(500, f"There is no project with project_id={project_id}")
Exemplo n.º 6
0
def get_traces_headers(project_id: int, radargram_id: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        radargram = radargramsmanager.get_radargram(project_id, radargram_id)
        if radargram is not None:
            traces = radargramsmanager.get_traces_headers(
                project_id, radargram_id)
            return jsonify({"traces": [trace.serialize for trace in traces]})
        else:
            abort(500,
                  f"There is no radargram with radargram_id={radargram_id}")
    else:
        abort(500, f"There is no project with project_id={project_id}")
Exemplo n.º 7
0
def get_traces_amplitudes(project_id: int, radargram_id: int, start_num: int,
                          finish_num: int, stage: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        radargram = radargramsmanager.get_radargram(project_id, radargram_id)
        if radargram is not None:
            traces = radargramsmanager.get_traces_amplitudes(
                project_id, radargram_id, start_num, finish_num, stage)
            return jsonify(
                {"amplitudes": [list(trace.amplitudes) for trace in traces]})
        else:
            abort(500,
                  f"There is no radargram with radargram_id={radargram_id}")
    else:
        abort(500, f"There is no project with project_id={project_id}")
Exemplo n.º 8
0
def get_traces(project_id: int, radargram_id: int, trace_id: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        radargram = radargramsmanager.get_radargram(project_id, radargram_id)
        if radargram is not None:
            trace = radargramsmanager.get_trace(project_id, radargram_id,
                                                trace_id)
            if trace is not None:
                data = trace.serialize
                data.update({"amplitudes": list(trace.amplitudes)})
                return jsonify(data)
            else:
                abort(500, f"There is no trace with trace_id={trace_id}")
        else:
            abort(500,
                  f"There is no radargram with radargram_id={radargram_id}")
    else:
        abort(500, f"There is no project with project_id={project_id}")
Exemplo n.º 9
0
def add_radargram(project_id: int):
    import projectmanager, radargramsmanager
    project = projectmanager.get_project(project_id)
    if project is not None:
        if 'datafile' not in request.files:
            abort(403, "File is not send (1)")
        file = request.files['datafile']
        if not file:
            abort(404, "File is not send (2)")
        name = os.path.basename(file.filename)
        filename = translit(file.filename, 'ru', reversed=True)
        filename = secure_filename(filename)
        filename = os.path.join(f"{g.user.id}_{project_id}_{filename}")

        radargram = radargramsmanager.add_radargram(project_id, name, file,
                                                    filename)
        if radargram is not None:
            return jsonify(radargram.serialize)
        else:
            abort(500, "Refuse adding radargram")
    else:
        return jsonify(
            {"Error": f"There is no project with project_id={project_id}"})