#
# BusyB, an automated build utility.
#
# Copyright (C) 1997-2003
#
# 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.
#
#
from Base import Base
from busybee.BusyBException import BusyBException
from busybee import SymbolManager
from busybee.HTMLWriter import HTMLWriter
from Description import Description
import sys
import os
class Build(Base):
def __init__(self):
Base.__init__(self)
self.steps = []
self.description = Description("Build")
self.logDir = "."
def setText(self, t):
pass
def setParent(self,p):
p.setBuild(self)
def setStep( self, s):
self.steps.append(s)
def setLogDir( self, d ):
self.logDir = d
def process(self):
print 'build process'
self.preProcess()
i = 1
logFile = self.getLogger()
logFile.timeStamp("Running steps")
try:
for s in self.steps:
try:
name = "Step" + str(i)
desc = s.getDescription().getText()
if desc == '':
desc = name
logFile.timeStamp()
logFile.writeFileRef(desc, name + '.html')
logFile.writeln()
except:
self.postProcess()
logFile.startFontColor( 'ff0000')
logFile.timeStamp( str(sys.exc_info()[1]) )
logFile.endFontColor()
self.handleException(ex)
try:
self.runStep(name, i, desc, s)
except:
print sys.exc_info()[1]
if( not self.tryHandleException(sys.exc_info()[1]) ):
logFile.startFontColor( 'ff0000')
logFile.timeStamp( str(sys.exc_info()[1]) )
logFile.endFontColor()
self.postProcess()
raise
i = i + 1
finally:
logFile.timeStamp( "Build finished.")
logFile.writeln()
logFile.rule()
logFile.writeln()
logFile.writeln()
logFile.write( 'Build powered by ', 'i' )
logFile.writeFileRef( 'BusyB', 'http://busyb.sourceforge.net')
logFile.writeln(".")
def runStep(self, name, number, desc, step):
stepLoggerPath = os.path.join( self.logDir, name + '.html' )
print 'path: ', stepLoggerPath
stepLogger = HTMLWriter(open(stepLoggerPath,"w"), desc )
stepLogger.rule()
step.setLogger( stepLogger )
symManager = SymbolManager.getInstance()
symManager.setSymbol('step_name', name)
symManager.setSymbol('step_number', number)
try:
step.process()
finally:
stepLogger.writeln()
stepLogger.rule()
stepLogger.writeln()
stepLogger.writeln()
stepLogger.write( 'Build powered by ', 'i' )
stepLogger.writeFileRef( 'BusyB', 'http://busyb.sourceforge.net')
stepLogger.writeln(".")
stepLogger.close()
symManager.unsetSymbol('step_name')
symManager.unsetSymbol('step_number')
|