~vila/udd/split-failures

« back to all changes in this revision

Viewing changes to categorise_failures.py

  • Committer: Vincent Ladeuil
  • Date: 2011-03-23 17:31:09 UTC
  • mto: This revision was merged to the branch mainline in revision 418.
  • Revision ID: v.ladeuil+lp@free.fr-20110323173109-cxm0id9b9a370mj2
Update mass-import to stay in sync with jubany.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
import sys
9
9
import time
10
10
 
11
 
from udd import icommon
 
11
sys.path.insert(0, os.path.dirname(__file__))
 
12
import icommon
12
13
 
13
14
html_head = '''<html>
14
15
<head>
18
19
<script src="jquery.flot.js"></script>
19
20
</head>
20
21
<body>
21
 
<p><a href="http://package-import.ubuntu.com/status/">All Ubuntu Overview</a>, 
22
 
<a href="http://package-import.ubuntu.com/status/main.html">Ubuntu Main Overview</a></p>
 
22
<a href="http://package-import.ubuntu.com/status/">Overview</a>
23
23
 
24
24
<p>You are looking at information on the Bazaar importer system that serves <a
25
25
href="https://wiki.ubuntu.com/DistributedDevelopment">Ubuntu Distributed
38
38
href="https://wiki.ubuntu.com/DistributedDevelopment/UnderTheHood">
39
39
UnderTheHood  </a> part of the <a
40
40
href="https://wiki.ubuntu.com/DistributedDevelopment">
41
 
wiki.  </a> </p>
 
41
wiki  </a> </p>.
42
42
 
43
43
<p>This page was last updated at <tt>''' + datetime.datetime.utcnow().isoformat() + ''' UTC.</tt></p>
44
44
'''
45
45
 
46
 
html_contents = '''<h3>Contents of this page</h3>
47
 
<ul>
48
 
<li><a href="#stats">Summary</a></li>
49
 
<li><a href="#latest">Latest failures</a></li>
50
 
<li><a href="#analysis">All failures</a></li>
51
 
</ul>
52
 
'''
53
 
 
54
46
html_tail = '''</body>
55
47
</html>
56
48
'''
180
172
        return len(reasons[b]) - len(reasons[a])
181
173
    keys.sort(cmp=compare)
182
174
    write_analyis_partial(f, keys, reasons, explanations,
183
 
            lambda x: x.auto_retry_masked, "failed too many times to retry")
 
175
            lambda x: x.auto_retry_masked, "failed to many times to retry")
184
176
    write_analyis_partial(f, keys, reasons, explanations,
185
177
            lambda x: not x.auto_retry, "failed")
186
178
    write_analyis_partial(f, keys, reasons, explanations,
210
202
    f = open(path, "wb")
211
203
    try:
212
204
        f.write(html_head % {"title": "bzr import failures"})
213
 
        f.write(html_contents)
 
205
        f.write("""<h3>Contents of this page</h3>
 
206
<ul>
 
207
<li><a href="#stats">Summary</a></li>
 
208
<li><a href="#latest">Latest failures</a></li>
 
209
<li><a href="#analysis">All failures</a></li>
 
210
</ul>
 
211
""")
214
212
        f.write('<div id="stats">\n')
215
213
        write_stats(f, package_info)
216
 
        f.write('</div>\n<div id="latest">\n<h3>Latest 50 Failures:</h3>\n<ul>\n')
 
214
        f.write('</div>\n<div id="latest">\nLatest 50 Failures:\n<ul>\n')
217
215
        write_latest(f, package_info)
218
216
        f.write('</ul>\n</div>\n')
219
 
        f.write('</div>\n<h3>All Failures by Category</h3>\n<div id="analysis">\n<ul>\n')
 
217
        f.write('</div>\n<div id="analysis">\n<ul>\n')
220
218
        write_analysis(f, reasons, explanations)
221
219
        f.write('</ul>\n</div>\n')
222
220
        db = icommon.HistoryDatabase(icommon.sqlite_history_file)
277
275
    f = open(path, "wb")
278
276
    try:
279
277
        f.write(html_head % {"title": "bzr import failures for main"})
280
 
        f.write(html_contents)
281
 
        f.write('<h3>Summary</h3>\n<div id="stats">\n')
 
278
        f.write("""<p><h3>Contents of this page</h3>
 
279
<ul>
 
280
<li><a href="#stats">Summary</a></li>
 
281
<li><a href="#latest">Latest failures</a></li>
 
282
<li><a href="#analysis">All failures</a></li>
 
283
</ul>
 
284
</p>
 
285
""")
 
286
        f.write('<div id="stats">\n')
282
287
        write_stats(f, package_info)
283
 
        f.write('</div>\n<div id="latest">\n<h3>Latest 50 Failures:</h3>\n<ul>\n')
 
288
        f.write('</div>\n<div id="latest">\n<p>Latest 50 Failures:\n<ul>\n')
284
289
        write_latest(f, package_info)
285
290
        f.write('</ul>\n</p>\n</div>\n')
286
 
        f.write('</div>\n<h3>All Failures by Category</h3>\n<div id="analysis">\n<ul>\n')
 
291
        f.write('</div>\n<div id="analysis">\n<ul>\n')
287
292
        write_analysis(f, reasons, explanations)
288
293
        f.write('</ul>\n</div>\n')
289
294
        db = icommon.HistoryDatabase(icommon.sqlite_history_file)
317
322
    remove_obsolete_pages(old_pages, new_pages)
318
323
 
319
324
 
320
 
def install_index():
321
 
    content = '''<html>
322
 
<head>
323
 
<title>Ubuntu Bazaar package importer</title>
324
 
<meta http-equiv="refresh" content="0;url=status/">
325
 
</head>
326
 
<body>
327
 
Hi!
328
 
 
329
 
See <a href="status">the status page.</a>
330
 
</body>
331
 
</html>
332
 
'''
333
 
    # FIXME: 'status' in content should stay in sync with 'status' in
334
 
    # web_status_dir, we could use os.path.basename(icommon.web_status_dir)
335
 
    # -- vila 2011-03-23
336
 
    index_path = os.path.join(icommon.web_base_dir, 'index.html')
337
 
    f = open(index_path, 'w')
338
 
    try:
339
 
        f.write(content)
340
 
    finally:
341
 
        f.close()
342
 
 
343
325
def main():
344
326
    lock = icommon.lock_categorise_failures()
345
327
    if lock is None:
346
328
        print "Another instance of categorise_failures is already running."
347
329
        sys.exit(0)
348
330
    try:
349
 
        install_index()
350
331
        get_info()
351
332
    finally:
352
333
        lock.close()