1 from ROOT
import TSQLServer, TSQLStatement
2 from datetime
import timedelta, date
14 resultpath =
'/home/nearline/jancode/results/' 17 dbpswfile = os.environ.get(
'NOVADBPWDFILE')
19 pfile =
open(dbpswfile,
'r') 26 week = timedelta(weeks=1)
27 day = timedelta(days=1)
33 query =
'select run, min(firstnonemptyeventtime), max(lastnonemptyeventtime) from ndos.nearline_metrics ' 34 query+=
"where triggertype = 2 and softwarerelease = '"+rel+
"' and firstnonemptyeventtime > TIMESTAMP'"+
str(date2)+
"' " 35 query+=
"and lastnonemptyeventtime <= TIMESTAMP'"+
str(date1+day)+
"' and firstnonemptyeventtime > TIMESTAMP'2010-01-01' " 36 query+=
"and lastnonemptyeventtime >= firstnonemptyeventtime " 37 query+=
"group by run order by run;" 40 db= TSQLServer.Connect(
"pgsql://ifdbprod.fnal.gov:5433/nova_prod",
"nova_reader", dbpsw)
42 print "Cannot connect to database" 45 stmt = db.Statement(query,1000)
50 while stmt.NextResultRow():
51 run = stmt.GetString(0)
52 start = stmt.GetDay(1)
54 starttime=time.mktime(time.strptime(stmt.GetString(1),
"%Y-%m-%d %H:%M:%S"))
55 endtime =time.mktime(time.strptime(stmt.GetString(2),
"%Y-%m-%d %H:%M:%S"))
59 elif starttime-prevend<2:
62 print "Problem with Statement" 72 path =
'/home/nearline/Nearline/Commissioning/FEBShutoff/febshutoff_auto.py' 76 print run,
"Processing" 77 endid = subprocess.call([
"python",path,run])
78 if endid == 0:
continue 80 failures+=run+
' has not been processed\n' 82 failures+=run+
' has no reco files\n' 84 failures+=run+
' failed to connect to the database\n' 86 failures+=run+
' problem with database query\n' 88 failures+=run+
' failed to connect to hardware database\n' 90 failures+=run+
' problem with hardware database query\n' 92 failures+=run+
' dcm name in hdb out of range\n' 94 failures+=run+
' coating in hdb out of range\n' 96 failures+=run+
' failed to connect to production database\n' 98 failures+=run+
' dcm in production database out of range\n' 100 failures+=run+
' problem with production database query\n' 102 print "Exit code out of range", endid
106 filename = resultpath+
str(date2)+
'_'+
str(date1)+
'.txt' 108 outfile.write(failures+
'\n')
110 file = resultpath+run+
'febshutoff_auto.txt' 111 if os.path.exists(file):
procfile open("FD_BRL_v0.txt")