ATLAS Offline Software
MuonRecRTT_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: MuonRecRTT_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 + "/MuonRecRTT_dynamic_pagemaker.log",'a')
31  logfile.write("Starting MuonRecRTT_dynamic_pagemaker.py run method\n")
32 
33  inputfile = self.runPath + "/ALL_MuonRecRTT_Plots.html"
34  outputfile = inputfile.replace(".html","_Dynamic.html")
35 
36  datasetlist = { "AthenaMuonSimRec" : " " ,
37  "AthenaMuonDataRec" : " " ,
38  "MuonDataRecTrf" : " "
39  }
40 
41  # helper function
42  def szsplit(stringlist,splitchar=" "):
43  if str(splitchar) == splitchar:
44  try:
45  return stringlist.split(splitchar)
46  except:
47  newlist = []
48  for item in stringlist:
49  newlist += item.split(splitchar)
50  return newlist
51  else:
52  for onechar in splitchar:
53  stringlist = szsplit(stringlist,onechar)
54  return stringlist
55 
56  logfile.write("Input file: " + inputfile + "\n")
57  logfile.write("Output file: " + outputfile + "\n")
58  logfile.write("datasetlist: \n")
59  for key in datasetlist.keys():
60  logfile.write(" " + key + ": " + datasetlist[key] +"\n")
61 
62  logfile.write("Getting dataset... ")
63  try:
64  dataset = datasetlist[self.jobGroup]
65  logfile.write("OK!\n")
66  except:
67  dataset = "Unknown (jobGroup = " + self.jobGroup + ")"
68  logfile.write("Unknown!\n")
69 
70  logfile.write(" Dataset name is " + dataset + "\n")
71 
72  jobinfolist = { "Release" : self.release , "Branch" : self.branch , "Build" : self.build , "Platform" : self.platform , "Dataset" : dataset }
73 
74  # For testing purposes
75  if self.runPath == ".":
76  self.runPath = "/afs/cern.ch/atlas/project/RTT/Results/rel_3/devval/build/i686-slc4-gcc34-opt/offline/MuonRecRTT/AthenaMuonRec/MuonRecRTT/263"
77 
78  logfile.write("jobinfolist: \n")
79  for key in jobinfolist.keys():
80  logfile.write(" " + key + ": " + jobinfolist[key] +"\n")
81 
82  logfile.write("Opening input file: " + inputfile + "\n")
83  input = open(inputfile,'r')
84 
85  logfile.write("Opening output file: " + outputfile + "\n")
86  output = open(outputfile,'w')
87 
88  logfile.write("Starting copy...\n")
89 
90  for line in input:
91  logfile.write("Line: " + line)
92  if line.count("<h2>Contents</h2>"):
93  logfile.write(" Contains <h2>Contents</h2>\n")
94  output.write("<TABLE BORDER=6 CELLSPACING=4 CELLPADDING=4>\n")
95  for key in jobinfolist.keys():
96  logfile.write(" Going through jobinfo list and writing value of " + key + "... ")
97  output.write(" <TR><TD><b>" + key + "</b></TD><TD>" + jobinfolist[key] + "</TD></TR>\n")
98  logfile.write("Done.\n")
99  logfile.write("Writing date and finishing table... ")
100  output.write(" <TR><TD><b>" + "Date" + "</b></TD><TD>" + os.popen("date").readline().strip() + "</TD></TR>\n")
101  output.write("</TABLE>\n\n")
102  logfile.write("Done.\n")
103  if line.count("RTT default page"):
104  logfile.write(" Contains RTT default page")
105  htmlline = "<li><a href=\"http://atlas-project-rtt-results.web.cern.ch/atlas-project-rtt-results/page2.php?xml="
106  htmlline += szsplit(self.runPath,["Results/","/MuonRecRTT"])[1]
107  htmlline += "/RTTSummary.xml&package=MuonRecRTT&job=MuonRecRTT&id=" + self.runPath.split("/")[-1]
108  htmlline += "\">RTT default page</a></li>\n"
109  output.write(htmlline)
110  logfile.write(" Writing: " + htmlline)
111  else:
112  if line.count("Log files"):
113  logfile.write(" Contains log files")
114  htmlline = "<li>Log files: "
115  for filename in os.listdir(self.runPath):
116  if filename.count("log"):
117  htmlline += "<a href=\"" + filename + "\">" + filename + "</a> "
118  htmlline += "</li>\n"
119  output.write(htmlline)
120  logfile.write(" Writing: " + htmlline)
121  else:
122  output.write(line)
123  logfile.write(" Output original line.\n")
124 
125  logfile.write("Now closing files.\n")
126  output.close()
127  input.close()
128  logfile.close()
129 
130 class fakePaths:
131  def __init__(self,release="release",build="build",platform="platform",branch="branch"):
132  self.release = release
133  self.build = build
134  self.targetCMTCONFIG = platform
135  self.branch = branch
136  self.runPath = os.popen("pwd").readline().strip()
137 
139  def __init__(self):
140  self.paths = fakePaths()
141  self.jobGroup = "AthenaMuonRec"
142  self.runPath = "."
143 
144 # Test run
145 if sys.argv[0] == "./MuonRecRTT_dynamic_pagemaker.py":
146 
147  fakedecr = fakeRttDescriptor()
148  fakeArgDict = { 'JobDescriptor' : fakedecr }
149  pagemaker = MuonRecRTT_dynamic_pagemaker(fakeArgDict)
150  pagemaker.run()
MuonRecRTT_dynamic_pagemaker.fakePaths.release
release
Definition: MuonRecRTT_dynamic_pagemaker.py:132
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.run
def run(self)
Definition: MuonRecRTT_dynamic_pagemaker.py:28
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.release
release
Definition: MuonRecRTT_dynamic_pagemaker.py:21
MuonRecRTT_dynamic_pagemaker.fakePaths.branch
branch
Definition: MuonRecRTT_dynamic_pagemaker.py:135
MuonRecRTT_dynamic_pagemaker.fakePaths.runPath
runPath
Definition: MuonRecRTT_dynamic_pagemaker.py:136
MuonRecRTT_dynamic_pagemaker.fakeRttDescriptor.paths
paths
Definition: MuonRecRTT_dynamic_pagemaker.py:140
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.platform
platform
Definition: MuonRecRTT_dynamic_pagemaker.py:24
MuonRecRTT_dynamic_pagemaker.fakePaths
Definition: MuonRecRTT_dynamic_pagemaker.py:130
MuonRecRTT_dynamic_pagemaker.fakeRttDescriptor.__init__
def __init__(self)
Definition: MuonRecRTT_dynamic_pagemaker.py:139
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.jobGroup
jobGroup
Definition: MuonRecRTT_dynamic_pagemaker.py:23
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.branch
branch
Definition: MuonRecRTT_dynamic_pagemaker.py:25
MuonRecRTT_dynamic_pagemaker.fakeRttDescriptor.jobGroup
jobGroup
Definition: MuonRecRTT_dynamic_pagemaker.py:141
MuonRecRTT_dynamic_pagemaker.fakePaths.__init__
def __init__(self, release="release", build="build", platform="platform", branch="branch")
Definition: MuonRecRTT_dynamic_pagemaker.py:131
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker
Definition: MuonRecRTT_dynamic_pagemaker.py:10
MuonRecRTT_dynamic_pagemaker.fakePaths.build
build
Definition: MuonRecRTT_dynamic_pagemaker.py:133
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.runPath
runPath
Definition: MuonRecRTT_dynamic_pagemaker.py:26
MuonRecRTT_dynamic_pagemaker.fakePaths.targetCMTCONFIG
targetCMTCONFIG
Definition: MuonRecRTT_dynamic_pagemaker.py:134
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.build
build
Definition: MuonRecRTT_dynamic_pagemaker.py:22
Trk::open
@ open
Definition: BinningType.h:40
MuonRecRTT_dynamic_pagemaker.fakeRttDescriptor
Definition: MuonRecRTT_dynamic_pagemaker.py:138
MuonRecRTT_dynamic_pagemaker.MuonRecRTT_dynamic_pagemaker.__init__
def __init__(self, argDict={})
Definition: MuonRecRTT_dynamic_pagemaker.py:11
str
Definition: BTagTrackIpAccessor.cxx:11
MuonRecRTT_dynamic_pagemaker.fakeRttDescriptor.runPath
runPath
Definition: MuonRecRTT_dynamic_pagemaker.py:142
Trk::split
@ split
Definition: LayerMaterialProperties.h:38