ATLAS Offline Software
Loading...
Searching...
No Matches
python.TrigConfFrontier Namespace Reference

Classes

class  FrontierCursor

Functions

 getServerUrls (frontier_servers)
 resolveUrl (url)
 getFrontierCursor (urls, schema, loglevel=logging.INFO)
 replacebindvars (query, bindvars)
 testQuery (query, bindvars)

Variables

 log = logging.getLogger( "TrigConfFrontier.py" )
str dbalias = "TRIGGERDBMC"
str query = "select distinct HPS.HPS_NAME from ATLAS_CONF_TRIGGER_RUN2_MC.HLT_PRESCALE_SET HPS where HPS.HPS_ID = :psk"
dict bindvars = { "psk": 260 }
 res = testQuery(query, bindvars)

Function Documentation

◆ getFrontierCursor()

python.TrigConfFrontier.getFrontierCursor ( urls,
schema,
loglevel = logging.INFO )

Definition at line 33 of file TrigConfFrontier.py.

33def getFrontierCursor(urls, schema, loglevel = logging.INFO):
34 log.setLevel(loglevel)
35 url_list = resolveUrl(urls)
36 if len(url_list) == 0:
37 log.warning("Cannot find a valid frontier connection, will not return a Frontier cursor")
38 return None
39 else:
40 log.info(f"Will use Frontier server at {urls}")
41
42 return FrontierCursor( urls = url_list, schema = schema)
43
44
45# used by FrontierCursor

◆ getServerUrls()

python.TrigConfFrontier.getServerUrls ( frontier_servers)
turns
'(serverurl=http://atlasfrontier-local.cern.ch:8000/atlr)(serverurl=http://atlasfrontier-ai.cern.ch:8000/atlr)'
into
['http://atlasfrontier-local.cern.ch:8000/atlr','http://atlasfrontier-ai.cern.ch:8000/atlr']

Definition at line 10 of file TrigConfFrontier.py.

10def getServerUrls(frontier_servers):
11 """
12 turns
13 '(serverurl=http://atlasfrontier-local.cern.ch:8000/atlr)(serverurl=http://atlasfrontier-ai.cern.ch:8000/atlr)'
14 into
15 ['http://atlasfrontier-local.cern.ch:8000/atlr','http://atlasfrontier-ai.cern.ch:8000/atlr']
16 """
17 from re import findall
18 return findall(r'\‍(serverurl=(.*?)\‍)',frontier_servers)
19
20

◆ replacebindvars()

python.TrigConfFrontier.replacebindvars ( query,
bindvars )
Replaces the bound variables with the specified values,
disables variable binding

Definition at line 46 of file TrigConfFrontier.py.

46def replacebindvars(query, bindvars):
47 """Replaces the bound variables with the specified values,
48 disables variable binding
49 """
50 for var,val in list(bindvars.items()):
51 if query.find(":%s" % var)<0:
52 raise NameError("variable '%s' is not a bound variable in this query: %s" % (var, query) )
53 if isinstance (val, int):
54 query = query.replace(":%s" % var,"%s" % val)
55 else:
56 query = query.replace(":%s" % var,"%r" % val)
57 log.debug("Resolving bound variable '%s' with %r", var,val)
58 log.debug("Resolved query: %s", query)
59 return query
60
61

◆ resolveUrl()

python.TrigConfFrontier.resolveUrl ( url)
Expects input string to be a URL or $FRONTIER_SERVER
Returns an accessible URL or None

Definition at line 21 of file TrigConfFrontier.py.

21def resolveUrl(url):
22 """
23 Expects input string to be a URL or $FRONTIER_SERVER
24 Returns an accessible URL or None"""
25 import re
26 if re.match("http://",url): # simple URL specification http://...
27 return [url]
28
29 if re.match(r'\‍(serverurl=(.*?)\‍)',url): # syntax of FRONTIER_SERVER
30 return getServerUrls(url)
31
32

◆ testQuery()

python.TrigConfFrontier.testQuery ( query,
bindvars )

Definition at line 228 of file TrigConfFrontier.py.

228def testQuery(query, bindvars):
229 from TrigConfigSvc.TrigConfigSvcUtils import interpretConnection
230 connectionParameters = interpretConnection("TRIGGERDBMC")
231 cursor = getFrontierCursor( urls = connectionParameters['url'], schema = connectionParameters['schema'])
232 cursor.execute(query, bindvars)
233 log.info("Raw response:")
234 log.info(cursor.result)
235 cursor.decodeResult()
236 log.info("Decoded response:")
237 log.info(cursor.result[0][0])
238 if cursor.result[0][0] != 'MC_pp_v7':
239 return 1
240 return 0
241
242

Variable Documentation

◆ bindvars

dict python.TrigConfFrontier.bindvars = { "psk": 260 }

Definition at line 249 of file TrigConfFrontier.py.

◆ dbalias

str python.TrigConfFrontier.dbalias = "TRIGGERDBMC"

Definition at line 247 of file TrigConfFrontier.py.

◆ log

python.TrigConfFrontier.log = logging.getLogger( "TrigConfFrontier.py" )

Definition at line 8 of file TrigConfFrontier.py.

◆ query

str python.TrigConfFrontier.query = "select distinct HPS.HPS_NAME from ATLAS_CONF_TRIGGER_RUN2_MC.HLT_PRESCALE_SET HPS where HPS.HPS_ID = :psk"

Definition at line 248 of file TrigConfFrontier.py.

◆ res

python.TrigConfFrontier.res = testQuery(query, bindvars)

Definition at line 251 of file TrigConfFrontier.py.