CMS 3D CMS Logo

Functions | Variables
hcal_runs_valdas Namespace Reference

Functions

def get_all (q, qs)
 
def get_single (q, qs)
 
def main (rf, rt)
 
def qstring (qstring)
 
def query (query)
 

Variables

 rf
 
 rt
 
 SQL
 
 TIME
 
 URL
 

Function Documentation

◆ get_all()

def hcal_runs_valdas.get_all (   q,
  qs 
)

Definition at line 42 of file hcal_runs_valdas.py.

References DeadROC_duringRun.dir, createfilelist.int, and qstring().

Referenced by main().

42 def get_all(q, qs):
43  qid = query(q)
44  ps = qstring(qs)
45  u = "%s/query/%s/count?%s" % (URL, qid, ps)
46  resp = urllib2.urlopen(u)
47  if "getcode" in dir(resp) and resp.getcode() == 200:
48  data = []
49  c = int(resp.read())
50  p = 1
51  while c > 0:
52  u = "%s/query/%s/page/1000/%d/data?%s" % (URL, qid, p, ps)
53  req = urllib2.Request(u, headers={"Accept" : "application/json"})
54  resp = urllib2.urlopen(req)
55  if "getcode" in dir(resp) and resp.getcode() == 200:
56  j = json.loads(resp.read())
57  data.extend(j["data"])
58  p += 1
59  c -= 1000
60  return data
61  return None
62 
def qstring(qstring)
Definition: query.py:1

◆ get_single()

def hcal_runs_valdas.get_single (   q,
  qs 
)

Definition at line 33 of file hcal_runs_valdas.py.

References DeadROC_duringRun.dir, and qstring().

Referenced by main().

33 def get_single(q, qs):
34  req = urllib2.Request("%s/query/%s/data?%s" % (URL, query(q), qstring(qs)), headers={"Accept" : "application/json"})
35  resp = urllib2.urlopen(req)
36  if "getcode" in dir(resp) and resp.getcode() == 200:
37  ret = json.loads(resp.read())
38  if len(ret["data"]) > 0:
39  return ret["data"][0][0]
40  return None
41 
def qstring(qstring)
def get_single(q, qs)
Definition: query.py:1

◆ main()

def hcal_runs_valdas.main (   rf,
  rt 
)

Definition at line 63 of file hcal_runs_valdas.py.

References get_all(), get_single(), createfilelist.int, and print().

63 def main(rf, rt):
64  ps = {}
65  if rf != None: ps["rf"] = rf
66  if rt != None: ps["rt"] = rt
67  data = get_all(SQL, ps)
68  for r in data:
69  if r[3] != None:
70  for t in ["pedestal","LED","laser"]:
71  if re.search(t, r[3], flags=re.IGNORECASE) != None:
72  d = get_single(TIME, { "p.run": int(r[0])})
73  if d is not None:
74  d = "\"" + d + "\""
75  print(r[0], t, d, r[2])
76  break
77 
78 
def get_single(q, qs)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ qstring()

def hcal_runs_valdas.qstring (   qstring)

Definition at line 26 of file hcal_runs_valdas.py.

Referenced by get_all(), and get_single().

26 def qstring(qstring):
27  ps = ""
28  for k in qstring.keys():
29  ps += "&" if ps != "" else ""
30  ps += "%s=%s" % (k, qstring[k])
31  return ps
32 
def qstring(qstring)

◆ query()

def hcal_runs_valdas.query (   query)

Definition at line 21 of file hcal_runs_valdas.py.

References DeadROC_duringRun.dir.

21 def query(query):
22  resp = urllib2.urlopen(URL + "/query", query)
23  if "getcode" in dir(resp) and resp.getcode() == 200:
24  return resp.read()
25 

Variable Documentation

◆ rf

hcal_runs_valdas.rf

Definition at line 81 of file hcal_runs_valdas.py.

◆ rt

hcal_runs_valdas.rt

Definition at line 82 of file hcal_runs_valdas.py.

◆ SQL

hcal_runs_valdas.SQL

Definition at line 5 of file hcal_runs_valdas.py.

◆ TIME

hcal_runs_valdas.TIME

Definition at line 19 of file hcal_runs_valdas.py.

◆ URL

hcal_runs_valdas.URL

Definition at line 4 of file hcal_runs_valdas.py.