ATLAS Offline Software
Classes | Functions | Variables
python.TrigConfFrontier Namespace Reference

Classes

class  FrontierCursor
 

Functions

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

Variables

 log
 
 dbalias
 
 query
 
 bindvars
 
 res
 

Function Documentation

◆ getFrontierCursor()

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

Definition at line 33 of file TrigConfFrontier.py.

33 def 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()

def 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.

10 def 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()

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

Definition at line 46 of file TrigConfFrontier.py.

46 def 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()

def 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.

21 def 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()

def python.TrigConfFrontier.testQuery (   query,
  bindvars 
)

Definition at line 228 of file TrigConfFrontier.py.

228 def 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

python.TrigConfFrontier.bindvars

Definition at line 249 of file TrigConfFrontier.py.

◆ dbalias

python.TrigConfFrontier.dbalias

Definition at line 247 of file TrigConfFrontier.py.

◆ log

python.TrigConfFrontier.log

Definition at line 8 of file TrigConfFrontier.py.

◆ query

python.TrigConfFrontier.query

Definition at line 248 of file TrigConfFrontier.py.

◆ res

python.TrigConfFrontier.res

Definition at line 251 of file TrigConfFrontier.py.

python.TrigConfFrontier.testQuery
def testQuery(query, bindvars)
Definition: TrigConfFrontier.py:228
python.TrigConfFrontier.getServerUrls
def getServerUrls(frontier_servers)
Definition: TrigConfFrontier.py:10
python.TrigConfFrontier.getFrontierCursor
def getFrontierCursor(urls, schema, loglevel=logging.INFO)
Definition: TrigConfFrontier.py:33
python.utils.AtlRunQueryTriggerUtils.interpretConnection
def interpretConnection(connection, debug=False, resolveAlias=True)
Definition: AtlRunQueryTriggerUtils.py:230
python.TrigConfFrontier.resolveUrl
def resolveUrl(url)
Definition: TrigConfFrontier.py:21
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.TrigConfFrontier.replacebindvars
def replacebindvars(query, bindvars)
Definition: TrigConfFrontier.py:46