CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
hcal_runs_valdas Namespace Reference

Functions

def get_all
 
def get_single
 
def main
 
def qstring
 
def query
 

Variables

list rf = sys.argv[1]
 
list rt = sys.argv[2]
 
string SQL
 
string TIME = "select to_char(p.time,'YYYY-MM-DD HH24:MI:SS') time from hcal.run_parameters p where p.name like '%TRIGGERS'"
 
string URL = "http://vocms00170:2113"
 

Function Documentation

def hcal_runs_valdas.get_all (   q,
  qs 
)

Definition at line 42 of file hcal_runs_valdas.py.

References DeadROC_duringRun.dir, and qstring().

Referenced by main().

42 
43 def get_all(q, qs):
44  qid = query(q)
45  ps = qstring(qs)
46  u = "%s/query/%s/count?%s" % (URL, qid, ps)
47  resp = urllib2.urlopen(u)
48  if "getcode" in dir(resp) and resp.getcode() == 200:
49  data = []
50  c = int(resp.read())
51  p = 1
52  while c > 0:
53  u = "%s/query/%s/page/1000/%d/data?%s" % (URL, qid, p, ps)
54  req = urllib2.Request(u, headers={"Accept" : "application/json"})
55  resp = urllib2.urlopen(req)
56  if "getcode" in dir(resp) and resp.getcode() == 200:
57  j = json.loads(resp.read())
58  data.extend(j["data"])
59  p += 1
60  c -= 1000
61  return data
62  return None
Definition: query.py:1
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 
34 def get_single(q, qs):
35  req = urllib2.Request("%s/query/%s/data?%s" % (URL, query(q), qstring(qs)), headers={"Accept" : "application/json"})
36  resp = urllib2.urlopen(req)
37  if "getcode" in dir(resp) and resp.getcode() == 200:
38  ret = json.loads(resp.read())
39  if len(ret["data"]) > 0:
40  return ret["data"][0][0]
41  return None
Definition: query.py:1
def hcal_runs_valdas.main (   rf,
  rt 
)

Definition at line 63 of file hcal_runs_valdas.py.

References get_all(), and get_single().

63 
64 def main(rf, rt):
65  ps = {}
66  if rf != None: ps["rf"] = rf
67  if rt != None: ps["rt"] = rt
68  data = get_all(SQL, ps)
69  for r in data:
70  if r[3] != None:
71  for t in ["pedestal","LED","laser"]:
72  if re.search(t, r[3], flags=re.IGNORECASE) != None:
73  d = get_single(TIME, { "p.run": int(r[0])})
74  if d is not None:
75  d = "\"" + d + "\""
76  print r[0], t, d, r[2]
77  break
78 
def hcal_runs_valdas.qstring (   qstring)

Definition at line 26 of file hcal_runs_valdas.py.

Referenced by get_all(), and get_single().

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

Definition at line 21 of file hcal_runs_valdas.py.

References DeadROC_duringRun.dir.

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

Variable Documentation

tuple hcal_runs_valdas.rf = sys.argv[1]

Definition at line 81 of file hcal_runs_valdas.py.

tuple hcal_runs_valdas.rt = sys.argv[2]

Definition at line 82 of file hcal_runs_valdas.py.

string hcal_runs_valdas.SQL
Initial value:
1 = "select \
2  r.RUNNUMBER,\
3  r.START_TIME,\
4  r.RUN_TRIGGERS,\
5  r.RUN_TYPE\
6  from \
7  hcal.runs r \
8  where \
9  r.RUN_GLOBAL = 0 and \
10  (r.runnumber >= :rf or :rf = 0) and \
11  (r.runnumber <= :rt or :rt = 0) \
12  order by \
13  r.runnumber"

Definition at line 5 of file hcal_runs_valdas.py.

string hcal_runs_valdas.TIME = "select to_char(p.time,'YYYY-MM-DD HH24:MI:SS') time from hcal.run_parameters p where p.name like '%TRIGGERS'"

Definition at line 19 of file hcal_runs_valdas.py.

string hcal_runs_valdas.URL = "http://vocms00170:2113"

Definition at line 4 of file hcal_runs_valdas.py.