111 Build the HTML content
113 path = resource_filename(
"DQDefects.data",
"table.html")
114 with open(path)
as fd:
115 template = MarkupTemplate(fd, path)
117 stream = template.generate(HTML=HTML, **kwargs)
118 serializer = HTMLSerializer(doctype=
"html5")
119 content = encode(serializer(stream))
122def build_defects(descriptions, virtuals, intolerables, lbs, lumis, all_defects):
124 with timer(
"Sort defects by channel"):
125 dbc = all_defects.by_channel
127 with timer(
"Compute luminosities"):
128 lumi_by_defect = compute_lumi_many_channels(lbs, lumis, all_defects)
132 for name, description
in sorted(descriptions.iteritems()):
133 virtual, intolerable = name
in virtuals, name
in intolerables
134 defect =
Defect(name, description, dbc[name], virtual, intolerable,
135 lumi_by_defect.get(name, 0))
136 defects.append(defect)
138 defects.sort(key=
lambda d: (d.virtual,
not d.intolerable))
154 iov_range =
None,
None
155 iov_range = 185000 << 32, 185500 << 32
158 with timer(
"Fetch defect info"):
159 all_defects = d.retrieve(*iov_range)
161 with timer(
"fetch peripheral information"):
162 descriptions = d.all_defect_descriptions
163 intolerable = d.get_intolerable_defects()
164 virtual = d.virtual_defect_names
166 with timer(
"Fetch lumi inputs"):
167 lbs, lumis = fetch_lumi_inputs(iov_range,
"ONLINE")
169 d =
build_defects(descriptions, virtual, intolerable, lbs, lumis, all_defects)
171 target_dir =
"/afs/cern.ch/user/p/pwaller/www/defects/test"
172 art_dir = pjoin(target_dir,
"extern")
179 content =
build_table(headings=heading_titles, defects=d)
180 with open(pjoin(target_dir,
"test.html"),
"w")
as fd: