updateRunHistoryTables.py
Go to the documentation of this file.
1 import sys
2 import os
3 import psycopg2
4 
5 det=sys.argv[1]
6 part=sys.argv[2]
7 minrun=sys.argv[3]
8 
9 if det == 'FarDet':
10  try:
11  conn = psycopg2.connect("dbname=nova_prod host=novadaq-far-db-01.fnal.gov user=novadaq port=5432")
12  except:
13  print "I am unable to connect to the database"
14  exit(0)
15 elif (det == 'NearDet') or (det =="TestBeam"):
16  try:
17  conn = psycopg2.connect("dbname=nova_prod host=novadaq-near-db-03.fnal.gov user=novadaq port=5432")
18  except:
19  print "I am unable to connect to the database"
20  exit(0)
21 
22 cur = conn.cursor()
23 
24 SQL = "select run from {}.runs where run>{} and tstop is NULL and partition={} and tstart>now()-interval '7 day' order by run desc".format(det,minrun,part)
25 
26 #if det == 'FarDet':
27 # SQL = "select run from {}.runs where run>{} and tstop is NULL and partition={} and tstart<now()-interval '6 hour' order by run desc".format(det,minrun,part)
28 
29 cur.execute(SQL)
30 
31 rows = cur.fetchall()
32 
33 isFirst = True
34 
35 for row in rows:
36  if isFirst:
37  isFirst = False
38  print "Skipping most recent run: ", row[0]
39  else:
40  run = row[0]
41  cmd = "updateRunHistoryTables -d {} {}".format(det,run)
42  print cmd
43  os.system(cmd)
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
exit(0)