1 import urllib2, re, simplejson
as json, socket
4 URL =
"http://vocms00169: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 resp = urllib2.urlopen(
"%s/query/%s/data?%s" % (URL,
query(q),
qstring(qs)))
35 if "getcode" in dir(resp)
and resp.getcode() == 200:
36 return json.loads(resp.read())[
"data"][0][0]
42 u =
"%s/query/%s/count?%s" % (URL, qid, ps)
43 resp = urllib2.urlopen(u)
44 if "getcode" in dir(resp)
and resp.getcode() == 200:
49 u =
"%s/query/%s/page/1000/%d/data?%s" % (URL, qid, p, ps)
50 resp = urllib2.urlopen(u)
51 if "getcode" in dir(resp)
and resp.getcode() == 200:
52 j = json.loads(resp.read())
53 data.extend(j[
"data"])
61 if rf !=
None: ps[
"rf"] = rf
62 if rt !=
None: ps[
"rt"] = rt
66 for t
in [
"pedestal",
"LED",
"laser"]:
67 if re.search(t, r[3], flags=re.IGNORECASE) !=
None:
69 print r[0], t,
"\"" + d +
"\"", r[2]
73 if __name__ ==
'__main__':
75 rf = sys.argv[1]
if len(sys.argv) > 1
else "-"
76 rt = sys.argv[2]
if len(sys.argv) > 2
else "-"
77 rf = int(rf)
if rf.isdigit()
else 0
78 rt = int(rt)
if rt.isdigit()
else 0