#
# BusyB, an automated build utility.
#
# Copyright (C) 1997-2005
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
import pickle
import sys
import time
import os
from HTMLWriter import HTMLWriter
from LogDirManager import getBuildDirs
class LogIndexCompiler:
def __init__(self, dir, desc):
self.dir = dir
print '*** logIndex: ', dir
self.desc = desc
self.dateColumnSize= 25
self.descColumnSize= 35
self.statusColumnSize= 40
def loadRecord( self, path):
print 'loading: ' + path
try:
f = open(path, "r")
ret = pickle.load(f)
f.close()
return ret
except:
print str(sys.exc_info()[1])
return None
def compile(self):
stream = open(os.path.join(self.dir.getAbsPath(), "index.html" ), "w")
logFile = HTMLWriter( stream, self.desc)
self.writeLogHeader(logFile)
buildDirs = getBuildDirs(self.dir)
for d in buildDirs:
print 'build Dir' + d
buildRecord=self.loadRecord(
os.path.join( self.dir.getAbsPath(), os.path.join( d, "status.dat")))
if buildRecord:
self.writeLogFileEntry(logFile, d, buildRecord )
self.writeLogFooter(logFile)
logFile.close()
def writeLogHeader(self, f):
f.startTable(95,1)
f.startRow()
f.startCell(self.dateColumnSize)
f.write( "Date", "b")
f.endCell()
f.startCell(self.descColumnSize)
f.write( "Description", "b")
f.endCell()
f.startCell(self.statusColumnSize)
f.write( "Result", "b")
f.endCell()
def writeLogFooter(self,f):
f.endTable()
f.writeln()
f.write( 'Administrative details can be found in the ')
f.writeFileRef( 'BusyB system log', 'log.html')
f.writeln(".")
f.writeln()
f.write( 'Build powered by ', 'i' )
f.writeFileRef( 'BusyB', 'http://busyb.sourceforge.net')
f.writeln(".")
def writeLogFileEntry( self, f, dir, record ):
f.startRow()
f.startCell(self.dateColumnSize)
timeString = time.ctime(time.mktime(record.date))
f.write( timeString )
f.endCell()
f.startCell(self.descColumnSize)
f.writeFileRef( record.description, dir + "/index.html" )
f.endCell()
f.startCell(self.statusColumnSize)
if ( record.status.startswith( "OK" ) ):
f.writeln( record.status )
else:
f.startFontColor( 'ff0000')
f.writeln( record.status )
f.endFontColor()
f.endCell()
f.endRow()
|