1 import urllib2, re, json, socket
4 URL =
"http://vocms00170:2113"
13 r.RUN_GLOBAL = 0 and \
14 (r.runnumber >= :rf or :rf = 0) and \
15 (r.runnumber <= :rt or :rt = 0) \
19 TIME =
"select to_char(p.time,'YYYY-MM-DD HH24:MI:SS') time from hcal.run_parameters p where p.name like '%TRIGGERS'"
22 resp = urllib2.urlopen(URL +
"/query", query)
23 if "getcode" in dir(resp)
and resp.getcode() == 200:
28 for k
in qstring.keys():
29 ps +=
"&" if ps !=
"" else ""
30 ps +=
"%s=%s" % (k, qstring[k])
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]
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:
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"])
65 if rf !=
None: ps[
"rf"] = rf
66 if rt !=
None: ps[
"rt"] = rt
70 for t
in [
"pedestal",
"LED",
"laser"]:
71 if re.search(t, r[3], flags=re.IGNORECASE) !=
None:
75 print r[0], t, d, r[2]
79 if __name__ ==
'__main__':
81 rf = sys.argv[1]
if len(sys.argv) > 1
else "-"
82 rt = sys.argv[2]
if len(sys.argv) > 2
else "-"
83 rf = int(rf)
if rf.isdigit()
else 0
84 rt = int(rt)
if rt.isdigit()
else 0