-
Notifications
You must be signed in to change notification settings - Fork 11
/
BBS-report.py
executable file
·2223 lines (2013 loc) · 87.8 KB
/
BBS-report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
##############################################################################
###
### This file is part of the BBS software (Bioconductor Build System).
###
### Author: Hervé Pagès <[email protected]>
### Last modification: June 16, 2021
###
import sys
import os
import time
import shutil
import re
import fnmatch
import string
import html
import bbs.fileutils
import bbs.parse
import bbs.jobs
import bbs.rdir
import BBSutils
import BBSvars
import BBSreportutils
node2aboutpage = {}
node2Rinstpkgspage = {}
node2Rinstpkgcount = {}
##############################################################################
### General stuff displayed on all pages
##############################################################################
def write_HTML_header(out, page_title=None, css_file=None, js_file=None):
report_nodes = BBSutils.getenv('BBS_REPORT_NODES')
title = BBSreportutils.make_report_title(report_nodes)
out.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"')
out.write(' "http://www.w3.org/TR/html4/loose.dtd">\n')
out.write('<HTML>\n')
out.write('<HEAD>\n')
out.write('<META http-equiv="Content-Type" content="text/html; charset=UTF-8">\n')
if page_title:
title += " - " + page_title
out.write('<TITLE>%s</TITLE>\n' % title)
if css_file:
out.write('<LINK rel="stylesheet" href="%s" type="text/css">\n' % css_file)
if js_file:
out.write('<SCRIPT type="text/javascript" src="%s"></SCRIPT>\n' % js_file)
out.write('</HEAD>\n')
return
def write_abc_dispatcher(out, href="", current_letter=None,
activate_current_letter=False):
out.write('<TABLE class="abc_dispatcher"><TR>')
for i in range(65,91):
letter = chr(i)
if letter == current_letter and not activate_current_letter:
out.write('<TD style="background: inherit;">%s</TD>' % letter)
continue
html_letter = '<A href="%s#%s">%s</A>' % (href, letter, letter)
if letter == current_letter:
html_letter = '<B>[%s]</B>' % html_letter
out.write('<TD>%s</TD>' % html_letter)
out.write('</TR></TABLE>')
return
def write_goback_links(out, topdir=".", long_link=False, current_letter=None):
report_nodes = BBSutils.getenv('BBS_REPORT_NODES')
title = BBSreportutils.make_report_title(report_nodes)
TABLE_style = 'width: 100%; background: #EEE;'
out.write('<TABLE class="grid_layout" style="%s"><TR>' % TABLE_style)
TD_style = 'text-align: left; padding: 5px; vertical-align: middle;'
out.write('<TD style="%s"><I>' % TD_style)
if long_link:
out.write('Back to <B>%s</B>: ' % title)
out.write('<A href="%s/">simplified</A> ' % topdir)
out.write('<A href="%s/long-report.html">long</A>' % topdir)
else:
out.write('<A href="%s/">Back to <B>%s</B></A>' % (topdir, title))
out.write('</I></TD>')
if not no_alphabet_dispatch and current_letter != None:
out.write('<TD>')
write_abc_dispatcher(out, topdir, current_letter, True)
out.write('</TD>')
out.write('</TR></TABLE>\n')
return
def write_switch_link(out, simp_link=False, long_link=False):
if not simp_link and not long_link:
return
if simp_link:
link = '<A href="./">Switch to simplified report</A>'
else:
link = '<A href="./long-report.html">Switch to long report</A>'
out.write('<P style="margin: 0px; text-align: left">%s</P>\n' % link)
return
def write_timestamp(out):
out.write('<P class="time_stamp">\n')
date = bbs.jobs.currentDateString()
out.write('This page was generated on %s.\n' % date)
out.write('</P>\n')
return
def write_motd_asTABLE(out):
if not 'BBS_REPORT_MOTD' in os.environ:
return
motd = os.environ['BBS_REPORT_MOTD']
if motd == "":
return
out.write('<DIV class="motd">\n')
out.write('<TABLE>')
out.write('<TR><TD>%s</TD></TR>' % motd)
out.write('</TABLE>\n')
out.write('</DIV>\n')
return
def write_notes_to_developers(out, pkg, extra_note=None):
# Renviron.bioc is expected to be found in BBS_REPORT_PATH which should
# be the current working directory.
if BBSvars.buildtype != "bioc" and not os.path.exists('Renviron.bioc'):
return
out.write('<DIV class="notes_to_developers">\n')
out.write('<TABLE><TR><TD>\n')
out.write('<B>To the developers/maintainers ')
out.write('of the %s package:</B><BR>\n' % pkg)
nnotes = int(BBSvars.buildtype == "bioc") + \
int(os.path.exists('Renviron.bioc')) * 2 + \
int(extra_note != None)
prefix = '- ' if nnotes >= 2 else ''
if BBSvars.buildtype == "bioc":
url = 'https://bioconductor.org/developers/how-to/troubleshoot-build-report/'
out.write('%sAllow up to 24 hours (and sometimes ' % prefix)
out.write('48 hours) for your latest push to ')
out.write('[email protected]:packages/%s.git ' % pkg)
out.write('to reflect on this report. ')
out.write('See <A href="%s">Troubleshooting Build Report</A> ' % url)
out.write('for more information.<BR>\n')
if os.path.exists('Renviron.bioc'):
out.write('%sUse the following ' % prefix)
out.write('<A href="../%s">Renviron settings</A> ' % 'Renviron.bioc')
out.write('to reproduce errors and warnings.<BR>\n')
out.write('%sIf \'R CMD check\' started to fail recently ' % prefix)
out.write('on the Linux builder(s) over a missing dependency, ')
out.write('add the missing dependency to \'Suggests:\' in your ')
out.write('DESCRIPTION file. See ')
out.write('<A href="../%s">Renviron.bioc</A> ' % 'Renviron.bioc')
out.write('for more information.<BR>\n')
if extra_note != None:
out.write('%s%s\n' % (prefix, extra_note))
out.write('</TD></TR></TABLE>\n')
out.write('</DIV>\n')
return
##############################################################################
### write_node_specs_table()
##############################################################################
def read_Rversion(Node_rdir):
filename = 'NodeInfo/R-version.txt'
f = Node_rdir.WOpen(filename)
Rversion = bbs.parse.bytes2str(f.readline())
f.close()
Rversion = Rversion.replace('R version ', '')
Rversion_html = Rversion.replace(' ', ' ')
return Rversion_html
def get_Rconfig_value_from_file(Node_rdir, var):
filename = 'NodeInfo/R-config.txt'
dcf = Node_rdir.WOpen(filename)
val = bbs.parse.get_next_DCF_val(dcf, var, True)
dcf.close()
if val == None:
filename = '%s/%s' % (Node_rdir.label, filename)
raise bbs.parse.DcfFieldNotFoundError(filename, var)
return val
def write_Rconfig_table_from_file(out, Node_rdir, vars):
out.write('<TABLE class="Rconfig">\n')
out.write('<TR>')
out.write('<TD style="background: #CCC; width: 150px;"><I><B>R variable</B> (VAR)</I></TD>')
out.write('<TD style="background: #CCC;"><I><B>Value</B> (\'R CMD config <VAR>\' output)</I></TD>')
out.write('</TR>\n')
for var in vars:
val = get_Rconfig_value_from_file(Node_rdir, var)
out.write('<TR><TD><B>%s</B></TD><TD>%s</TD></TR>\n' % (var, val))
out.write('<TR>')
out.write('<TD COLSPAN="2" style="font-size: smaller;">')
out.write('<I>Please refer to \'R CMD config -h\' for the meaning of these variables</I>')
out.write('</TD>')
out.write('</TR>\n')
out.write('</TABLE>\n')
return
def write_SysCommandVersion_from_file(out, Node_rdir, var, config=True):
filename = 'NodeInfo/%s-version.txt' % var
f = Node_rdir.WOpen(filename, return_None_on_error=True)
if f == None:
return
if config:
cmd = get_Rconfig_value_from_file(Node_rdir, var)
syscmd = '%s --version' % cmd
out.write('<P><B>Compiler version</B> (\'%s\' output):</P>\n' % syscmd)
else:
cmd = var.lower()
syscmd = '%s --version' % cmd
out.write('<P><B>%s version</B> (\'%s\' output):</P>\n' % (cmd, syscmd))
out.write('<PRE style="margin-left: 12px;">\n')
for line in f:
out.write(bbs.parse.bytes2str(line))
f.close()
out.write('</PRE>\n')
return
def make_aboutnode_page(Node_rdir, node, long_link=False):
page_title = 'More about %s' % node.node_id
aboutnode_page = '%s-NodeInfo.html' % node.node_id
print("BBS> [make_aboutnode_page] Write %s in %s/ ..." % \
(aboutnode_page, os.getcwd()), end=" ")
sys.stdout.flush()
out = open(aboutnode_page, 'w')
write_HTML_header(out, page_title, 'report.css')
out.write('<BODY>\n')
write_goback_links(out, long_link=long_link)
write_timestamp(out)
out.write('<H2><SPAN class="%s">%s</SPAN></H2>\n' % \
(node.hostname.replace(".", "_"), page_title))
out.write('<BR>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
out.write('<TABLE>\n')
out.write('<TR><TD><B>Hostname: </B></TD><TD>%s</TD></TR>\n' % node.hostname)
out.write('<TR><TD><B>OS: </B></TD><TD>%s</TD></TR>\n' % node.os_html)
out.write('<TR><TD><B>Arch: </B></TD><TD>%s</TD></TR>\n' % node.arch)
out.write('<TR><TD><B>Platform: </B></TD><TD>%s</TD></TR>\n' % node.platform)
out.write('<TR><TD><B>R version: </B></TD><TD>%s</TD></TR>\n' % read_Rversion(Node_rdir))
out.write('<TR>')
out.write('<TD><B>R environment variables: </B></TD>')
out.write('<TD>')
# Renviron.bioc is expected to be found in BBS_REPORT_PATH which should
# be the current working directory.
if os.path.exists('Renviron.bioc'):
out.write('<A href="%s">%s</A>' % ('Renviron.bioc', 'Renviron.bioc'))
else:
out.write('none')
out.write('</TD>')
out.write('</TR>\n')
out.write('</TABLE>\n')
out.write('</DIV>\n')
out.write('<HR>\n')
out.write('<H2>C compiler</H2>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
C_vars = ['CC', 'CFLAGS', 'CPICFLAGS']
write_Rconfig_table_from_file(out, Node_rdir, C_vars)
write_SysCommandVersion_from_file(out, Node_rdir, 'CC')
out.write('</DIV>\n')
out.write('<HR>\n')
out.write('<H2>C++ compiler</H2>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
Cplusplus_vars = ['CXX', 'CXXFLAGS', 'CXXPICFLAGS']
write_Rconfig_table_from_file(out, Node_rdir, Cplusplus_vars)
write_SysCommandVersion_from_file(out, Node_rdir, 'CXX')
out.write('</DIV>\n')
out.write('<HR>\n')
#out.write('<H2>C++98 compiler</H2>\n')
#out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
#Cplusplus98_vars = ['CXX98', 'CXX98FLAGS', 'CXX98PICFLAGS', 'CXX98STD']
#write_Rconfig_table_from_file(out, Node_rdir, Cplusplus98_vars)
#write_SysCommandVersion_from_file(out, Node_rdir, 'CXX98')
#out.write('</DIV>\n')
#
#out.write('<HR>\n')
out.write('<H2>C++11 compiler</H2>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
Cplusplus11_vars = ['CXX11', 'CXX11FLAGS', 'CXX11PICFLAGS', 'CXX11STD']
write_Rconfig_table_from_file(out, Node_rdir, Cplusplus11_vars)
write_SysCommandVersion_from_file(out, Node_rdir, 'CXX11')
out.write('</DIV>\n')
out.write('<HR>\n')
out.write('<H2>C++14 compiler</H2>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
Cplusplus14_vars = ['CXX14', 'CXX14FLAGS', 'CXX14PICFLAGS', 'CXX14STD']
write_Rconfig_table_from_file(out, Node_rdir, Cplusplus14_vars)
write_SysCommandVersion_from_file(out, Node_rdir, 'CXX14')
out.write('</DIV>\n')
out.write('<HR>\n')
out.write('<H2>C++17 compiler</H2>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
Cplusplus17_vars = ['CXX17', 'CXX17FLAGS', 'CXX17PICFLAGS', 'CXX17STD']
write_Rconfig_table_from_file(out, Node_rdir, Cplusplus17_vars)
write_SysCommandVersion_from_file(out, Node_rdir, 'CXX17')
out.write('</DIV>\n')
out.write('<HR>\n')
out.write('<H2>Java</H2>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
if node.os_html.find('Windows') == 0:
write_SysCommandVersion_from_file(out, Node_rdir, 'java', config=False)
else:
write_SysCommandVersion_from_file(out, Node_rdir, 'JAVA', config=False)
out.write('</DIV>\n')
out.write('<HR>\n')
out.write('<H2>Pandoc</H2>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
write_SysCommandVersion_from_file(out, Node_rdir, 'pandoc', False)
out.write('</DIV>\n')
out.write('<HR>\n')
#out.write('<H2>Fortran 77 compiler</H2>\n')
#out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
#Fortran77_vars = ['F77', 'FFLAGS', 'FLIBS', 'FPICFLAGS']
#write_Rconfig_table_from_file(out, Node_rdir, Fortran77_vars)
#write_SysCommandVersion_from_file(out, Node_rdir, 'F77')
#out.write('</DIV>\n')
#
#out.write('<HR>\n')
#out.write('<H2>Fortran 9x compiler</H2>\n')
#out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
#Fortran9x_vars = ['FC', 'FCFLAGS', 'FCPICFLAGS']
#write_Rconfig_table_from_file(out, Node_rdir, Fortran9x_vars)
#write_SysCommandVersion_from_file(out, Node_rdir, 'FC')
#out.write('</DIV>\n')
#
#out.write('<HR>\n')
out.write('<P>More information might be added in the future...</P>\n')
out.write('</BODY>\n')
out.write('</HTML>\n')
out.close()
print("OK")
return aboutnode_page
def make_all_aboutnode_pages(long_link=False):
products_in_rdir = BBSvars.products_in_rdir
for node in BBSreportutils.NODES:
if node.buildbin == None: # foreign node
continue
Node_rdir = products_in_rdir.subdir(node.node_id)
aboutnode_page = make_aboutnode_page(Node_rdir, node, long_link)
node2aboutpage[node.node_id] = aboutnode_page
return
### Make local copy (and rename) R-instpkgs.txt file.
### Returns the 2-string tuple containing the filename of the generated page
### and the number of installed pkgs.
def make_Rinstpkgs_page(Node_rdir, node, long_link=False):
page_title = 'R packages installed on %s' % node.node_id
Rinstpkgspage = '%s-R-instpkgs.html' % node.node_id
print("BBS> [make_Rinstpkgs_page] Write %s in %s/ ..." % \
(Rinstpkgspage, os.getcwd()), end=" ")
sys.stdout.flush()
out = open(Rinstpkgspage, 'w')
write_HTML_header(out, page_title, 'report.css')
out.write('<BODY>\n')
write_goback_links(out, long_link=long_link)
write_timestamp(out)
out.write('<H2><SPAN class="%s">%s</SPAN></H2>\n' % \
(node.hostname.replace(".", "_"), page_title))
out.write('<BR>\n')
out.write('<DIV class="%s">\n' % node.hostname.replace(".", "_"))
filename = 'NodeInfo/R-instpkgs.txt'
out.write('<PRE>\n')
f = Node_rdir.WOpen(filename)
nline = 0
for line in f:
out.write(bbs.parse.bytes2str(line))
nline += 1
f.close()
out.write('</PRE>\n')
out.write('</DIV></BODY>\n')
out.write('</HTML>\n')
out.close()
print("OK")
return (Rinstpkgspage, str(nline-1))
def make_all_Rinstpkgs_pages(long_link=False):
products_in_rdir = BBSvars.products_in_rdir
for node in BBSreportutils.NODES:
if node.buildbin == None: # foreign node
continue
Node_rdir = products_in_rdir.subdir(node.node_id)
(Rinstpkgspage, Rinstpkgcount) = make_Rinstpkgs_page(Node_rdir, node,
long_link)
node2Rinstpkgspage[node.node_id] = Rinstpkgspage
node2Rinstpkgcount[node.node_id] = Rinstpkgcount
return
def write_node_specs_table(out, aboutnode_dir='.', long_link=False):
out.write('<TABLE class="node_specs">\n')
out.write('<TR>')
out.write('<TH>Hostname</TH>')
out.write('<TH>OS</TH>')
out.write('<TH>Arch (*)</TH>')
out.write('<TH>R version</TH>')
out.write('<TH style="text-align: right;">Installed pkgs</TH>')
out.write('</TR>\n')
products_in_rdir = BBSvars.products_in_rdir
for node in BBSreportutils.NODES:
if node.buildbin == None: # foreign node
continue
Node_rdir = products_in_rdir.subdir(node.node_id)
aboutnode_page = node2aboutpage[node.node_id]
aboutnode_url = '%s/%s' % (aboutnode_dir, aboutnode_page)
Rversion_html = read_Rversion(Node_rdir)
Rinstpkgspage = node2Rinstpkgspage[node.node_id]
Rinstpkgcount = node2Rinstpkgcount[node.node_id]
Rinstpkgs_url = '%s/%s' % (aboutnode_dir, Rinstpkgspage)
out.write('<TR class="%s">' % node.hostname.replace(".", "_"))
out.write('<TD><B><A href="%s"><B>%s</B></A></B></TD>' % (aboutnode_url, node.node_id))
out.write('<TD>%s</TD>' % node.os_html)
out.write('<TD>%s</TD>' % node.arch)
out.write('<TD>%s</TD>' % Rversion_html)
out.write('<TD style="text-align: right;">')
out.write('<A href="%s">%s</A>' % (Rinstpkgs_url, Rinstpkgcount))
out.write('</TD>')
out.write('</TR>\n')
out.write('<TR>')
out.write('<TD COLSPAN="5" style="font-size: smaller;">')
out.write('<I>Click on any hostname to see more info ')
out.write('about the system (e.g. compilers)')
out.write(' ')
out.write('(*) as reported by \'uname -p\', ')
out.write('except on Windows and Mac OS X</I>')
out.write('</TD>')
out.write('</TR>\n')
out.write('</TABLE>\n')
return
##############################################################################
### write_vcs_meta_for_pkg_as_TABLE()
##############################################################################
def _make_link_with_mouseover(url, content):
onmouseover = 'add_class_mouseover(this);'
onmouseout = 'remove_class_mouseover(this);'
return '<A href="%s" onmouseover="%s" onmouseout="%s">%s</A>' % \
(url, onmouseover, onmouseout, content)
def _keyval_as_HTML(key, val, inject_nbsp_in_key=True):
if inject_nbsp_in_key:
key = key.replace(' ', ' ')
val = val.replace(' ', ' ')
return '%s: <SPAN class="svn_info">%s</SPAN>' % (key, val)
def _write_keyval_as_TD(out, key, val):
html = _keyval_as_HTML(key, val)
out.write('<TD class="svn_info">%s</TD>' % html)
return
def _write_pkg_keyval_as_TD(out, pkg, key):
val = BBSreportutils.get_vcs_meta(pkg, key)
_write_keyval_as_TD(out, key, val)
return
def _write_Date_as_TD(out, pkg, key, full_line=True):
val = BBSreportutils.get_vcs_meta(pkg, key)
if not full_line:
val = ' '.join(val.split(' ')[0:3])
_write_keyval_as_TD(out, key, val)
return
def _write_LastChange_as_TD(out, pkg, key, with_Revision=False):
val = BBSreportutils.get_vcs_meta(pkg, key)
html = _keyval_as_HTML(key, val)
if with_Revision:
key2 = 'Revision'
val2 = BBSreportutils.get_vcs_meta(pkg, key2)
html2 = _keyval_as_HTML(key2, val2)
html = '%s / %s' % (html, html2)
out.write('<TD class="svn_info">%s</TD>' % html)
return
def _write_svn_info_for_pkg_as_TRs(out, pkg, full_info=False):
if full_info:
out.write('<TR>')
_write_Date_as_TD(out, None, 'Snapshot Date', full_info)
out.write('</TR>\n')
out.write('<TR>')
_write_pkg_keyval_as_TD(out, pkg, 'URL')
out.write('</TR>\n')
out.write('<TR>')
_write_LastChange_as_TD(out, pkg, 'Last Changed Rev', True)
out.write('</TR>\n')
out.write('<TR>')
_write_Date_as_TD(out, pkg, 'Last Changed Date', full_info)
out.write('</TR>\n')
return
def _write_git_log_for_pkg_as_TRs(out, pkg, full_info=False):
## metadata other than snapshot date exists only for individual pkg repos
if pkg == None:
out.write('<TR>')
key = 'Approx. Package Snapshot Date/Time '
key = key.replace(' ', ' ')
key += '(<SPAN style="font-family: monospace;">git pull</SPAN>)'
val = BBSreportutils.get_vcs_meta(None, 'Snapshot Date')
if not full_info:
val = ' '.join(val.split(' ')[0:3])
html = _keyval_as_HTML(key, val, inject_nbsp_in_key=False)
out.write('<TD class="svn_info">%s</TD>' % html)
out.write('</TR>\n')
else:
if full_info:
out.write('<TR>')
_write_Date_as_TD(out, None, 'Snapshot Date', full_info)
out.write('</TR>\n')
out.write('<TR>')
_write_pkg_keyval_as_TD(out, pkg, 'git_url')
out.write('</TR>\n')
out.write('<TR>')
_write_pkg_keyval_as_TD(out, pkg, 'git_branch')
out.write('</TR>\n')
out.write('<TR>')
_write_LastChange_as_TD(out, pkg, 'git_last_commit', False)
out.write('</TR>\n')
out.write('<TR>')
_write_Date_as_TD(out, pkg, 'git_last_commit_date', full_info)
out.write('</TR>\n')
return
def write_vcs_meta_for_pkg_as_TABLE(out, pkg, full_info=False):
out.write('<TABLE class="svn_info">\n')
if BBSvars.MEAT0_type == 1:
_write_svn_info_for_pkg_as_TRs(out, pkg, full_info)
else:
_write_git_log_for_pkg_as_TRs(out, pkg, full_info)
out.write('</TABLE>\n')
return
##############################################################################
### write_explain_glyph_table()
##############################################################################
def _get_stage_labels():
stage_labels = []
buildtype = BBSvars.buildtype
for stage in BBSreportutils.stages_to_display(buildtype):
stage_labels.append(BBSreportutils.stage_label(stage))
return stage_labels
## Produce a SPAN element.
def _status_as_glyph(status):
html = status
if status != 'skipped':
html = ' %s ' % html
return '<SPAN class="glyph %s">%s</SPAN>' % (status, html)
## Produce a TD element (table cell).
def _write_glyph_box(out, status, toggleable=False):
if toggleable:
toggle_id = '%s_toggle' % status.lower()
onmouseover = 'add_class_mouseover(this);'
onmouseout = 'remove_class_mouseover(this);'
onclick = 'filter_gcards(\'%s\');' % status.lower()
TD_attrs = ['class="glyph_box toggle"',
'id="%s"' % toggle_id,
'onmouseover="%s"' % onmouseover,
'onmouseout="%s"' % onmouseout,
#'onkeypress="%s"' % onclick,
'onclick="%s"' % onclick,
'style="width: 110px;"']
checkbox_id = '%s_checkbox' % status.lower()
checkbox_attrs = 'id="%s" style="margin: 0px; padding: 0px;"' % \
checkbox_id
checkbox_html = '<INPUT type="checkbox" checked %s>' % checkbox_attrs
else:
TD_attrs = ['class="glyph_box"']
checkbox_html = ''
TD1_style = 'text-align: left; padding-left: 3px; padding-right: 3px;'
TD1_html = '<TD style="%s">%s</TD>' % (TD1_style, _status_as_glyph(status))
TD2_style = 'text-align: right; padding-right: 2px;'
TD2_html = '<TD style="%s">%s</TD>' % (TD2_style, checkbox_html)
TABLE_html = '<TABLE><TR>%s%s</TR></TABLE>' % (TD1_html, TD2_html)
out.write('<TD %s>%s</TD>\n' % (' '.join(TD_attrs), TABLE_html))
return
def _write_glyph_as_TR(out, status, explain_html, toggleable=False):
out.write('<TR>\n')
_write_glyph_box(out, status, toggleable)
out.write('<TD class="glyph_explain">%s</TD>\n' % explain_html)
out.write('</TR>\n')
return
def _explain_TIMEOUT_in_HTML(stage_labels):
labels = []
times = []
if 'INSTALL' in stage_labels:
labels.append('INSTALL')
times.append(int(BBSvars.INSTALL_timeout / 60.0))
if 'BUILD' in stage_labels:
labels.append('BUILD')
times.append(int(BBSvars.BUILD_timeout / 60.0))
if 'CHECK' in stage_labels:
labels.append('CHECK')
times.append(int(BBSvars.CHECK_timeout / 60.0))
if 'BUILD BIN' in stage_labels:
labels.append('BUILD BIN')
times.append(int(BBSvars.BUILDBIN_timeout / 60.0))
if len(labels) == 1:
html = labels[0]
else:
html = '%s or %s' % (', '.join(labels[:-1]), labels[-1])
html += ' of package took more than '
same_times = times[:-1] == times[1:]
if same_times:
html += str(times[0])
else:
times = [str(t) for t in times]
html += '%s or %s' % (', '.join(times[:-1]), times[-1])
html += ' minutes'
if not same_times:
html += ', respectively'
return html
def _explain_ERROR_in_HTML(stage_labels):
labels = stage_labels.copy()
if len(labels) == 1 and labels[0] == 'CHECK':
html = 'CHECK of package produced errors'
else:
CHECK_in_labels = 'CHECK' in labels
if CHECK_in_labels:
labels.remove('CHECK')
if len(labels) == 1:
html = labels[0]
else:
html = '%s or %s' % (', '.join(labels[:-1]), labels[-1])
html += ' of package failed'
if CHECK_in_labels:
html += ', or CHECK produced errors'
return 'Bad DESCRIPTION file, or ' + html
def _explain_WARNINGS_in_HTML():
return 'CHECK of package produced warnings'
def _explain_OK_in_HTML(stage_labels, simple_layout=False):
if len(stage_labels) == 1:
html = stage_labels[0]
else:
conjunction = 'and' if simple_layout else 'or'
html = '%s %s %s' % \
(', '.join(stage_labels[:-1]), conjunction, stage_labels[-1])
return html + ' of package went OK'
def _explain_NotNeeded_in_HTML():
return 'INSTALL of package was not needed ' + \
'(click on glyph to see why)'
def _explain_NA_in_HTML(stage_labels):
if len(stage_labels) == 1:
html = stage_labels[0]
else:
html = '%s or %s' % (', '.join(stage_labels[:-1]), stage_labels[-1])
html += ' result is not available because' + \
' of an anomaly in the Build System'
return html
def _explain_skipped_in_HTML(stage_labels):
labels = []
if 'CHECK' in stage_labels:
labels.append('CHECK')
if 'BUILD BIN' in stage_labels:
labels.append('BUILD BIN')
if len(labels) == 1:
html = labels[0]
else:
html = '%s or %s' % (', '.join(labels[:-1]), labels[-1])
html += ' of package was skipped because the BUILD step failed'
return html
### FH: Create checkboxes to select display types
def write_explain_glyph_table(out, simple_layout=False):
buildtype = BBSvars.buildtype
wide_table = simple_layout or \
not BBSreportutils.display_propagation_status(buildtype)
out.write('<FORM action="">\n')
styles = ['width: %s' % ('800px' if wide_table else '620px'),
'border: solid black 1px',
'border-collapse: collapse']
out.write('<TABLE style="%s">\n' % ';'.join(styles))
out.write('<TR>\n')
out.write('<TD COLSPAN="2" style="font-style: italic; border-bottom: solid black 1px;">')
out.write('<B>Package status is indicated by one of the following glyphs</B>')
out.write('</TD>\n')
out.write('</TR>\n')
stage_labels = _get_stage_labels()
explain_html = _explain_TIMEOUT_in_HTML(stage_labels)
_write_glyph_as_TR(out, "TIMEOUT", explain_html, True)
explain_html = _explain_ERROR_in_HTML(stage_labels)
_write_glyph_as_TR(out, "ERROR", explain_html, True)
if 'CHECK' in stage_labels:
explain_html = _explain_WARNINGS_in_HTML()
_write_glyph_as_TR(out, "WARNINGS", explain_html, True)
explain_html = _explain_OK_in_HTML(stage_labels, simple_layout)
_write_glyph_as_TR(out, "OK", explain_html, True)
## "NotNeeded" glyph (only used when "smart STAGE2" is enabled i.e.
## when STAGE2 skips installation of target packages not needed by
## another target package for build or check).
#if buildtype not in ["workflows", "books", "bioc-longtests"]:
# _write_glyph_as_TR(out, "NotNeeded", _explain_NotNeeded_in_HTML())
explain_html = _explain_NA_in_HTML(stage_labels)
_write_glyph_as_TR(out, "NA", explain_html)
if not simple_layout and \
('CHECK' in stage_labels or 'BUILD BIN' in stage_labels):
explain_html = _explain_skipped_in_HTML(stage_labels)
_write_glyph_as_TR(out, "skipped", explain_html)
out.write('<TR>\n')
out.write('<TD COLSPAN="2" style="font-style: italic; border-top: solid black 1px;">')
out.write('Click on any glyph in the report below ')
out.write('to access the detailed report.')
out.write('</TD>\n')
out.write('</TR>\n')
out.write('</TABLE>\n')
out.write('</FORM>\n')
return
##############################################################################
### Glyph cards (gcards) and gcard lists
##############################################################################
class LeafReportReference:
def __init__(self, pkg, node_hostname, node_id, stage):
self.pkg = pkg
self.node_hostname = node_hostname
self.node_id = node_id
self.stage = stage
def _get_all_show_classes():
status_classes = ['timeout', 'error', 'warnings', 'ok']
return ['show_%s_gcards' % status for status in status_classes]
def _write_vertical_space(out):
ncol_to_display = BBSreportutils.ncol_to_display(BBSvars.buildtype)
TD_html = '<TD COLSPAN="%s"></TD>' % (ncol_to_display + 5)
out.write('<TR class="vertical_space">%s</TR>\n' % TD_html)
return
def _url_to_pkg_landing_page(pkg):
buildtype = BBSvars.buildtype
if buildtype == "cran":
return "https://cran.rstudio.com/package=%s" % pkg
bioc_version = BBSvars.bioc_version
if buildtype == "books":
return "/books/%s/%s/" % (bioc_version, pkg)
#if buildtype == "data-annotation":
# repo = "data/annotation"
#elif buildtype == "data-experiment":
# repo = "data/experiment"
#elif buildtype == "workflows":
# repo = "workflows"
#else:
# repo = "bioc"
#url = "/packages/%s/%s/html/%s.html" % (bioc_version, repo, pkg)
## Use short URL:
url = "/packages/%s/%s" % (bioc_version, pkg)
return url
def _pkgname_as_HTML(pkg, pkgdir=None):
if pkgdir == None:
return pkg
return '<A href="%s/">%s</A>' % (pkgdir, pkg)
def _pkgname_and_version_as_HTML(pkg, version, pkgdir=None, deprecated=False):
html1 = '<B>%s %s</B>' % (_pkgname_as_HTML(pkg, pkgdir), version)
if deprecated:
html1 = '<s>%s</s>' % html1
url = _url_to_pkg_landing_page(pkg)
SPANcontent = '(<A href="%s">landing page</A>)' % url
SPANstyle = 'font-size: smaller; font-style: italic;'
html2 = '<SPAN style="%s">%s</SPAN>' % (SPANstyle, SPANcontent)
return '%s %s' % (html1, html2)
def _node_OS_Arch_as_SPAN(node):
return '<SPAN style="font-size: smaller;">%s / %s</SPAN>' % \
(node.os_html, node.arch)
def _write_node_spec_as_TD(out, node, spec_html, selected=False):
TDclasses = node.hostname.replace(".", "_")
if selected:
TDclasses += ' selected'
out.write('<TD class="%s">%s</TD>' % (TDclasses, spec_html))
return
def _write_pkg_status_as_TD(out, pkg, node, stage,
topdir='.', leafreport_ref=None):
selected = leafreport_ref != None and \
pkg == leafreport_ref.pkg and \
node.node_id == leafreport_ref.node_id and \
stage == leafreport_ref.stage
TDclasses = 'status %s %s' % (node.hostname.replace(".", "_"), stage)
if selected:
TDclasses += ' selected'
status = BBSreportutils.get_pkg_status(pkg, node.node_id, stage)
if status in ["skipped", "NA"]:
TDcontent = _status_as_glyph(status)
else:
if leafreport_ref == None:
pkgdir = '%s/%s' % (topdir, pkg)
else:
pkgdir = '.'
url = BBSreportutils.get_leafreport_rel_url(pkgdir, node.node_id, stage)
TDcontent = _make_link_with_mouseover(url, _status_as_glyph(status))
out.write('<TD class="%s">%s</TD>' % (TDclasses, TDcontent))
return
def write_stagelabel_as_TD(out, stage, leafreport_ref):
selected = leafreport_ref != None and \
stage == leafreport_ref.stage
TDclasses = 'STAGE %s' % stage
if selected:
TDclasses += ' selected'
stage_label = BBSreportutils.stage_label(stage)
TD_html = '<TD class="%s">%s</TD>' % (TDclasses, stage_label)
out.write(TD_html)
return
def write_pkg_stagelabels_as_TDs(out, leafreport_ref=None):
buildtype = BBSvars.buildtype
for stage in BBSreportutils.stages_to_display(buildtype):
write_stagelabel_as_TD(out, stage, leafreport_ref)
if BBSreportutils.display_propagation_status(buildtype):
out.write('<TD style="width: 12px;"></TD>')
return
def write_pkg_propagation_status_as_TD(out, pkg, node):
status = BBSreportutils.get_propagation_status_from_db(pkg, node.hostname)
if status == None:
TDcontent = ''
else:
IMGstyle = 'border: 0px; width: 10px; height: 10px;'
if "/" in out.name:
path = "../"
else:
path = "./"
if status.startswith("YES"):
color = "Green"
elif status.startswith("NO"):
color = "Red"
else: # "UNNEEDED"
color = "Blue"
IMGsrc = '%s120px-%s_Light_Icon.svg.png' % (path, color)
TDcontent = '<IMG style="%s" alt="%s" title="%s" src="%s">' % \
(IMGstyle, status, status, IMGsrc)
out.write('<TD class="status %s">%s</TD>' % \
(node.hostname.replace(".", "_"), TDcontent))
return
def write_pkg_statuses_as_TDs(out, pkg, node,
topdir='.', leafreport_ref=None):
TDclasses = 'status %s' % node.hostname.replace(".", "_")
buildtype = BBSvars.buildtype
ncol_to_display = BBSreportutils.ncol_to_display(buildtype)
if pkg in skipped_pkgs:
TDattrs = 'COLSPAN="%s" class="%s"' % (ncol_to_display, TDclasses)
TDcontent = _status_as_glyph('ERROR')
TDcontent += ' (Bad DESCRIPTION file)'
out.write('<TD %s>%s</TD>' % (TDattrs, TDcontent))
elif not BBSreportutils.is_supported(pkg, node):
TDattrs = 'COLSPAN="%s" class="%s"' % (ncol_to_display, TDclasses)
TDcontent = '... NOT SUPPORTED ...'
TDcontent = '%s' % TDcontent.replace(' ', ' ')
out.write('<TD %s>%s</TD>' % (TDattrs, TDcontent))
else:
for stage in BBSreportutils.stages_to_display(buildtype):
if stage != 'buildbin' or BBSreportutils.is_doing_buildbin(node):
_write_pkg_status_as_TD(out, pkg, node, stage,
topdir, leafreport_ref)
else:
out.write('<TD class="%s"></TD>' % TDclasses)
if BBSreportutils.display_propagation_status(buildtype):
write_pkg_propagation_status_as_TD(out, pkg, node)
return
### Produce 2 full TRs.
def write_abc_dispatcher_within_gcard_list(out, current_letter):
## FH: Need the collapsable_rows class to blend out the alphabetical
## selection when "ok" packages are unselected.
out.write('<TBODY class="abc_dispatcher collapsable_rows">\n')
_write_vertical_space(out)
out.write('<TR class="abc">')
out.write('<TD COLSPAN="2">')
out.write('<TABLE class="big_letter"><TR><TD>')
out.write('<A name="%s">%s</A>' % \
(current_letter, current_letter))
out.write('</TD></TR></TABLE>')
out.write('</TD>')
ncol_to_display = BBSreportutils.ncol_to_display(BBSvars.buildtype)
out.write('<TD COLSPAN="%s">' % (ncol_to_display + 3))
write_abc_dispatcher(out, "", current_letter)
out.write('</TD>')
out.write('</TR>\n')
out.write('</TBODY>\n')
return
def statuses2classes(statuses):
classes = []
if "TIMEOUT" in statuses:
classes.append("timeout")
if "ERROR" in statuses:
classes.append("error")
if "WARNINGS" in statuses:
classes.append("warnings")
## A package is tagged with the "ok" class if it's not tagged with any of
## the "timeout", "error" or "warnings". Note that this means that
## a package could end up being tagged with the "ok" class even if it
## doesn't have any OK in 'statuses' (e.g. if it's unsupported on all
## platforms).
if len(classes) == 0:
classes = ["ok"]
return ' '.join(classes)
def write_quickstats_TD(out, quickstats, node, stage):
stats = quickstats[node.node_id][stage]
html = '<TABLE class="quickstats"><TR>'
html += '<TD class="glyph %s">%d</TD>' % ("TIMEOUT", stats[0])
html += '<TD class="glyph %s">%d</TD>' % ("ERROR", stats[1])
if stage == 'checksrc':
html += '<TD class="glyph %s">%d</TD>' % ("WARNINGS", stats[2])
html += '<TD class="glyph %s">%d</TD>' % ("OK", stats[3])
# Only relevant when "smart STAGE2" is enabled.
#if stage == 'install':
# html += '<TD class="glyph %s">%d</TD>' % ("NotNeeded", stats[4])
html += '</TR></TABLE>'
out.write('<TD>%s</TD>' % html)
return
### The quick stats span several table rows (TRs).
def write_quickstats(out, quickstats, no_links, selected_node=None):
out.write('<THEAD class="quickstats">\n')
out.write('<TR class="header">')
TDclass = 'leftmost top_left_corner'
TDstyle = 'padding-left: 0px;'
out.write('<TD COLSPAN="3" class="%s" style="%s">QUICK STATS</TD>' % \
(TDclass, TDstyle))
out.write('<TD>OS / Arch</TD>')
write_pkg_stagelabels_as_TDs(out)
out.write('<TD class="rightmost top_right_corner"></TD>')
out.write('</TR>\n')
nb_nodes = len(BBSreportutils.NODES);
## Find index of last non foreign node.
last_non_foreign_ix = -1
for i in range(nb_nodes):
node = BBSreportutils.NODES[i]
if node.buildbin == None: # foreign node
continue
last_non_foreign_ix = i
for i in range(nb_nodes):
node = BBSreportutils.NODES[i]
if node.buildbin == None: # foreign node
continue
is_last = i == last_non_foreign_ix
selected = toned_down = False
TRclasses = node.hostname.replace(".", "_")
if selected_node != None:
if selected_node == node.node_id:
selected = True
TRclasses += ' selected_row'
else:
toned_down = True
TRclasses += ' toned_down'
out.write('<TR class="%s">' % TRclasses)