Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'aspectRatio',
'colorMap',
'copyCharacteristic',
'intensityPlotsWidth',
'notes',
'plotAxisX',
'plotAxisY',
'plotAxisY2',
'plotScale',
'rotateAngle',
'rotateReshape',
))
SRW_RUN_ALL_MODEL = 'simulation'
__EXAMPLE_FOLDERS = PKDict({
'Bending Magnet Radiation': '/SR Calculator',
'Diffraction by an Aperture': '/Wavefront Propagation',
'Ellipsoidal Undulator Example': '/Examples',
'Focusing Bending Magnet Radiation': '/Examples',
'Gaussian X-ray Beam Through Perfect CRL': '/Examples',
'Gaussian X-ray beam through a Beamline containing Imperfect Mirrors': '/Examples',
'Idealized Free Electron Laser Pulse': '/SR Calculator',
'LCLS SXR beamline - Simplified': '/Light Source Facilities/LCLS',
'LCLS SXR beamline': '/Light Source Facilities/LCLS',
'NSLS-II CHX beamline': '/Light Source Facilities/NSLS-II/NSLS-II CHX beamline',
'Polarization of Bending Magnet Radiation': '/Examples',
'Soft X-Ray Undulator Radiation Containing VLS Grating': '/Examples',
'Tabulated Undulator Example': '/Examples',
'Undulator Radiation': '/SR Calculator',
'Young\'s Double Slit Experiment (green laser)': '/Wavefront Propagation',
'Young\'s Double Slit Experiment (green laser, no lens)': '/Wavefront Propagation',
def __init__(self, uri, *args, **kwargs):
super(Redirect, self).__init__(
PKDict(uri=uri),
*args,
**kwargs
)
elements.append(PKDict(
name=name,
type='NLLENS',
extractor_type=model.extractor_type,
knll=nli.knll[idx],
cnll=nli.cnll[idx],
_id=0,
))
names.append(name)
names.append(d2.name)
names = names[:-1]
names.append(d1.name)
id_map[model._id].name = ','.join(names)
return LatticeUtil(
PKDict(
models=PKDict(
elements=elements,
beamlines=[],
),
),
_SCHEMA,
).iterate_models(
SynergiaLatticeIterator(_format_field_value),
'elements',
).result
def get_application_data(data, **kwargs):
if data['method'] == 'column_info':
data = PKDict(
models=PKDict(
analysisData=data['analysisData'],
),
)
return PKDict(
columnInfo=_column_info(
str(_SIM_DATA.lib_file_abspath(_analysis_data_path(data))),
),
)
if data['method'] == 'update_kicker':
return _update_epics_kicker(data)
if data['method'] == 'read_kickers':
return _read_epics_kickers(data)
if data['method'] == 'enable_steering':
return _enable_steering(data)
assert False, 'unknown application_data method: {}'.format(data['method'])
def test_in_request(op, cfg=None, before_request=None, headers=None, want_cookie=True, want_user=True, **kwargs):
fc = flask_client(cfg, **kwargs)
try:
from pykern import pkunit
from pykern import pkcollections
if before_request:
before_request(fc)
setattr(
server._app,
server.SRUNIT_TEST_IN_REQUEST,
PKDict(op=op, want_cookie=want_cookie, want_user=want_user),
)
from sirepo import uri_router
r = fc.get(
uri_router.srunit_uri,
headers=headers,
)
pkunit.pkeq(200, r.status_code, 'FAIL: status={}', r.status)
if r.mimetype == 'text/html':
m = _JAVASCRIPT_REDIRECT_RE.search(r.data)
if m:
pkunit.pkfail('redirect={}', m.group(1))
pkunit.pkfail('other html response={}', r.data)
d = pkcollections.json_load_any(r.data)
pkunit.pkeq('ok', d.get('state'), 'FAIL: data={}', d)
finally:
try:
sim_name (str): case sensitive name ['Scooby Doo']
sim_type (str): app ['myapp']
Returns:
dict: data
"""
from pykern import pkunit
from pykern.pkdebug import pkdpretty
self.sr_sim_type_set(sim_type)
if not sim_name:
sim_name = 'Scooby Doo'
d = self.sr_post(
'listSimulations',
PKDict(
simulationType=self.sr_sim_type,
search=PKDict({'simulation.name': sim_name}),
)
)
assert 1 == len(d), \
'listSimulations name={} returned count={}'.format(sim_name, len(d))
d = d[0].simulation
res = self.sr_get_json(
'simulationData',
PKDict(
simulation_type=self.sr_sim_type,
pretty='0',
simulation_id=d.simulationId,
),
)
pkunit.pkeq(sim_name, res.models.simulation.name)
def api_authBlueskyLogin():
req = sirepo.http_request.parse_post(id=True)
auth_hash(req.req_data, verify=True)
path = simulation_db.find_global_simulation(
req.type,
req.id,
checked=True,
)
sirepo.auth.login(
this_module,
uid=simulation_db.uid_from_dir_name(path),
# do not supply sim_type (see auth.login)
)
return sirepo.http_reply.gen_json_ok(
PKDict(
data=simulation_db.open_json_file(req.type, sid=req.id),
schema=simulation_db.get_schema(req.type),
),
def login_fail_redirect(sim_type=None, module=None, reason=None, reload_js=False):
raise util.SRException(
'loginFail',
PKDict(
method=module.AUTH_METHOD,
reason=reason,
reload_js=reload_js,
sim_type=sim_type,
),
'login failed: reason={} method={}',
reason,
module.AUTH_METHOD,
)
dm,
(
'beamEvolutionAnimation',
'bunch',
'bunchAnimation',
'bunchTwiss',
'simulationSettings',
'turnComparisonAnimation',
'twissReport',
'twissReport2',
),
)
if 'bunchReport' in dm:
del dm['bunchReport']
for i in range(1, 5):
m = dm['bunchReport{}'.format(i)] = PKDict()
cls.update_model_defaults(m, 'bunchReport')
if i == 1:
m.y = 'xp'
elif i == 2:
m.x = 'y'
m.y = 'yp'
elif i == 4:
m.x = 'z'
m.y = 'zp'
cls._organize_example(data)