[03c004]: nightly.py  Maximize  Restore  History

Download this file

1819 lines (1562 with data), 67.9 kB

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Rajarshi Guha <rajarshi.guha@gmail.com>
# 04/30/2006
#
# Requires a Unix system, for now
#
# Requires on the path: java, ant, svn, nice, rm, tar
# Optionally on the path: dot (from graphviz)
#
# Python requirements: Python 2.4, libxml & libxslt bindings
#
# Environment requirements: JAVA_HOME and ANT_HOME should be set
#
# Also you should have Beanshell and JGraphT installed and specified
# in the classpath variable below. However if specified as "" or None
# then no dependency graph is generated
#
# Code coverage is now measured using Emma. The emma.jar should be
# specified in the classpath variable below
#
# Update 05/01/2006 - Added suggestions from Egon: link to sf.net,
# added a title to the HTML page, links to
# build output, link to a JUnit summary, link
# to dependency graphs
# Update 05/05/2006 - Added JAPI comparison. Checked for required
# executables and env vars
# Update 05/07/2006 - Added a command line option to prevent mail
# from being sent. Also replaced the system() to
# tar with calls to the tarfile python module.
# Added some more checks
# Update 05/08/2006 - Added checks for JVM segfaults
# Update 05/13/2006 - Added the output of ant info
# Update 05/15/2006 - Added a link to the CDK SVN commits page
# Update 05/16/2006 - Added code to generate and provide the source distribution
# Update 05/17/2006 - Updated the code to use a seperate class for HTML tables
# and cells. This allows easier generation of table contents
# and not have to worry about <tr> and <td> tags and so on.
# Also added a link to the keyword list
# Update 06/04/2006 - Some bugfixes to the output as well as some more checks for
# robustness
# Update 06/05/2006 - Fixed the keyword task
# Update 06/07/2006 - Added code to parse the output of pmd-unused reports and add
# a summary page to the corresponding section
# Update 06/08/2006 - Reorganized to summarize PMD reports in terms of total number
# of violations and linked to actual PMD report pages. Updated
# keywords section to point to the local API docs
# Update 06/26/2006 - Added column totals to the JUnit summary page
# Update 07/03/2006 - Added the bug analysis section. Also trapped exceptions from the
# bug analysis code
# Update 07/31/2006 - Added success rate to junit summary. Added some code to cleanup
# japize files
# Update 08/01/2006 - Made some error cases more consistent
# Update 09/18/2006 - Added current time to the title
# Update 09/20/2006 - Updated to wrap Junit result files in HTML tags
# Update 09/24/2006 - Updated to include revision info in the title
# Update 11/27/2006 - Fixed a bug in parsing the Junit log output. Also provides
# visual identification of JUnit crashes
# Update 11/29/2006 - Added code coverage with Emma
# Update 12/10/2006 - Added code to allow for sending emails via a SMTP server
# that requires a password/login. Also added a check for
# Gmail server, since they require a TLS setup. Also added
# code to redact the email password and login's if specified
# Update 12/20/2006 - Fixed the regexes to take into account new modules
# Update 02/10/2007 - Updated to change the value of version in the property file
# rather than hard code it as a date stamp in the build script
# Update 02/19/2007 - Updated to process CDKCite errors
# Update 10/26/2007 - Updated for new test.modulesuites package
# Update 09/19/1009 - Updated for API location change (fixes #2833020)
import string, sys, os, os.path, time, re, glob, shutil, pickle
import tarfile, StringIO
import datetime
from email.MIMEText import MIMEText
import email.Utils
import smtplib
#################################################################
#
# NO NEED TO CHANGE ANYTHING BELOW HERE
#
#################################################################
debug = False
pickle_file = None
today = time.localtime()
todayStr = '%04d%02d%02d' % (today[0], today[1], today[2])
todayNice = '%04d-%02d-%02d' % (today[0], today[1], today[2])
dryRun = False
firstTime = False
haveXSLT = True
noMail = False
bugStats = True
# check to see if we have libxml2 and libxslt
try:
import libxml2
import libxslt
except ImportError:
haveXSLT = False
print 'Will not tranlate PMD XML output'
class TableCell:
_valign = 'top'
_align = 'left'
_bgcolor = None
_text = None
_klass = None
def __init__(self, text, valign = 'top', align = 'left', klass=None):
self._text = text
self._valign = valign
self._align = align
self._klass = klass
def setVAlign(self, pos):
self._valign = pos
def setAlign(self, pos):
self._align = pos
def appendText(self, text):
self._text = self._text + text
def getText(self):
return self._text
def __repr__(self):
if self._klass:
return """
<td class=\"%s\" align=\"%s\" valign=\"%s\">
%s
</td>
""" % (self._klass, self._align, self._valign, self._text)
else: return """
<td align=\"%s\" valign=\"%s\">
%s
</td>
""" % (self._align, self._valign, self._text)
class HTMLTable:
rows = []
currentRow = None
headerCells = []
_border = 0
_cellspacing = 5
def __init__(self, border = 0, cellspacing = 5):
self._border = border
self._cellspacing = cellspacing
def getCellCount(self):
return len(rows[curretRow])
def addRow(self):
self.rows.append( [] )
if self.currentRow == None: self.currentRow = 0
else: self.currentRow = self.currentRow+1
def addRule(self):
self.addRow()
self.addCell("HTMLTABLE_HRULE")
def addHeaderCell(self, text, valign='top', align='left', klass = None):
self.headerCells.append(TableCell(text, valign, align, klass))
def addCell(self, text, whichRow = None, valign='top', align='left', klass = None):
"""
Adds a cell to the current row if whichRow == None
"""
if not text: return
if whichRow == None:
cellList = self.rows[self.currentRow]
cellList.append(TableCell(text, valign, align, klass))
self.rows[self.currentRow] = cellList
elif whichRow > self.currentRow: raise IndexError("Invalid row index was specified")
else:
cellList = self.rows[whichRow]
cellList.append(TableCell(text, valign, align, klass))
self.rows[whichRow] = cellList
def appendToCell(self, text, newline = True):
"""
Appends text to the current cell in the current row
"""
if not text: return
cellList = self.rows[self.currentRow]
if newline: cellList[ len(cellList)-1 ].appendText("<br>"+text)
else: cellList[ len(cellList)-1 ].appendText(text)
self.rows[self.currentRow] = cellList
def __repr__(self):
# we want to pad the shorter rows with empty cells
maxRowLen = max(map(len, self.rows))
table = StringIO.StringIO()
table.write("<table border=%d cellspacing=%d>\n" % (self._border, self._cellspacing))
# write out the header row
table.write("<thead>\n<tr>\n")
for headerCell in self.headerCells: table.write(headerCell)
table.write("</tr></thead>\n")
# now write the rest of the rows
for row in self.rows:
table.write("<tr>\n")
if len(row) == 1 and row[0].getText() == 'HTMLTABLE_HRULE':
table.write('<td colspan=%d><hr></td>\n</tr>\n' % (maxRowLen))
continue
for cell in row:
table.write(cell)
if len(row) != maxRowLen:
for i in range(maxRowLen-len(row)):
table.write(TableCell(""))
table.write("\n</tr>\n")
table.write("\n</table>\n")
return table.getvalue()
def sendMail(message, subject = 'CDK Nightly Trunk Build Failed'):
if fromName == "" or fromName == None \
or toName == "" or toName == None \
or smtpServerName == "" or smtpServerName == None:
print 'Skipping mail'
return
try:
msg = MIMEText(message)
msg['Subject'] = '%s - %s' % (subject,todayNice)
msg['Message-id'] = email.Utils.make_msgid()
msg['From'] = fromName
msg['To'] = toName
server = smtplib.SMTP(smtpServerName)
if smtpServerName.find('gmail.com') != -1:
server.ehlo()
server.starttls()
server.ehlo()
if smtpLogin != "None" and smtpPassword != "None":
server.login(smtpLogin, smtpPassword)
server.sendmail(fromName, toName, msg.as_string())
server.quit()
print 'Sent mail to %s' % (toName)
except Exception, e:
print e
def transformXML2HTML(src, dest, xsltFile, pmd=True):
if haveXSLT: # if we have the proper libs do the xform
print ' Transforming %s' % (src)
try:
styleDoc = libxml2.parseFile(xsltFile)
except libxml2.parserError:
return False
style = libxslt.parseStylesheetDoc(styleDoc)
try:
doc = libxml2.parseFile(src)
except libxml2.parserError:
return False
result = style.applyStylesheet(doc, None)
htmlString = style.saveResultToString(result)
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()
# we need to add a bit to the HTML output to indicate what file was processed
# if we are doing the transform for PMD
if pmd:
prefix = os.path.basename(dest).split('.')[0]
htmlString = re.sub('Report</div>', 'Report [<i>module - %s</i>]</div>' % (prefix), htmlString)
f = open(dest, 'w')
f.write(htmlString)
f.close()
return True
else: # cannot xform, so just copy the XML file
shutil.copyfile(src, dest)
return False
def writeJunitSummaryHTML(stats, testCoverage = None, stable=True, verbose=True):
unstableModules = []
if not stable and len(unstableModules) == 0: return None
pagetype = 'Stable'
if not stable: pagetype = 'Unstable'
if verbose: print ' Processing for %s' % (pagetype)
summary = """
<html>
<head>
<title>CDK JUnit Test Summary (%s) [%s]</title>
<style type="text/css">
tr.crash { background-color: #F778A1;}
td.cov { color: #A5A5A5; }
</style>
</head>
<body>
<center>
<h2>CDK JUnit Test Summary (%s) [%s]</h2>
<table border="0" cellspacing="5" cellpadding="3">
<thead>
<tr>
<td valign="top" align="center"><b>Module</b></td>
<td valign="top" align="center"><b>Number<br />of Tests</b></td>
<td valign="top" align="center"><b>Failed</b></td>
<td valign="top" align="center"><b>Errors</b></td>
<td valign="top" align="center"><b>Success<br />Rate (%%)</b></td>
<td valign="top" align="center"><b>Missing Test<br />Coverage</b></td>
</tr>
</thead>
<tr>
<td colspan="6"><hr /></td>
</tr>
""" % (todayNice, pagetype, todayNice, pagetype)
totalTest = 0
totalFail = 0
totalError = 0
totalMissingMethod = 0
totalMissingClass = 0
for entry in stats:
if stable and (entry[0] in unstableModules): continue
if not stable and entry[0] not in unstableModules: continue
if int(entry[1]) != -1:
totalTest = totalTest + int(entry[1])
totalFail = totalFail + int(entry[2])
totalError = totalError + int(entry[3])
else:
summary = summary + "<tr class='crash'>"
summary = summary + "<td align=\"left\"><a href=\"test/result-%s.html\">%s</a> [<b>CRASHED</b>]</td>" % (entry[0], entry[0])
summary = summary + "<td></td><td></td><td></td><td></td>"
summary = summary + "</tr>"
continue
summary = summary + "<tr>"
summary = summary + "<td align=\"left\"><a href=\"test/result-%s.html\">%s</a></td>" % (entry[0], entry[0])
for i in entry[1:]:
summary = summary + "<td align=\"right\">%s</td>" % (i)
if float(entry[1]) != 0:
summary = summary + "<td align=\"right\">%.2f</td>" % (100*(float(entry[1])-float(entry[2])-float(entry[3]))/float(entry[1]))
else:
summary = summary + "<td align=\"right\">NA</td>"
try:
nmeth,nclass = testCoverage[entry[0]]
summary += '<td class="cov" align="right">%d methods in %d classes</td>' % (nmeth, nclass)
totalMissingMethod += nmeth
totalMissingClass += nclass
except KeyError, e:
print ' No test coverage info for module %s' % (entry[0])
summary += '<td>&#160;</td>'
summary = summary + "</tr>"
if totalTest == 0:
totalTest = 0.000001
summary = summary + """
<tr>
<td colspan="6"><hr /></td>
</tr>
<tr>
<td><b>Totals</b></td>
<td class=\"totalTest\" align=\"right\">%d</td>
<td class=\"totalFail\" align=\"right\">%d</td>
<td class=\"totalError\" align=\"right\">%d</td>
<td align=\"right\">%.2f</td>
<td class=\"cov\" align=\"right\">%d methods in %d classes</td>
</tr>
<tr>
<td colspan="6"><hr /></td>
</tr>
</table>
</center>
</body>
</html>""" % (totalTest, totalFail, totalError, (float(totalTest-totalFail-totalError)/float(totalTest))*100, totalMissingMethod, totalMissingClass)
return summary
def parseJunitCoverage():
coverageDict = {}
testOutputs = glob.glob(os.path.join(nightly_repo, 'reports', 'result-*.txt'))
for testOutput in testOutputs:
moduleName = os.path.basename(testOutput).split('.')[0].split('-')[1]
f = open(testOutput, 'r')
while True:
line = f.readline()
if not line: break
if line.find('Testcase: testCoverage(') == -1: continue
line = f.readline()
regex = re.compile('tests:\s+(\d+)\s+in number of classes: (\d+)')
rematches = regex.findall(line)
nmeth = 0
nclass = 0
if len(rematches) > 0:
nmeth, nclass = rematches[0]
coverageDict[moduleName] = (int(nmeth), int(nclass))
break
return coverageDict
def parseJunitOutput(summaryFile, stable=True):
f = open(os.path.join(nightly_dir,'test.log'), 'r')
stats = []
foundModuleEntry = False
while True:
line = f.readline()
if not line: break
if string.find(line, 'test-module') == 0:
foundModuleEntry = True
if foundModuleEntry:
foundModuleEntry = False
moduleName = f.readline()
moduleStats = None
while True:
moduleStats = f.readline()
if string.find(moduleStats, '[junit] Tests run:') != -1: break
if moduleStats.find("[junit] Tests run:") == -1:
stats.append( (moduleName.split()[5], -1, -1, -1) )
continue
# parse the stats and name of the module
moduleStats = moduleStats.split()
nTest = moduleStats[3][:-1]
nFail = moduleStats[5][:-1]
nError = moduleStats[7][:-1]
stats.append( (moduleName.split()[5], nTest, nFail, nError) )
f.close()
# sort the modules alphabetically
stats.sort(cmp = lambda x,y: cmp(x[0],y[0]))
# get test coverage info
covDict = parseJunitCoverage()
# get an HTML summary
summary = writeJunitSummaryHTML(stats, covDict, stable)
# write out this HTML
if summary:
fileName = os.path.join(nightly_web, summaryFile)
f = open(fileName, 'w')
f.write(summary)
f.close()
return True
else: return False
def parsePMDOutput(pmdReportDir, title=""):
reportDir = os.path.join(nightly_repo, 'reports', pmdReportDir)
if not os.path.exists(reportDir):
print 'Couldnt find %s' % (reportDir)
return None
print ' Parsing PMD report files (%s)' % (pmdReportDir)
xmlFiles = glob.glob(os.path.join(reportDir, '*.xml'))
xmlFiles.sort()
o = StringIO.StringIO()
o.write("""
<html>
<head>
<title>%s (%s) </title>
</head>
<body>
<center>
<h2>%s (%s) </h2>
<table border="0" cellspacing="2">
<thead>
<tr>
<td><b>Module</b></td><td><b>Number of Violations</b></td>
</tr>
</thead>
<tr>
<td colspan="2"><hr /></td>
</tr>
""" % (title, todayNice, title, todayNice))
total = 0
for xmlFile in xmlFiles:
moduleName = os.path.basename(xmlFile).split('.')[0]
f = open(xmlFile, 'r')
vcount = 0
for line in f:
if line.find('<violation') != -1: vcount = vcount + 1
o.write("""
<tr>
<td><a href=\"%s/%s.html\">%s</a></td>
<td align='center'>%d</td>
</tr>
""" % (pmdReportDir, moduleName, moduleName, vcount))
total += vcount
o.write("""
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td>total</td><td class="total">%s</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
</table>
</center>
</body>
</html>""" % (total))
return o.getvalue()
def parseOJDCOutput(ojdcReportDir, title=""):
reportDir = os.path.join(nightly_repo, 'reports', ojdcReportDir)
if not os.path.exists(reportDir):
print 'Couldnt find %s' % (reportDir)
return None
print ' Parsing OpenJavaDocCheck report files (%s)' % (ojdcReportDir)
xmlFiles = glob.glob(os.path.join(reportDir, '*.html'))
xmlFiles.sort()
o = StringIO.StringIO()
o.write("""
<html>
<head>
<title>%s (%s) </title>
</head>
<body>
<center>
<h2>%s (%s) </h2>
<table border="0" cellspacing="2">
<thead>
<tr>
<td><b>Module</b></td><td><b>Number of Violations</b></td>
</tr>
</thead>
<tr>
<td colspan="2"><hr /></td>
</tr>
""" % (title, todayNice, title, todayNice))
total = 0
for xmlFile in xmlFiles:
moduleName = os.path.basename(xmlFile).split('.')[0]
f = open(xmlFile, 'r')
vcount = 0
for line in f:
if line.find('class="violation') != -1: vcount = vcount + 1
o.write("""
<tr>
<td><a href=\"%s/%s.html\">%s</a></td>
<td align='center'>%d</td>
</tr>
""" % (ojdcReportDir, moduleName, moduleName, vcount))
total += vcount
o.write("""
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td>total</td><td class="total">%s</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
</table>
</center>
</body>
</html>""" % (total))
return o.getvalue()
def segvOccured(dir):
"""
Look in dir to see if there are any hs_* files
which indicate a SEGV in the JVM. If found
return True else return False
"""
hsfiles = glob.glob(os.path.join(dir, 'hs_*'))
if len(hsfiles) == 0: return False
else: return True
def checkIfAntJobFailed(logFileName):
"""
Returns True if the specified log file does
not contain the string 'BUILD SUCCESSFUL'
otherwise returns False
"""
f = open(logFileName, 'r')
loglines = f.readlines()
f.close()
loglines = string.join(loglines)
if loglines.find('BUILD SUCCESSFUL') == -1:
return True
else: return False
def getLogFilePath(logFileName):
"""
Creates the full path for a specified log file.
The log files are always placed in the NIGHTLY_DIR which can
be changed by the user"""
return os.path.join(nightly_dir, logFileName)
def updateRepo():
olddir = os.getcwd()
os.chdir(nightly_repo)
status = os.system('git checkout %s' % (git_branch))
if status == 0:
print 'git checkout %s ok' % (git_branch)
else:
print 'git checkout %s failed. Not proceeding' % (git_branch)
os.chdir(olddir)
return False
status = os.system('git pull > %s' % getLogFilePath('git.log'))
if status == 0:
print 'git pull ok'
os.chdir(olddir)
return True
else:
print 'git pull failed'
os.chdir(olddir)
return False
def runAntJob(cmdLine, logFileName, jobName, verbose=False):
if verbose: print cmdLine
olddir = os.getcwd()
os.chdir(nightly_repo)
# clean out any hs_err* files from the repo directory
hsfiles = glob.glob(os.path.join(nightly_repo, 'hs_*'))
for hsfile in hsfiles:
os.unlink(hsfile)
os.system('%s > %s' % (cmdLine, getLogFilePath(logFileName)))
# if a JVM segfault occured we've failed
if segvOccured(nightly_repo):
print '%s failed (JVM segfault)' % (jobName)
return False
# if for some reason a log file was not written we've failed
if not os.path.exists(getLogFilePath(logFileName)):
print '%s failed (no run log)' % (jobName)
return False
if checkIfAntJobFailed( getLogFilePath(logFileName) ):
print '%s failed (compile error)' % (jobName)
os.chdir(olddir)
return False
else:
print '%s ok' % (jobName)
os.chdir(olddir)
return True
def generateCDKDepGraph():
olddir = os.getcwd()
os.chdir(nightly_repo)
if classpath == "" or classpath == None:
print 'classpath not specified. Skipping dependency graph'
return None
if string.find(classpath, 'bsh.jar') == -1 or \
string.find(classpath, 'jgrapht') == -1:
print 'Did not find bsh.jar or the jgrapht jar in \'classpath\''
return None
if not executableExists('dot'):
print 'dot not found. Skipping dependency graph'
return None
os.system('java -cp %s bsh.Interpreter tools/deptodot.bsh > cdkdep.dot' % (classpath))
os.system('/usr/bin/dot -Tpng -o %s/cdkdep.png cdkdep.dot' % (nightly_web))
os.system('/usr/bin/dot -Tps -o %s/cdkdep.ps cdkdep.dot' % (nightly_web))
os.unlink('cdkdep.dot')
celltext = []
celltext.append("Dependency Graph:")
celltext.append("<a href=\"cdkdep.png\">PNG</a> <a href=\"cdkdep.ps\">PS</a>")
os.chdir(olddir)
return celltext
def writeTemporaryPage():
f = open(os.path.join(nightly_web, 'index.html'), 'w')
f.write("""
<html>
<head>
<title>""")
f.write(title_web)
f.write("""
</title>
<style>
<!--
tr:hover { background-color: #efefef; }
//-->
</style>
<head>
<body>
<center>
<h2 title='title'>%s</h2>
<p>
<br><br>
Regenerating Build - Please come back in a while
<center>
</body>
</html>""" % (title_web))
f.close()
def copyLogFile(fileName, srcDir, destDir):
if os.path.exists( os.path.join(srcDir, fileName) ):
shutil.copyfile(os.path.join(srcDir, fileName),
os.path.join(destDir, fileName))
return "<a href=\"%s\">%s</a>" % (fileName, fileName)
else: return None
def executableExists(executable):
found = False
paths = os.environ['PATH']
paths = paths.split(os.pathsep)
if len(paths) == 0: return False
for aPath in paths:
testPath = os.path.join(aPath, executable)
if os.path.exists(testPath) and os.path.isfile(testPath):
found = True
break
return found
def generateJAPI():
olddir = os.getcwd()
os.chdir(nightly_dir)
if japitools_path == "" or japitools_path == None:
print 'japitools_path not specified. Skipping japi'
return None
java_home = None
try:
java_home = os.environ['JAVA_HOME']
except KeyError, ke:
print 'java_home not specified. Skipping japi'
return None
if last_stable == "" or last_stable == None:
print 'last_stable not specified. Skipping japi'
return None
if not os.path.isfile(last_stable):
print 'last_stable specified an invalid file. Skipping japi'
return None
# get the paths to the japi binaries
japize = os.path.join(japitools_path, 'bin', 'japize')
japicompat = os.path.join(japitools_path, 'bin', 'japicompat')
# get path to rt.jar
rtjar = None
if os.path.exists(os.path.join(java_home, 'jre', 'lib', 'rt.jar')):
rtjar = os.path.join(java_home, 'jre', 'lib', 'rt.jar')
elif os.path.exists(os.path.join(java_home, 'lib', 'rt.jar')):
rtjar = os.path.join(java_home, 'jre', 'lib', 'rt.jar')
if rtjar == None:
print 'Cannot find rt.jar. Skipping japi comparison'
return page
oldName = os.path.basename(last_stable).split('.')[0]
oldJapize = os.path.join(nightly_dir, '%s.japi.gz' % (oldName))
newName = 'cdk-svn-%s' % (todayStr)
newJar = os.path.join(nightly_repo, 'dist', 'jar', 'cdk-svn-%s.jar' % (todayStr))
newJapize = os.path.join(nightly_dir, '%s.japi.gz' % (newName))
# run japize on the old cdk and the new one
os.system('%s as %s apis %s %s +org.openscience.cdk 2> japize.log'
% (japize, oldJapize, last_stable, rtjar))
os.system('%s as %s apis %s %s +org.openscience.cdk 2>> japize.log'
% (japize, newJapize, newJar, rtjar))
# in case there was an error
if (os.path.getsize(oldJapize) == 0 or os.path.getsize(newJapize) == 0):
return None
# do the comparison
os.system('%s -vh -o apicomp.html %s %s 2> japi.log'
% (japicompat, oldJapize, newJapize))
# do some regex sub on the apicomp output
lines = open(os.path.join(nightly_dir, 'apicomp.html') , 'r').readlines()
lines = string.join(lines)
lines = re.sub(nightly_dir, '', lines)
f = open(os.path.join(nightly_dir, 'apicomp.html'), 'w')
f.write(lines)
f.close()
# copy output
srcFile = os.path.join(nightly_dir, 'apicomp.html')
destFile = os.path.join(nightly_web, 'apicomp.html')
shutil.copyfile(srcFile, destFile)
# copy japi css so we get a nice webpage
srcFile = os.path.join(japitools_path, 'design', 'japi.css')
destFile = os.path.join(nightly_web, 'japi.css')
shutil.copyfile(srcFile, destFile)
# copy the comparison log file
srcFile = os.path.join(nightly_dir, 'japi.log')
destFile = os.path.join(nightly_web, 'japi.log')
shutil.copyfile(srcFile, destFile)
# make an entry on the page
celltexts = []
celltexts.append("<a href=\"http://www.kaffe.org/~stuart/japi/\">JAPI Comparison")
celltexts.append("<a href=\"apicomp.html\">Summary</a>")
celltexts.append("<a href=\"japi.log\">japicompat.log</a>")
# cleanup
os.unlink(newJapize)
os.unlink(oldJapize)
os.unlink('apicomp.html')
os.chdir(olddir)
return celltexts
def transformJunitResultToHTML(filename):
s = StringIO.StringIO()
lines = open(filename, 'r').readlines()
lines = string.join(lines)
## make some subs to get valid HTML
lines = lines.replace("<","&lt;")
line = lines.replace(">", "&gt;")
s.write("""
<html>
<body>
<pre>
%s
</pre>
</body>
</html>
""" % ( lines ))
return s.getvalue()
def doCodeCoverage():
olddir = os.getcwd()
os.chdir(nightly_repo)
# check that we have emma.jar
comps = classpath.split(':')
foundEmmaJar = False
for i in comps:
if i.find('emma.jar') != -1:
foundEmmaJar = True
if not foundEmmaJar:
print ' emma.jar should be in the classpath variable for code coverage'
os.chdir(olddir)
return None
# now lets get a list of the test class holders
f = glob.glob('src/org/openscience/cdk/test/modulesuites/M*Tests.java')
f.sort()
f = [x.split('.')[0] for x in [os.path.basename(x) for x in f]]
if not f:
print ' Strange! No test suite classes found.'
os.chdir(olddir)
return None
# lets do all the emma runs
if not os.path.exists('emma'): os.mkdir('emma')
for testsuite in f:
if testsuite.find('smiles') != -1: continue
print ' Analyzing %s' % (testsuite)
cmd = """java -cp %s emmarun -cp develjar/junit-4.3.1.jar:dist/jar/cdk-test.jar:dist/jar/cdk-svn-%s.jar:dist/jar/cdk-test-svn-%s.jar -ix +org.openscience.cdk.* -r html -sp src junit.textui.TestRunner org.openscience.cdk.test.%s &> tmp.log && cat tmp.log >> ../emma.log""" % (classpath, todayStr, todayStr, testsuite)
os.system(cmd)
if os.path.exists('coverage'):
shutil.copytree('coverage', (os.path.join('emma', testsuite)))
os.system('rm -rf coverage')
os.unlink('tmp.log')
# lets move the whole emma directory to the web dir
shutil.copytree('emma', os.path.join(nightly_web, 'emma'))
os.system('rm -rf emma')
# copy the log file
srcFile = os.path.join(nightly_dir, 'emma.log')
destFile = os.path.join(nightly_web, 'emma.log')
shutil.copyfile(srcFile, destFile)
os.unlink(os.path.join(nightly_dir, 'emma.log'))
os.chdir(olddir)
# lets make the links for the web page
celltext = []
celltext.append("""Code <a href="http://emma.sourceforge.net/">coverage</a>""")
f = glob.glob(os.path.join(nightly_web, 'emma', '*'))
f.sort()
tnameregex = re.compile('M(?P<tname>[a-zA-Z0-9]*)Tests')
s = ''
count = 1
for covdir in f:
base = os.path.basename(covdir)
matches = tnameregex.search(base)
tname = matches.group('tname')
s = s + '<a href="emma/%s">%s</a> ' % (base, tname)
if count % per_line == 0:
s = s + "<br>"
count += 1
celltext.append(s)
celltext.append('<a href="emma.log">emma.log</a>')
return celltext
def getVersion():
# update the build.props file
f = open(os.path.join(nightly_repo, 'build.props'), 'r')
lines = [x.strip() for x in f.readlines()]
f.close()
if lines[2].find('version') != 0:
return None
else:
return lines[2].split('=')[1].strip()
def shortenHash(h, link=True):
if not link:
return h[:4]+".."+h[-4:]
else:
repr = h[:4]+".."+h[-4:]
return '<a href="http://github.com/cdk/cdk/commit/%s">%s</a>' % (h, repr)
def getGitInfo():
oldDir = os.getcwd()
os.chdir(nightly_repo)
cmd = 'git log --pretty=medium --date=iso > tmpgit.log'
if debug: print '** Dir: %s Op: %s' % (os.getcwd(), cmd)
os.system(cmd)
gitLog = open('tmpgit.log', 'r').readlines()
if len(gitLog) <= 1: return None, None
commitHash = gitLog[0].split()[1].strip()
commitDate = ' '.join(gitLog[3].split()[1:3])
#commitDate = datetime.datetime.strptime(commitDate, "%Y-%m-%d %H:%M:%S")
os.unlink('tmpgit.log')
os.chdir(oldDir)
return commitHash, commitDate
if __name__ == '__main__':
if 'help' in sys.argv:
print """
Usage: nightly.py CONFIG [ARGS]
A configuration file must be supplied.
ARGS can be:
help - this message
dryrun - do a dry run. This does not sync with Git or run ant tasks. It is expected
that you have stuff from a previous run available and is mainly for testing
or updating the output
firsttime - specify this argument if you're running the script for the first time
nomail - if specified no mail will be sent in response to build errors
"""
sys.exit(0)
# load the config file. We first load it into a dictionary
# and make sure that we have only the valid variable names
# If we have others, we exit. Otherwise, reload it into the
# current environment
if not os.path.exists(sys.argv[1]):
print 'Couldn\'t find the config file: '+sys.argv[1]
sys.exit(0)
myl = {}
def dummyFunction(): pass
validConfigVars = ["nightly_repo", "nightly_dir", "nightly_web", "ant_libs", "classpath", "japitools_path", "last_stable", "per_line", "smtpServerName", "fromName", "toName", "smtpLogin", "smtpPassword", "links", "title_web", "git_path", "svn_path", "git_branch", "bugStats"]
execfile(sys.argv[1], myl)
for key in myl.keys():
if key == '__builtins__': continue
if key not in validConfigVars:
print 'Config file had an unknown variable: '+key
sys.exit(0)
if isinstance(key, type(dummyFunction)):
print 'Config variables must be explicit variables. No functions!'
sys.exit(0)
execfile(sys.argv[1])
print """
Configuration file = %s""" % (sys.argv[1])
# check for the presence of required executable
executableList = ['java', 'ant', 'tar', 'nice', 'git', 'rm']
ret = map( executableExists, executableList )
if False in executableList:
print 'Could not find one or more required executables: '+executableList
sys.exit(-1)
else:
print """
Found required executables"""
# check for certain environment variables
try:
tmp = os.environ['JAVA_HOME']
tmp = os.environ['ANT_HOME']
print """
Found required environment variables"""
except KeyError, ke:
print 'JAVA_HOME & ANT_HOME must be set in the environment'
sys.exit(-1)
# check that the specified dir's exist. Also if the nightly_web
# does not exists make it
if not os.path.exists(nightly_dir):
print '\'%s\' does not exist. Cannot carry on' % (nightly_dir)
sys.exit(-1)
if not os.path.exists(nightly_repo):
print '\'%s\' does not exist. Cannot carry on' % (nightly_repo)
sys.exit(-1)
if not os.path.exists(nightly_web):
print '\'%s\' does not exist. Will create it' % (nightly_web)
try:
os.makedirs(nightly_web)
except:
print 'Could not make the output directory for the nightly build. Exiting'
sys.exit(-1)
# are we going to do a dry run?
if 'dryrun' in [x.lower() for x in sys.argv] or 'dry' in [x.lower() for x in sys.argv]:
dryRun = True
if 'nomail' in [x.lower() for x in sys.argv]:
noMail = True
if 'firsttime' in [x.lower() for x in sys.argv] or 'first' in [x.lower() for x in sys.argv]:
firstTime= True
# print out some status stuff
print """
Variable settings
nightly_repo = %s
nightly_dir = %s
nightly_web = %s
""" % (nightly_repo, nightly_dir, nightly_web)
successSrc = True
successDist = True
successTestDist = True
successTest = True
successJavadoc = True
successKeyword = True
successOJDC = True
successPMD = True
successPMDUnused = True
successPMDMigrate = True
successGit = True
successJCP = False
currentRevision = None
oldRevision = None
xml = """
<nightly>
"""
start_dir = os.getcwd()
os.chdir(nightly_dir)
cdk_version = getVersion()
if not cdk_version:
print 'Error getting curent CDK version string'
sys.exit(-1)
xml += """
<cdk version="%s" />""" % (cdk_version);
if not dryRun:
# before cleaning anything, lets get some old data
# try and load the pickle of the previous test summaries
# else get a summary of the test results from the previous run
oldReports = None
pickle_file = os.path.join(nightly_dir, 'nightly.pickle')
if os.path.exists(pickle_file):
print 'Loading data from persistent storage'
data = pickle.load(open(pickle_file, 'r'))
oldReports = data[0]
oldRevision = data[1]
try:
oldDate = data[2]
except:
print """
Seems you're using an old pickle file. Delete it and rerun nightly
using the firsttime argument"""
sys.exit(-1)
else:
print 'Processing old data'
reports = glob.glob(os.path.join(nightly_repo, 'reports', '*.txt'))
reports.sort()
oldReports = []
for report in reports:
for line in open(report, 'r'):
if line.startswith('Testcase:'):
oldReports.append(''.join(line.split(':')[:2]))
oldRevision, oldDate = getGitInfo()
if not oldRevision and not firstTime:
print 'Error getting the Git log info. Exiting'
sys.exit(-1)
# clean out any files from a previous SEGV in the repo dir
hsfiles = glob.glob(os.path.join(nightly_repo, 'hs_*'))
for hsfile in hsfiles:
os.unlink(hsfile)
# clean up log files in the run dir
logfiles = glob.glob(os.path.join(nightly_dir, '*.log'))
for logfile in logfiles:
os.unlink(logfile)
# clean up source distribution files
logfiles = glob.glob(os.path.join(nightly_repo, 'cdk-source*'))
for logfile in logfiles:
os.unlink(logfile)
# clean up japize files
logfiles = glob.glob(os.path.join(nightly_dir, '*.japi.gz'))
for logfile in logfiles:
os.unlink(logfile)
# go into the repo and sync with SF Git
successGit = updateRepo()
# if we failed, report it and use previous build info
if not successGit:
print 'Could not update Git. Skipping nightly build'
f = open(os.path.join(nightly_web, 'index.html'), 'r')
lines = string.join(f.readlines())
f.close()
newlines = re.sub("<h2 class='title'>",
"""<center><b><h3>Could not connect to SVN. Using yesterdays build</h3></b></center>
<hr>
<p>
<h2 class='title'>""", lines)
f = open(os.path.join(nightly_web, 'index.html'), 'w')
f.write(newlines)
f.close()
os.chdir(start_dir)
sys.exit(0)
# get the latest commit hash and date
currentRevision, currentDate = getGitInfo()
if not currentRevision:
print 'Error getting git info. exiting'
sys.exit(-1)
# if there is no change in rev number since our
# last run, we can skip the run
print 'Last commit = %s\nLatest commit = %s' % (oldRevision, currentRevision)
if oldRevision == currentRevision and not firstTime:
print ' No commits since last run. Exiting'
sys.exit(0)
# compile the distro
successDist = runAntJob('nice -n 19 ant -lib %s clean dist-large' % (ant_libs), 'build.log', 'distro')
if successDist: # if we compiled, do the rest of the stuff
# successJCP = runAntJob('nice -n 19 ant -lib %s -f build-jchempaint.xml' % (ant_libs), 'jcp.log', 'jcp')
successTestDist = runAntJob('nice -19 ant -lib %s dist-test-large' % (ant_libs), 'testdist.log', 'testdist')
successSrc = runAntJob('nice -19 ant -lib %s sourcedist' % (ant_libs), 'srcdist.log', 'srcdist')
successTest = runAntJob('nice -n 19 ant -lib %s -DrunSlowTests=false test-all' % (ant_libs), 'test.log', 'test')
successJavadoc = runAntJob('export CLASSPATH && nice -n 19 ant -lib %s -f javadoc.xml' % (ant_libs), 'javadoc.log', 'javadoc')
successKeyword = runAntJob('nice -n 19 ant -lib %s -f doc/javadoc/build.xml keyword.index' % (ant_libs), 'keyword.log', 'keywords')
successOJDC = runAntJob('nice -n 19 ant -lib %s -f javadoc.xml ojdcheck' % (ant_libs), 'ojdc.log', 'ojdcheck')
successPMD = runAntJob('nice -n 19 ant -lib %s -f pmd.xml pmd' % (ant_libs), 'pmd.log', 'pmd')
successPMDUnused = runAntJob('nice -n 19 ant -lib %s -f pmd-unused.xml' % (ant_libs), 'pmdu.log', 'pmdu')
successPMDMigrate = runAntJob('nice -n 19 ant -lib %s -f pmd-migrating.xml' % (ant_libs), 'pmdm.log', 'pmdu')
else: # if the distro could not be built, there's not much use doing the other stuff
print 'Distro compile failed. Generating error page'
srcFile = os.path.join(nightly_dir, 'build.log')
destFile = os.path.join(nightly_web, 'build.log.fail')
shutil.copyfile(srcFile, destFile)
lines = None
if os.path.exists(os.path.join(nightly_web, 'index.html')):
f = open(os.path.join(nightly_web, 'index.html'), 'r')
lines = string.join(f.readlines())
f.close()
else: lines = ("<html><body><h2 class='title'>%s</h2></body></html>") % (title_web)
if lines.find("Could not compile the sources") == -1:
newlines = re.sub("<h2 class='title'>",
"""<center><b><h3>Could not compile the sources -
<a href=\"build.log.fail\">build.log</a>
</h3></b></center>
<hr>
<p>
<h2>""", lines)
f = open(os.path.join(nightly_web, 'index.html'), 'w')
f.write(newlines)
f.close()
# before finishing send of an email with the last 20 lines of build.log
f = open(os.path.join(nightly_dir, 'build.log'), 'r')
lines = f.readlines()
f.close()
if not noMail: sendMail(string.join(lines[-20:]))
# finally done!
os.chdir(start_dir)
sys.exit(0)
else:
currentRevision, currentDate = getGitInfo()
print 'Doing dry run'
# so we have done a build (hopefully). Get rid of the old stuff
# and set up a temporary page.
os.system('rm -rf %s/*' % (nightly_web))
writeTemporaryPage()
currTime = time.localtime()
currTime = "%02d:%02d" % (currTime[3], currTime[4])
page = """
<html>
<head>
<title>
%s - %s (%s) [Commit %s]
</title>
<style>
<!--
tr:hover { background-color: #efefef; }
.tdfail { background-color: #ea3f3f; }
//-->
</style>
<head>
<body>
<center>
<h2>%s - %s (%s EST)
<i>[<a href=\"http://github.com/cdk/cdk/">Git</a>
Commit <span style="font-size: small"><a href="http://github.com/cdk/cdk/commit/%s">%s</a></span>]</i></h2>
""" % (title_web, todayNice, currTime, currentRevision, title_web, todayNice, currTime, currentRevision, currentRevision)
xml += """
<title>%s</title>
<git>%s</git>
<date>%s</date>""" % (title_web, currentRevision, todayNice);
resultTable = HTMLTable()
resultTable.addHeaderCell("")
resultTable.addHeaderCell("")
resultTable.addHeaderCell("<b>Extra Info</b>", align='center')
# lets now make the web site for nightly builds
if successDist:
print ' Generating distro section'
distSrc = os.path.join(nightly_repo, 'dist', 'jar', 'cdk-%s.jar' % (cdk_version))
distDest = os.path.join(nightly_web, 'cdk-git-%s.jar' % (todayStr))
shutil.copyfile(distSrc, distDest)
resultTable.addRow()
resultTable.addCell("Combined CDK jar files:")
resultTable.addCell("<a href=\"cdk-git-%s.jar\">cdk-git-%s.jar</a>" % (todayStr, todayStr))
logEntryText = copyLogFile('build.log', nightly_dir, nightly_web)
if logEntryText:
resultTable.addCell(logEntryText)
resultTable.appendToCell("<a href=\"http://cia.vc/stats/project/cdk/cdk\">SVN commits</a>")
else:
resultTable.addCell("<br><a href=\"http://cia.vc/stats/project/cdk/cdk\">SVN commits</a>")
if successJCP:
jcpSrc = glob.glob(os.path.join(nightly_repo, 'dist', 'jar', 'jchempaint*.jar'))[0]
jcpDest = os.path.join(nightly_web, 'jchempaint-git-%s.jar' % (todayStr))
shutil.copyfile(jcpSrc, jcpDest)
resultTable.addRow()
resultTable.addCell('JChemPaint')
resultTable.addCell("<a href='jchempaint-git-%s.jar'>jchempaint-git-%s.jar</a>" % (todayStr, todayStr))
logEntryText = copyLogFile('jcp.log', nightly_dir, nightly_web)
if logEntryText:
resultTable.addCell(logEntryText)
if successSrc:
print ' Generating source distro section'
srcSrc = os.path.join(nightly_repo, 'cdk-src+libs-%s.tar.gz' % (cdk_version))
srcDest = os.path.join(nightly_web, 'cdk-src+libs-git-%s.tar.gz' % (todayStr))
shutil.copyfile(srcSrc, srcDest)
srcSrc = os.path.join(nightly_repo, 'cdk-src+libs-%s.zip' % (cdk_version))
srcDest = os.path.join(nightly_web, 'cdk-src+libs-git-%s.zip' % (todayStr))
shutil.copyfile(srcSrc, srcDest)
resultTable.addRow()
resultTable.addCell("CDK Source files:")
resultTable.addCell("<a href=\"cdk-src+libs-git-%s.tar.gz\">Compressed tar file</a>" % (todayStr))
resultTable.appendToCell("<a href=\"cdk-src+libs-git-%s.zip\">ZIP file</a>" % (todayStr))
if 'svn_path' in myl.keys() and svn_path != 'None':
resultTable.appendToCell("<a href=\"%s\">SVN Repository</a>" % (svn_path))
if git_path != 'None':
resultTable.appendToCell("<a href=\"%s\">Git Repository</a>" % (git_path))
# check whether we can copy the run output
resultTable.addCell(copyLogFile('srcdist.log', nightly_dir, nightly_web))
# Lets tar up the java docs and put them away
resultTable.addRow()
resultTable.addCell("API Documentation:")
if successJavadoc:
print ' Generating javadoc section'
destFile = os.path.join(nightly_web, 'javadoc-%s.tgz' % (todayStr))
# tar up the javadocs
olddir = os.getcwd()
os.chdir(os.path.join(nightly_repo,'doc'))
tfile = tarfile.open(destFile, 'w:gz')
tfile.add("cdk-javadoc-%s" % (cdk_version))
tfile.close()
os.chdir(olddir)
shutil.copytree('%s/doc/cdk-javadoc-%s' % (nightly_repo, cdk_version),
'%s/cdk-javadoc-%s' % (nightly_web, cdk_version))
## make a symlink to teh online Javadocs so that other code can easily reach it
os.symlink('%s/cdk-javadoc-%s' % (nightly_web, cdk_version),
'%s/api' % (nightly_web))
resultTable.addCell("<a href=\"javadoc-%s.tgz\">Tarball</a>" % (todayStr))
resultTable.appendToCell("<a href=\"cdk-javadoc-%s/index.html\">Browse online</a>" % (cdk_version))
# check whether we can copy the run output
resultTable.addCell(copyLogFile('javadoc.log', nightly_dir, nightly_web))
# process the javadoc log to get CDKCite errors
f = open(os.path.join(nightly_dir, 'javadoc.log'), 'r')
o = open(os.path.join(nightly_dir, 'citation.log'), 'w')
o.write("""
<html>
<head><title>CDK Javadoc Citation Errors</title></head>
<body>
<h2><center>CDK Javadoc Citation Errors</center></h2>
""")
count = 0
for line in f:
if line.find('CDKCiteERROR: ') > 0:
line = re.sub('\\[javadoc\\] ', '', line)
o.write(line+"<br>\n")
count += 1
o.write("</body></html>")
f.close()
o.close()
if count > 0:
shutil.copyfile(os.path.join(nightly_dir, 'citation.log'),
os.path.join(nightly_web, 'citation.log'))
resultTable.appendToCell('<a href="citation.log">Citations Errors</a>')
else: os.unlink(os.path.join(nightly_dir, 'citation.log'))
# if the key word run did OK, add the link to the xformed keyword list
if successKeyword and os.path.exists(os.path.join(nightly_repo, 'keyword.index.xml')):
srcFile = os.path.join(nightly_repo, 'keyword.index.xml')
destFile = os.path.join(nightly_web, 'keywords.html')
xsltFile = os.path.join(nightly_repo, 'doc', 'javadoc', 'keywordIndex2HTML.xsl')
transformXML2HTML(srcFile, destFile, xsltFile, False)
resultTable.appendToCell("<a href=\"keywords.html\">Keywords</a>")
# replace the cdk.sf.net with local reference
f = open(os.path.join(nightly_web, 'keywords.html'), 'r')
lines = string.join(f.readlines())
f.close()
f = open(os.path.join(nightly_web, 'keywords.html'), 'w')
f.write(re.sub('http://cdk.sf.net/','', lines))
f.close()
else:
resultTable.addCell("<b>FAILED</b>", klass="tdfail")
resultTable.addCell(copyLogFile('javadoc.log', nightly_dir, nightly_web))
resultTable.addRule()
print ' Generating descriptor summary'
distjar = glob.glob(os.path.join(nightly_repo, 'dist', 'jar', 'cdk-%s*' % (cdk_version)))[0]
cmd = 'java -cp %s:%s bsh.Interpreter %s > %s' % \
(classpath, distjar, os.path.join(nightly_repo, 'tools', 'dnames.bsh'), os.path.join(nightly_web, 'dnames.html'))
os.system(cmd)
resultTable.addRow()
resultTable.addCell("Descriptors")
resultTable.addCell("""<a href='dnames.html'>All</a> &nbsp; <a href='dnames.html#molecule'>Molecular</a>
&nbsp; <a href='dnames.html#bond'>Bond</a> &nbsp; <a href='dnames.html#atom'>Atom</a>
""")
# generate the dependency graph entry
print ' Generating dependency graph'
celltexts = generateCDKDepGraph()
if celltexts:
resultTable.addRow()
for celltext in celltexts: resultTable.addCell(celltext)
# get the JUnit test results
resultTable.addRow()
resultTable.addCell("<a href=\"http://www.junit.org/index.htm\">JUnit</a> results:")
if successTest:
print ' Generating JUnit section'
# we'll want to do a diff against the previous runs results,
# but only if it is not a dry run
nTestFixed = 'NA'
nTestFails = 'NA'
if not dryRun:
reports = glob.glob(os.path.join(nightly_repo, 'reports', '*.txt'))
reports.sort()
newReports = []
for report in reports:
for line in open(report, 'r'):
if line.startswith('Testcase:'):
newReports.append(''.join(line.split(':')[:2]))
import difflib
diff = difflib.unified_diff(oldReports, newReports)
nTestFixed = -1
nTestFails = -1
for i in diff:
if i.startswith('-'): nTestFixed += 1
if i.startswith('+'): nTestFails += 1
# dump the new report to the pickle file
# so that it's the old report for the
# next run. Byt only do so, if the current version
# is newer than the older version
if currentRevision != oldRevision or firstTime:
data = [newReports, currentRevision, currentDate]
pickle.dump(data, open(pickle_file, 'w'))
print ' Wrote pickle file with this builds test reports'
# dump out a nice HTML diff page
oldReports = [x.replace('Testcase', '') for x in oldReports]
newReports = [x.replace('Testcase', '') for x in newReports]
oldReports = [x.replace('org.openscience.cdk.test', 'o.o.c.t') for x in oldReports]
newReports = [x.replace('org.openscience.cdk.test', 'o.o.c.t') for x in newReports]
htmlDiff = difflib.HtmlDiff()
difffile = htmlDiff.make_file(oldReports, newReports, numlines=0, context=True)
difffile = difffile.replace('<title></title>',
"""
<title>Fixed and New JUnit Failures</title>""")
difffile = difffile.replace("<body>",
"""
<body>
<center><h2>Fixed and New JUnit Failures
</center></h2>
""")
difffile= difffile.replace("<tbody>",
"""
<tbody>
<tr>
<td></td>
<td></td>
<td align='center'><b>Tests fixed since Rev %s</b></td>
<td></td>
<td></td>
<td align='center'><b>New failures in Rev %s</b></td>
</tr>
""" % (oldRevision, currentRevision), 1)
f = open(os.path.join(nightly_web,'junitdiff.html'), 'w')
f.write(difffile)
f.close()
# make the directory for reports
testDir = os.path.join(nightly_web, 'test')
os.mkdir(testDir)
# copy the individual report files
reportFiles = glob.glob(os.path.join(nightly_repo, 'reports', 'result-*'))
for report in reportFiles:
newfile = transformJunitResultToHTML(report)
newfilename = os.path.basename(report).split('.')[0]+".html"
dest = os.path.join(testDir, newfilename)
f = open(dest, 'w')
f.write(newfile)
f.close()
repFiles = glob.glob(os.path.join(testDir,'result-*.html'))
repFiles.sort()
count = 1
s = ""
for repFile in repFiles:
title = string.split(os.path.basename(repFile),'.')[0]
title = string.split(title, '-')[1]
s = s+"<a href=\"test/%s\">%s</a>\n" % (os.path.basename(repFile), title)
if count % per_line == 0:
s += "<br>"
count += 1
resultTable.addCell(s)
# summarize JUnit test results - it will go into nightly_web
parseJunitOutput('junitsummary.html')
# check whether we can copy the run output and link to the summary
if os.path.exists( os.path.join(nightly_dir, 'test.log') ):
shutil.copyfile(os.path.join(nightly_dir, 'test.log'),
os.path.join(nightly_web, 'test.log'))
resultTable.addCell("<a href=\"test.log\">test.log</a>")
resultTable.appendToCell("<a href=\"junitsummary.html\">Stable</a>")
if not dryRun:
resultTable.appendToCell("<br>No. old fails fixed since %s = %s" % (shortenHash(oldRevision,True),str(nTestFixed)))
resultTable.appendToCell("No. new fails since %s = %s" % (shortenHash(oldRevision,True),str(nTestFails)))
resultTable.appendToCell("<a href='%s'>Comparison</a>" % ('junitdiff.html'))
else:
resultTable.addCell("<b>FAILED</b>", klass="tdfail")
if os.path.exists( os.path.join(nightly_dir, 'test.log') ):
shutil.copyfile(os.path.join(nightly_dir, 'test.log'),
os.path.join(nightly_web, 'test.log'))
resultTable.addCell("<a href=\"test.log\">test.log</a>")
f = open(os.path.join(nightly_dir, 'test.log'), 'r')
lines = f.readlines()
f.close()
if not noMail: sendMail(string.join(lines[-20:]), 'JUnit test failed')
# do the code coverage
if successTestDist:
print ' Performing code coverage'
#celltexts = doCodeCoverage()
#if celltexts:
# resultTable.addRow()
# for celltext in celltexts: resultTable.addCell(celltext)
else:
resultTable.addRow()
resultTable.addCell("""Code <a href="http://emma.sourceforge.net/">coverage</a>""")
resultTable.addCell("<b>FAILED</b>", klass="tdfail")
if os.path.exists( os.path.join(nightly_dir, 'emma.log') ):
shutil.copyfile(os.path.join(nightly_dir, 'emma.log'),
os.path.join(nightly_web, 'emma.log'))
resultTable.addCell("<a href=\"emma.log\">emma.log</a>")
# get the results of the OpenJavaDocCheck analysis
resultTable.addRow()
resultTable.addCell("<a href=\"http://github.com/egonw/ojdcheck\">OpenJavaDocCheck</a> results:<br><i><b>All</b></i>")
if successPMD:
print ' Generating OpenJavaDocCheck section'
# make the PMD dir in the web dir
os.mkdir(os.path.join(nightly_web,'ojdcheck'))
# transform the PMD XML output to nice HTML
xmlFiles = glob.glob(os.path.join(nightly_repo,'reports/ojdcheck/*.html'))
xmlFiles.sort()
count = 1
s = ''
for xmlFile in xmlFiles:
prefix = os.path.basename(xmlFile).split('.')[0]
htmlFile = os.path.join(nightly_web, 'ojdcheck', prefix)+'.html'
shutil.copyfile(xmlFile, os.path.join(nightly_web, htmlFile))
s = s+"<a href=\"ojdcheck/%s\">%s</a>\n" % (os.path.basename(htmlFile), prefix)
if count % per_line == 0: s += "<br>"
count += 1
resultTable.addCell(s)
ojdcheckSummary = parseOJDCOutput('ojdcheck', 'CDK OpenJavaDocCheck Summary')
if not ojdcheckSummary == None:
o = open(os.path.join(nightly_web, 'ojdcheckSummary.html'), 'w')
o.write(ojdcheckSummary)
o.close()
resultTable.addCell('<a href="ojdcheckSummary.html">Summary</a>')
else: # OJDC stage failed for some reason
resultTable.addCell("<b>FAILED</b>", klass="tdfail")
if os.path.exists( os.path.join(nightly_dir, 'ojdcheck.log') ):
shutil.copyfile(os.path.join(nightly_dir, 'ojdcheck.log'),
os.path.join(nightly_web, 'ojdcheck.log'))
resultTable.addCell("<a href=\"ojdcheck.log\">ojdcheck.log</a>")
# get the results of the PMD analysis
resultTable.addRow()
resultTable.addCell("<a href=\"http://pmd.sourceforge.net/\">PMD</a> results:<br><i><b>All</b></i>")
if successPMD:
print ' Generating PMD section'
# make the PMD dir in the web dir
os.mkdir(os.path.join(nightly_web,'pmd'))
# transform the PMD XML output to nice HTML
xmlFiles = glob.glob(os.path.join(nightly_repo,'reports/pmd/*.xml'))
xmlFiles.sort()
count = 1
s = ''
for xmlFile in xmlFiles:
prefix = os.path.basename(xmlFile).split('.')[0]
htmlFile = os.path.join(nightly_web, 'pmd', prefix)+'.html'
xsltFile = os.path.join(nightly_repo,'pmd','wz-pmd-report.xslt')
transformXML2HTML(xmlFile, htmlFile, xsltFile)
s = s+"<a href=\"pmd/%s\">%s</a>\n" % (os.path.basename(htmlFile), prefix)
if count % per_line == 0: s += "<br>"
count += 1
resultTable.addCell(s)
pmdSummary = parsePMDOutput('pmd', 'CDK PMD Summary')
if not pmdSummary == None:
o = open(os.path.join(nightly_web, 'pmdsummary.html'), 'w')
o.write(pmdSummary)
o.close()
resultTable.addCell('<a href="pmdsummary.html">Summary</a>')
else: # PMD stage failed for some reason
resultTable.addCell("<b>FAILED</b>", klass="tdfail")
if os.path.exists( os.path.join(nightly_dir, 'pmd.log') ):
shutil.copyfile(os.path.join(nightly_dir, 'pmd.log'),
os.path.join(nightly_web, 'pmd.log'))
resultTable.addCell("<a href=\"pmd.log\">pmd.log</a>")
resultTable.addRow()
resultTable.addCell("<ahref=\"http://pmd.sourceforge.net/\">PMD</a> results:<br><i><b>Migration (1.5)</b></i>")
if successPMDMigrate:
print ' Generating PMD-Migrating section'
os.mkdir(os.path.join(nightly_web,'pmd-migrating'))
# transform the PMD XML output to nice HTML
xmlFiles = glob.glob(os.path.join(nightly_repo,'reports/pmd-migrating/*.xml'))
xmlFiles.sort()
count = 1
s = ''
for xmlFile in xmlFiles:
prefix = os.path.basename(xmlFile).split('.')[0]
htmlFile = os.path.join(nightly_web, 'pmd-migrating', prefix)+'.html'
xsltFile = os.path.join(nightly_repo,'pmd','wz-pmd-report.xslt')
status = transformXML2HTML(xmlFile, htmlFile, xsltFile)
if status:
s = s+"<a href=\"pmd-migrating/%s\">%s</a>\n" % (os.path.basename(htmlFile), prefix)
else: s += ""
if count % per_line == 0: s += "<br>"
count += 1
resultTable.addCell(s)
pmdSummary = parsePMDOutput('pmd-migrating', 'CDK PMD Migrating Code Summary')
if not pmdSummary == None:
o = open(os.path.join(nightly_web, 'pmdmsummary.html'), 'w')
o.write(pmdSummary)
o.close()
resultTable.addCell('<a href="pmdmsummary.html">Summary</a>')
else: # PMD stage failed for some reason
resultTable.addCell("<b>FAILED</b>", klass="tdfail")
if os.path.exists( os.path.join(nightly_dir, 'pmdm.log') ):
shutil.copyfile(os.path.join(nightly_dir, 'pmdm.log'),
os.path.join(nightly_web, 'pmdm.log'))
resultTable.addCell("<a href=\"pmdm.log\">pmdm.log</a>")
resultTable.addRow()
resultTable.addCell("<a href=\"http://pmd.sourceforge.net/\">PMD</a> results:<br><i><b>Unused Code</b></i>")
if successPMDUnused:
print ' Generating PMD-Unused section'
# make the PMD dir in the web dir
os.mkdir(os.path.join(nightly_web,'pmd-unused'))
# transform the PMD XML output to nice HTML
xmlFiles = glob.glob(os.path.join(nightly_repo,'reports/pmd-unused/*.xml'))
xmlFiles.sort()
count = 1
s = ''
for xmlFile in xmlFiles:
prefix = os.path.basename(xmlFile).split('.')[0]
htmlFile = os.path.join(nightly_web, 'pmd-unused', prefix)+'.html'
xsltFile = os.path.join(nightly_repo,'pmd','wz-pmd-report.xslt')
transformXML2HTML(xmlFile, htmlFile, xsltFile)
s = s+"<a href=\"pmd-unused/%s\">%s</a>\n" % (os.path.basename(htmlFile), prefix)
if count % per_line == 0: s += "<br>"
count += 1
resultTable.addCell(s)
pmdSummary = parsePMDOutput('pmd-unused', 'CDK PMD Unused Code Summary')
if not pmdSummary == None:
o = open(os.path.join(nightly_web, 'pmdusummary.html'), 'w')
o.write(pmdSummary)
o.close()
resultTable.addCell('<a href="pmdusummary.html">Summary</a>')
else: # PMD stage failed for some reason
resultTable.addCell("<b>FAILED</b>", klass="tdfail")
if os.path.exists( os.path.join(nightly_dir, 'pmdu.log') ):
shutil.copyfile(os.path.join(nightly_dir, 'pmdu.log'),
os.path.join(nightly_web, 'pmdu.log'))
resultTable.addCell("<a href=\"pmdu.log\">pmdu.log</a>")
# try and run japitools
print ' Generating JAPI comparison'
celltexts = generateJAPI()
if celltexts:
resultTable.addRow()
for celltext in celltexts: resultTable.addCell(celltext)
# run the bug analysis code
print ' Performing bug analysis'
sys.path.append( os.path.join(nightly_repo, 'tools') )
if bugStats:
import analyzeBugs
try:
analyzeBugs.analyzeBugs( os.path.join(nightly_web, 'bugs.html'), os.path.join(nightly_repo, 'src/main') )
resultTable.addRow()
resultTable.addCell("Bug Analysis")
resultTable.addCell("<a href=\"bugs.html\">Results</a>")
except IOError, ioe:
print ioe
except RuntimeError, rte:
print rte
## Add a links section
if links:
resultTable.addRow()
resultTable.addCell("Links");
s = ''
for text, link in links:
s = s + "<a href='%s'>%s<a><br>" % (link, text)
resultTable.addCell(s)
# copy this script to the nightly we dir. The script should be in nightly_dir
f = open(os.path.join(nightly_dir,'nightly.py'), 'r')
script = string.join(f.readlines())
f.close()
f = open(os.path.join(nightly_web, 'nightly.py'), 'w')
f.write(script)
f.close()
# close up the HTML and write out the web page
olddir = os.getcwd()
os.chdir(nightly_repo)
os.system('ant info > %s' % (os.path.join(nightly_web, 'antinfo.txt')))
def getSysInfo(filename):
data = ''.join(open(filename).readlines())
osname = re.findall('OS:\s+(.*)', data)
osversion = re.findall('Version:\s+(.*)', data)
javaversion = re.findall('Java version:\s+(.*)', data)
javavendor = re.findall('Java vendor:\s+(.*)', data)
return osname[0], osversion[0],javaversion[0],javavendor[0]
on,ov,jv,jn = getSysInfo(os.path.join(nightly_web, 'antinfo.txt'))
xml += """
<operatingSystem>
<name>%s</name>
<version>%s</version>
</operatingSystem>
<java>
<vendor>%s</vendor>
<version>%s</version>
</java>
""" % (on, ov, jn, jv);
resultTable.addRule()
resultTable.addRow()
resultTable.addCell("<i>Build details</i>")
resultTable.addCell("<i>%s %s</i>" % (on, ov))
resultTable.appendToCell("<i>%s JDK %s</i>" % (jn, jv))
resultTable.appendToCell("<a href=\"antinfo.txt\">ant info</a>")
page = page + str(resultTable)
page = page + """
<br><br><br>
<a href='nightly.tar.gz'>Download</a> this site (excluding jars and tarballs). <br>
<br><br>Generated by <a href=\"nightly.py\">nightly.py</a>
<p>
<a href=\"http://sourceforge.net/projects/cdk/\"><img alt=\"SourceForge.net Logo\"
border=\"0\" height=\"31\" width=\"88\"
src=\"http://sourceforge.net/sflogo.php?group_id=20024&type=5&type=1\"></a>
</center>
</body>
</html>"""
f = open(os.path.join(nightly_web, 'index.html'), 'w')
f.write(page)
f.close()
xml += """
</nightly>
"""
f = open(os.path.join(nightly_web, 'nightly.xml'), 'w')
f.write(xml)
f.close()
# make the nightly site tarball
cmd = """
tar -zcvf %s %s --exclude %s --exclude %s --exclude=*.gz --exclude=*.zip --exclude=*.jar > /dev/null
""" % (os.path.join(nightly_web, 'nightly.tar.gz'), \
nightly_web, \
os.path.join(nightly_web, 'api'), \
os.path.join(nightly_web, 'javadoc'))
os.system(cmd)
# go back to where we started
os.chdir(start_dir)
sys.exit(0)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks