Definition at line 356 of file TriggerConfigAccessBase.py.
◆ __init__()
| def python.TriggerConfigAccessBase.ConfigCrestLoader.__init__ |
( |
|
self, |
|
|
*ConfigType |
configType, |
|
|
str |
dbname, |
|
|
int |
dbkey, |
|
|
str |
crestServer |
|
) |
| |
Definition at line 357 of file TriggerConfigAccessBase.py.
357 def __init__(self, *, configType: ConfigType, dbname: str, dbkey: int, crestServer: str):
359 self.crestServer = crestServer
◆ _get_payload()
| dict python.TriggerConfigAccessBase.ConfigCrestLoader._get_payload |
( |
|
self, |
|
|
str |
hash |
|
) |
| |
|
private |
get payload from crest server using request library
Args:
hash (str): the query part of the url as required by the REST api
Raises:
RuntimeError: when connection or query failed
Returns:
dict: the json content
Definition at line 370 of file TriggerConfigAccessBase.py.
370 def _get_payload(self, hash: str) -> dict:
371 """get payload from crest server using request library
374 hash (str): the query part of the url as required by the REST api
377 RuntimeError: when connection or query failed
380 dict: the json content
384 url = f
"{self.crestServer}/payloads/data"
389 preq = requests.Request(method=
'GET', url=url, params=params).prepare()
390 with requests.Session()
as session:
392 resp = session.send(preq)
393 except requests.ConnectionError
as exc:
394 log.error(f
"Could not connect to crest server {self.crestServer} ({exc})")
395 raise RuntimeError(f
"Could not connect to CREST server {self.crestServer}")
397 if resp.status_code != 200:
398 log.error(f
"Error: HTTP GET request '{preq.url}' failed")
399 raise RuntimeError(f
"Query {hash} to crest failed with status code {resp.status_code}")
401 config = json.loads(resp.content)
402 self.confirmConfigType(config)
◆ confirmConfigType()
| def python.TriggerConfigAccessBase.ConfigLoader.confirmConfigType |
( |
|
self, |
|
|
|
config |
|
) |
| |
|
inherited |
checks that the in-file specification of the configuration type matches the expected type
Definition at line 51 of file TriggerConfigAccessBase.py.
51 def confirmConfigType(self,config):
53 checks that the in-file specification of the configuration type matches the expected type
55 if config[
'filetype'] != self.configType:
56 raise RuntimeError(
"Can not load file with filetype '%s' when expecting '%s'" % (config[
'filetype'], self.configType.filetype))
◆ getWriteFilename()
| def python.TriggerConfigAccessBase.ConfigCrestLoader.getWriteFilename |
( |
|
self | ) |
|
◆ load()
| dict[str, Any] python.TriggerConfigAccessBase.ConfigCrestLoader.load |
( |
|
self | ) |
|
Reimplemented from python.TriggerConfigAccessBase.ConfigLoader.
Definition at line 405 of file TriggerConfigAccessBase.py.
405 def load(self) -> dict[str, Any]:
407 crest_conn = TriggerCrestUtil.getCrestConnection(self.dbname)
408 if crest_conn
is None:
409 raise RuntimeError(f
"Cannot resolve CREST connection for dbname {self.dbname}")
410 hash = f
"triggerdb://{crest_conn}/{self.configType.crestkey}/{self.dbkey}"
411 config = self._get_payload(hash=hash)
◆ setQuery()
| def python.TriggerConfigAccessBase.ConfigCrestLoader.setQuery |
( |
|
self, |
|
|
|
query |
|
) |
| |
◆ crestServer
| python.TriggerConfigAccessBase.ConfigCrestLoader.crestServer |
◆ dbkey
| python.TriggerConfigAccessBase.ConfigCrestLoader.dbkey |
◆ dbname
| python.TriggerConfigAccessBase.ConfigCrestLoader.dbname |
◆ schema
| python.TriggerConfigAccessBase.ConfigCrestLoader.schema |
The documentation for this class was generated from the following file: