3 import os,time,sys,shutil,glob
5 from datetime
import datetime
7 from email.MIMEText
import MIMEText
11 s=smtplib.SMTP(
"localhost")
13 body=
"File merge failed by unknown reason for run"+run
15 msg[
'Subject'] =
"File merge failed."
16 msg[
'From'] = ServerMail
17 msg[
'To'] = EmailAddress
18 s.sendmail(ServerMail,tolist,msg.as_string())
28 hist = f.FindObjectAny(
"reportSummaryContents")
30 if (hist ==
None and rootfile.rfind(
'HcalTiming') == -1):
41 TempTag = TimeTag +
'-tmp'
42 if not os.path.exists(TimeTag):
43 os.system(
'touch -t 01010000 '+ TimeTag)
49 TAG = os.stat(TimeTag).st_mtime
50 for dir, subdirs, files
in os.walk(DIR):
51 paths = [
"%s/%s" % (dir, x)
for x
in files]
52 for f
in [x
for x
in paths
if re.search(
r'/DQM_.*_R[0-9]{9}\.root$', x)]:
53 if os.stat(f).st_mtime > TAG
and f.index(
"DQM_Reference") < 0:
54 NEW.get(f[-14:-5], []).
append(f)
58 print 'Have not found new files...'
61 os.system(
"ls -l %s" % TimeTag)
62 os.system(
'touch '+ TempTag)
64 print 'Found %d new file(s).' % NFOUND
69 for (run, files)
in NEW.iteritems():
70 runnr =
"%09d" % long(run)
71 destdir =
"%s/%s/%s/%s" % (FILEDIR, runnr[0:3], runnr[3:6], runnr[6:9])
75 destfile =
"%s/DQM_V%04d_R%s.root" % (destdir, version, runnr)
76 if not os.path.exists(destfile):
break
77 oldfiles.append(destfile)
80 if not os.path.exists(destdir):
83 logfile =
"%s.log" % destfile[:-4]
84 tmpdestfile =
"%s.tmp" % destfile
86 print 'Run %s is being merged...' % run
88 if os.path.exists(tmpdestfile):
89 os.remove(tmpdestfile)
93 LOGFILE =
file(logfile,
'a')
94 LOGFILE.write(os.popen(
'DQMMergeFile %s %s' % (tmpdestfile,
" ".
join(files))).
read())
95 if not os.path.exists(tmpdestfile):
96 print 'Failed merging files for run %s. Try again after two minutes' % run
102 os.rename(tmpdestfile, destfile)
104 allOldFiles.extend(oldfiles)
105 newFiles.append(destfile)
108 if os.path.exists(TMPDB):
111 if os.path.exists(DB):
114 logfile.write(
'*** INITIALISE DATABASE ***\n')
115 logfile.write(os.popen(
'visDQMRegisterFile %s "/Global/Online/ALL" "Global run"' % TMPDB).
read())
117 logfile.write(
'*** UNREGISTER %d OLD FILES ***\n' % len(allOldFiles))
118 while len(allOldFiles) > 0:
119 (slice, rest) = (allOldFiles[0:50], allOldFiles[50:])
120 logfile.write(os.popen(
'visDQMUnregisterFile %s %s' % (tmpdb,
" ".
join(slice))).
read())
125 for file
in newFiles:
126 print 'Registering %s' % file
127 logfile.write(
'*** REGISTER FILE %s ***\n' % file)
128 logfile.write(os.popen(
'visDQMRegisterFile %s "/Global/Online/ALL" "Global run" %s' % (TMPDB, file)).
read())
129 print '%s registered' % file
133 os.rename(TempTag, TimeTag)
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
static std::string join(char **cmd)