예제 #1
0
파일: server.py 프로젝트: pir8aye/sirepo
def api_simulationFrame(frame_id):
    #TODO(robnagler) startTime is reportParametersHash; need version on URL and/or param names in URL
    keys = [
        'simulationType', 'simulationId', 'modelName', 'animationArgs',
        'frameIndex', 'startTime'
    ]
    data = dict(zip(keys, frame_id.split('*')))
    template = sirepo.template.import_module(data)
    data['report'] = template.get_animation_name(data)
    run_dir = simulation_db.simulation_run_dir(data)
    model_data = simulation_db.read_json(
        run_dir.join(template_common.INPUT_BASE_NAME))
    frame = template.get_simulation_frame(run_dir, data, model_data)
    response = _json_response(frame)
    if 'error' not in frame and template.WANT_BROWSER_FRAME_CACHE:
        now = datetime.datetime.utcnow()
        expires = now + datetime.timedelta(365)
        response.headers['Cache-Control'] = 'public, max-age=31536000'
        response.headers['Expires'] = expires.strftime(
            "%a, %d %b %Y %H:%M:%S GMT")
        response.headers['Last-Modified'] = now.strftime(
            "%a, %d %b %Y %H:%M:%S GMT")
    else:
        _no_cache(response)
    return response
예제 #2
0
def api_simulationFrame(frame_id):
    #TODO(robnagler) startTime is reportParametersHash; need version on URL and/or param names in URL
    keys = ['simulationType', 'simulationId', 'modelName', 'animationArgs', 'frameIndex', 'startTime']
    data = dict(zip(keys, frame_id.split('*')))
    template = sirepo.template.import_module(data)
    data['report'] = template.get_animation_name(data)
    run_dir = simulation_db.simulation_run_dir(data)
    model_data = simulation_db.read_json(run_dir.join(template_common.INPUT_BASE_NAME))
    if feature_config.cfg.runner_daemon:
        # XX TODO: it would be better if the frontend passed the jhash to this
        # call. Since it doesn't, we have to read it out of the run_dir, which
        # creates a race condition -- we might return a frame from a different
        # version of the report than the one the frontend expects.
        jhash = template_common.report_parameters_hash(model_data)
        frame = runner_client.run_extract_job(
            run_dir, jhash, 'get_simulation_frame', data,
        )
    else:
        frame = template.get_simulation_frame(run_dir, data, model_data)
    resp = http_reply.gen_json(frame)
    if 'error' not in frame and template.WANT_BROWSER_FRAME_CACHE:
        now = datetime.datetime.utcnow()
        expires = now + datetime.timedelta(365)
        resp.headers['Cache-Control'] = 'public, max-age=31536000'
        resp.headers['Expires'] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
        resp.headers['Last-Modified'] = now.strftime("%a, %d %b %Y %H:%M:%S GMT")
    else:
        _no_cache(resp)
    return resp
예제 #3
0
def app_simulation_frame(frame_id):
    keys = ['simulationType', 'simulationId', 'modelName', 'animationArgs', 'frameIndex', 'startTime']
    data = dict(zip(keys, frame_id.split('-')))
    run_dir = simulation_db.simulation_run_dir(data)
    template = sirepo.template.import_module(data['simulationType'])
    response = flask.jsonify(template.get_simulation_frame(run_dir, data))

    if template.WANT_BROWSER_FRAME_CACHE:
        now = datetime.datetime.utcnow()
        expires = now + datetime.timedelta(365)
        response.headers['Cache-Control'] = 'public, max-age=31536000'
        response.headers['Expires'] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
        response.headers['Last-Modified'] = now.strftime("%a, %d %b %Y %H:%M:%S GMT")
    else:
        _no_cache(response)
    return response
예제 #4
0
파일: server.py 프로젝트: mrakitin/sirepo
def app_simulation_frame(frame_id):
    #TODO(robnagler) startTime is reportParametersHash; need version on URL and/or param names in URL
    keys = ['simulationType', 'simulationId', 'modelName', 'animationArgs', 'frameIndex', 'startTime']
    data = dict(zip(keys, frame_id.split('*')))
    template = sirepo.template.import_module(data)
    data['report'] = template.get_animation_name(data)
    run_dir = simulation_db.simulation_run_dir(data)
    model_data = simulation_db.read_json(run_dir.join(template_common.INPUT_BASE_NAME))
    response = _json_response(template.get_simulation_frame(run_dir, data, model_data))

    if template.WANT_BROWSER_FRAME_CACHE:
        now = datetime.datetime.utcnow()
        expires = now + datetime.timedelta(365)
        response.headers['Cache-Control'] = 'public, max-age=31536000'
        response.headers['Expires'] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
        response.headers['Last-Modified'] = now.strftime("%a, %d %b %Y %H:%M:%S GMT")
    else:
        _no_cache(response)
    return response
예제 #5
0
def app_simulation_frame(frame_id):
    keys = [
        'simulationType', 'simulationId', 'modelName', 'animationArgs',
        'frameIndex', 'startTime'
    ]
    data = dict(zip(keys, frame_id.split('-')))
    run_dir = simulation_db.simulation_run_dir(data)
    template = sirepo.template.import_module(data['simulationType'])
    response = flask.jsonify(template.get_simulation_frame(run_dir, data))

    if template.WANT_BROWSER_FRAME_CACHE:
        now = datetime.datetime.utcnow()
        expires = now + datetime.timedelta(365)
        response.headers['Cache-Control'] = 'public, max-age=31536000'
        response.headers['Expires'] = expires.strftime(
            "%a, %d %b %Y %H:%M:%S GMT")
        response.headers['Last-Modified'] = now.strftime(
            "%a, %d %b %Y %H:%M:%S GMT")
    else:
        _no_cache(response)
    return response