示例#1
0
文件: server.py 项目: yeeon/sirepo
def api_copyNonSessionSimulation():
    req = http_request.parse_json()
    sim_type = req['simulationType']
    src = py.path.local(
        simulation_db.find_global_simulation(
            sim_type,
            req['simulationId'],
            checked=True,
        ))
    data = simulation_db.open_json_file(
        sim_type,
        src.join(simulation_db.SIMULATION_DATA_FILE),
    )
    if 'report' in data:
        del data['report']
    data['models']['simulation']['isExample'] = False
    data['models']['simulation']['outOfSessionSimulationId'] = req[
        'simulationId']
    res = _save_new_and_reply(data)
    target = simulation_db.simulation_dir(sim_type,
                                          simulation_db.parse_sid(data))
    template_common.copy_lib_files(
        data,
        simulation_db.lib_dir_from_sim_dir(src),
        simulation_db.lib_dir_from_sim_dir(target),
    )
    template = sirepo.template.import_module(data)
    if hasattr(template, 'copy_related_files'):
        template.copy_related_files(data, str(src), str(target))
    return res
示例#2
0
文件: server.py 项目: pir8aye/sirepo
def api_copyNonSessionSimulation():
    req = _json_input()
    sim_type = req['simulationType']
    global_path = simulation_db.find_global_simulation(sim_type,
                                                       req['simulationId'])
    if global_path:
        data = simulation_db.open_json_file(
            sim_type,
            os.path.join(global_path, simulation_db.SIMULATION_DATA_FILE),
        )
        data['models']['simulation']['isExample'] = False
        data['models']['simulation']['outOfSessionSimulationId'] = req[
            'simulationId']
        res = _save_new_and_reply(data)
        target = simulation_db.simulation_dir(sim_type,
                                              simulation_db.parse_sid(data))
        template_common.copy_lib_files(
            data,
            py.path.local(os.path.dirname(global_path)).join('lib'),
            target.join('../lib'),
        )
        template = sirepo.template.import_module(data)
        if hasattr(template, 'copy_related_files'):
            template.copy_related_files(data, global_path, str(target))
        return res
    werkzeug.exceptions.abort(404)