ATLAS Offline Software
MooRTT_dynamic_pagemaker.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 
5 import os
6 import sys
7 
8 # module: MooRTT_dynamic_pagemaker.py
9 
11  def __init__(self,argDict={}):
12 
13  # access my args from the dictionary passed in, and convert any basic types
14  # self.myArg = argDict.get('MyArg') # = the Python string type '3'
15  # self.myArg = int(self.myArg) # = the Python integer type 3
16 
17  # access the RTT descriptor instance
18  rttDescriptor = argDict.get('JobDescriptor')
19 
20  # grab some stuff from it
21  self.release = str(rttDescriptor.paths.release)
22  self.build = str(rttDescriptor.paths.build)
23  self.jobGroup = str(rttDescriptor.jobGroup)
24  self.platform = str(rttDescriptor.paths.targetCMTCONFIG)
25  self.branch = str(rttDescriptor.paths.branch)
26  self.runPath = str(rttDescriptor.runPath)
27 
28  def run(self):
29  # do the stuff I wanted to do...
30  logfile = open(self.runPath + "/MooRTT_dynamic_pagemaker.log",'a')
31  logfile.write("Starting MooRTT_dynamic_pagemaker.py run method\n")
32 
33  inputfile = self.runPath + "/ALL_MooRTT_Plots.html"
34  outputfile = inputfile.replace(".html","_Dynamic.html")
35 
36  datasetlist = {"AthenaMooPerformance-MoMu-mupt100-geo-02-01-00" : " SingleMu_100GeV_15616 " ,
37  "AthenaMooPerformance-MoMu-mupt10-geo-02-01-00" : " SingleMu_10GeV_15616 " ,
38  "AthenaMooPerformance-MoMu-Zprime-geo-02-01-00" : " SingleMu_5GeV_15616 " ,
39  "AthenaMooPerformance-MoMu-h4lep-geo-02-01-00" : " SingleMu_3GeV_15616 " ,
40  "AthenaMooPerformance-MoMu-mupt5-hyb-geo-08-00-02mupt10-geo-02-01-00" : " SingleMu_5GeV_15616 " ,
41  "AthenaMooPerformance-MoMu-mupt5-TGmat-geo-08-00-02mupt10-geo-02-01-00" : " SingleMu_5GeV_15616 " ,
42  "AthenaMooPerformance-MoMu-Jpsi-geo-08-00-02" : " Jpsi_15616 " ,
43  "AthenaMooPerformance-MoMu-zmumu-geo-08-00-02" : " Zmumu_15616 " ,
44  "AthenaMooPerformance-MoMu-ttbar-geo-08-00-02" : " ttbar_15616 " ,
45  "AthenaMooPerformance-MoMu-zmumu-csc-01-02-00-sf05" : " pile1sf05_misal1_csc11.005145.PythiaZmumu.digit.RDO.v12000605 "
46  }
47 
48  # helper function
49  def szsplit(stringlist,splitchar=" "):
50  if str(splitchar) == splitchar:
51  try:
52  return stringlist.split(splitchar)
53  except:
54  newlist = []
55  for item in stringlist:
56  newlist += item.split(splitchar)
57  return newlist
58  else:
59  for onechar in splitchar:
60  stringlist = szsplit(stringlist,onechar)
61  return stringlist
62 
63  logfile.write("Input file: " + inputfile + "\n")
64  logfile.write("Output file: " + outputfile + "\n")
65  logfile.write("datasetlist: \n")
66  for key in datasetlist.keys():
67  logfile.write(" " + key + ": " + datasetlist[key] +"\n")
68 
69  logfile.write("Getting dataset... ")
70  try:
71  dataset = datasetlist[self.jobGroup]
72  logfile.write("OK!\n")
73  except:
74  dataset = "Unknown (jobGroup = " + self.jobGroup + ")"
75  logfile.write("Unknown!\n")
76 
77  logfile.write(" Dataset name is " + dataset + "\n")
78 
79  jobinfolist = { "Release" : self.release , "Branch" : self.branch , "Build" : self.build , "Platform" : self.platform , "Dataset" : dataset }
80 
81  # For testing purposes
82  if self.runPath == ".":
83  self.runPath = "/afs/cern.ch/atlas/project/RTT/Results/rel_3/devval/build/i686-slc4-gcc34-dbg/offline/MooPerformance/AthenaMooPerformance-MoMu-mupt10-csc-01-02-00/MoMuStandalone_topOptions/100"
84 
85  logfile.write("jobinfolist: \n")
86  for key in jobinfolist.keys():
87  logfile.write(" " + key + ": " + jobinfolist[key] +"\n")
88 
89  logfile.write("Opening input file: " + inputfile + "\n")
90  input = open(inputfile,'r')
91 
92  logfile.write("Opening output file: " + outputfile + "\n")
93  output = open(outputfile,'w')
94 
95  logfile.write("Starting copy...\n")
96 
97  for line in input:
98  logfile.write("Line: " + line)
99  if line.count("<h2>Contents</h2>"):
100  logfile.write(" Contains <h2>Contents</h2>\n")
101  output.write("<TABLE BORDER=6 CELLSPACING=4 CELLPADDING=4>\n")
102  for key in jobinfolist.keys():
103  logfile.write(" Going through jobinfo list and writing value of " + key + "... ")
104  output.write(" <TR><TD><b>" + key + "</b></TD><TD>" + jobinfolist[key] + "</TD></TR>\n")
105  logfile.write("Done.\n")
106  logfile.write("Writing date and finishing table... ")
107  output.write(" <TR><TD><b>" + "Date" + "</b></TD><TD>" + os.popen("date").readline().strip() + "</TD></TR>\n")
108  output.write("</TABLE>\n\n")
109  logfile.write("Done.\n")
110  if line.count("RTT default page"):
111  logfile.write(" Contains RTT default page")
112  htmlline = "<li><a href=\"http://atlas-project-rtt-results.web.cern.ch/atlas-project-rtt-results/page2.php?xml="
113  htmlline += szsplit(self.runPath,["Results/","/MooPerformance"])[1]
114  htmlline += "/RTTSummary.xml&package=MooPerformance&job=MoMuStandalone_topOptions&id=" + self.runPath.split("/")[-1]
115  htmlline += "\">RTT default page</a></li>\n"
116  output.write(htmlline)
117  logfile.write(" Writing: " + htmlline)
118  else:
119  if line.count("Log files"):
120  logfile.write(" Contains log files")
121  htmlline = "<li>Log files: "
122  for filename in os.listdir(self.runPath):
123  if filename.count("log"):
124  htmlline += "<a href=\"" + filename + "\">" + filename + "</a> "
125  htmlline += "</li>\n"
126  output.write(htmlline)
127  logfile.write(" Writing: " + htmlline)
128  else:
129  output.write(line)
130  logfile.write(" Output original line.\n")
131 
132  logfile.write("Now closing files.\n")
133  output.close()
134  input.close()
135  logfile.close()
136 
137 class fakePaths:
138  def __init__(self,release="release",build="build",platform="platform",branch="branch"):
139  self.release = release
140  self.build = build
141  self.targetCMTCONFIG = platform
142  self.branch = branch
143  self.runPath = os.popen("pwd").readline().strip()
144 
146  def __init__(self):
147  self.paths = fakePaths()
148  self.jobGroup = "AthenaMooPerformance-MoMu-mupt10-csc-01-02-00"
149  self.runPath = "."
150 
151 # Test run
152 if sys.argv[0] == "./MooRTT_dynamic_pagemaker.py":
153 
154  fakedecr = fakeRttDescriptor()
155  fakeArgDict = { 'JobDescriptor' : fakedecr }
156  pagemaker = MooRTT_dynamic_pagemaker(fakeArgDict)
157  pagemaker.run()
MooRTT_dynamic_pagemaker.fakePaths.release
release
Definition: MooRTT_dynamic_pagemaker.py:139
MooRTT_dynamic_pagemaker.fakePaths.branch
branch
Definition: MooRTT_dynamic_pagemaker.py:142
MooRTT_dynamic_pagemaker.fakeRttDescriptor.runPath
runPath
Definition: MooRTT_dynamic_pagemaker.py:149
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.release
release
Definition: MooRTT_dynamic_pagemaker.py:21
MooRTT_dynamic_pagemaker.fakeRttDescriptor
Definition: MooRTT_dynamic_pagemaker.py:145
MooRTT_dynamic_pagemaker.fakePaths.__init__
def __init__(self, release="release", build="build", platform="platform", branch="branch")
Definition: MooRTT_dynamic_pagemaker.py:138
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.platform
platform
Definition: MooRTT_dynamic_pagemaker.py:24
MooRTT_dynamic_pagemaker.fakePaths.build
build
Definition: MooRTT_dynamic_pagemaker.py:140
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.jobGroup
jobGroup
Definition: MooRTT_dynamic_pagemaker.py:23
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.runPath
runPath
Definition: MooRTT_dynamic_pagemaker.py:26
MooRTT_dynamic_pagemaker.fakePaths
Definition: MooRTT_dynamic_pagemaker.py:137
MooRTT_dynamic_pagemaker.fakePaths.runPath
runPath
Definition: MooRTT_dynamic_pagemaker.py:143
MooRTT_dynamic_pagemaker.fakeRttDescriptor.jobGroup
jobGroup
Definition: MooRTT_dynamic_pagemaker.py:148
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker
Definition: MooRTT_dynamic_pagemaker.py:10
Trk::open
@ open
Definition: BinningType.h:40
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.__init__
def __init__(self, argDict={})
Definition: MooRTT_dynamic_pagemaker.py:11
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.build
build
Definition: MooRTT_dynamic_pagemaker.py:22
MooRTT_dynamic_pagemaker.fakePaths.targetCMTCONFIG
targetCMTCONFIG
Definition: MooRTT_dynamic_pagemaker.py:141
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.branch
branch
Definition: MooRTT_dynamic_pagemaker.py:25
MooRTT_dynamic_pagemaker.MooRTT_dynamic_pagemaker.run
def run(self)
Definition: MooRTT_dynamic_pagemaker.py:28
str
Definition: BTagTrackIpAccessor.cxx:11
MooRTT_dynamic_pagemaker.fakeRttDescriptor.__init__
def __init__(self)
Definition: MooRTT_dynamic_pagemaker.py:146
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
MooRTT_dynamic_pagemaker.fakeRttDescriptor.paths
paths
Definition: MooRTT_dynamic_pagemaker.py:147