You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@gump.apache.org by aj...@apache.org on 2003/11/18 23:52:17 UTC
cvs commit: jakarta-gump/python/gump/output statistics.py
ajack 2003/11/18 14:52:17
Modified: python/gump/model property.py
python/gump/output statistics.py
Log:
1) Improved 'bad property' handling
2) Restored 'previous state' for statistics DB.
Revision Changes Path
1.5 +19 -14 jakarta-gump/python/gump/model/property.py
Index: property.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/model/property.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- property.py 18 Nov 2003 19:37:38 -0000 1.4
+++ property.py 18 Nov 2003 22:52:17 -0000 1.5
@@ -80,22 +80,27 @@
# provide default elements when not defined in xml
def complete(self,parent,workspace):
if self.isComplete(): return
-
+
+ # Properties are either on the workspace, or on
+ # an ant entry within a project. Pick workspace or project.
+ responsibleParty=workspace
+ if isinstance(parent,Ant): responsibleParty=parent.getOwner()
+
if self.xml.reference=='home':
if not workspace.hasProject(self.xml.project):
- parent.addError('Cannot resolve homedir of *unknown* [' + self.xml.project + ']')
+ responsibleParty.addError('Cannot resolve homedir of *unknown* [' + self.xml.project + ']')
else:
self.setValue(workspace.getProject(self.xml.project).getHomeDirectory())
elif self.xml.reference=='srcdir':
if not workspace.hasProject(self.xml.project):
- parent.addError('Cannot resolve srcdir of *unknown* [' + self.xml.project + ']')
+ responsibleParty.addError('Cannot resolve srcdir of *unknown* [' + self.xml.project + ']')
else:
self.setValue(workspace.getProject(self.xml.project).getModule().getSourceDirectory())
elif self.xml.reference=='jarpath' or self.xml.reference=='jar':
if not workspace.hasProject(self.xml.project):
- parent.addError('Cannot resolve jar/jarpath of *unknown* [' + self.xml.project + ']')
+ responsibleParty.addError('Cannot resolve jar/jarpath of *unknown* [' + self.xml.project + ']')
else:
targetProject=workspace.getProject(self.xml.project)
@@ -108,32 +113,32 @@
self.setValue(jar.getName())
break
else:
- self.value=("jar with id %s was not found in project %s " +
+ responsibleParty.addError( \
+ "jar with id %s was not found in project %s " +
"referenced by %s") % \
(self.xml.id, targetProject.getName(), project.getName())
- log.error(self.value)
elif targetProject.getJarCount()==1:
- self.value=targetProject.getJars()[0].getPath()
+ self.setValue(targetProject.getJars()[0].getPath())
elif targetProject.getJarCount()>1:
- self.value=("Multiple jars defined by project %s referenced by %s; " + \
+ responsibleParty.addError( \
+ "Multiple jars defined by project %s referenced by %s; " + \
"an id attribute is required to select the one you want") % \
(targetProject.getName(), project.getName())
- log.error(self.value)
else:
- self.value=("Project %s referenced by %s defines no jars as output") % \
- (targetProject.getName(), project.getName())
- log.error(self.value)
+ responsibleParty.addError( \
+ 'Project %s referenced by %s defines no jars as output') % \
+ (targetProject.getName(), project.getName())
elif self.xml.path:
#
- # Path relative to module's srcdir
+ # Path relative to module's srcdir (doesn't work in workspace)
#
self.value=os.path.abspath(os.path.join( \
parent.getOwner().getModule().getSourceDirectory(), \
self.xml.path))
if not hasattr(self,'value'):
- log.error('Unhandled Property: ' + self.getName() + ' on: ' + \
+ responsibleParty.addError('Unhandled Property: ' + self.getName() + ' on: ' + \
str(parent))
self.setComplete(1)
1.4 +13 -2 jakarta-gump/python/gump/output/statistics.py
Index: statistics.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/output/statistics.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- statistics.py 18 Nov 2003 21:49:12 -0000 1.3
+++ statistics.py 18 Nov 2003 22:52:17 -0000 1.4
@@ -83,6 +83,7 @@
self.first=''
self.last=''
self.currentState=STATE_UNSET
+ self.previousState=STATE_UNSET
self.sequenceInState=0
def getFOGFactor(self):
@@ -109,6 +110,9 @@
def currentStateKey(self):
return self.projectname + '-current-state'
+ def previousStateKey(self):
+ return self.projectname + '-previous-state'
+
def sequenceInStateKey(self):
return self.projectname + '-state-seq'
@@ -131,13 +135,14 @@
#
# Deal with states & changes...
#
- previousState=self.currentState
+ lastCurrentState=self.currentState
self.currentState=project.getState()
- if previousState==self.currentState:
+ if lastCurrentState==self.currentState:
self.sequenceInState += 1
else:
self.sequenceInState = 1
+ self.previousState=lastCurrentState
class StatisticsDB:
"""Statistics Interface"""
@@ -166,6 +171,7 @@
s.first=self.getDate(s.firstKey())
s.last=self.getDate(s.lastKey())
s.currentState=stateForName(self.get(s.currentStateKey()))
+ s.previousState=stateForName(self.get(s.previousStateKey()))
s.sequenceInState=self.getInt(s.sequenceInStateKey())
return s
@@ -177,6 +183,7 @@
self.putDate(s.firstKey(), s.first)
self.putDate(s.lastKey(), s.last)
self.put(s.currentStateKey(), stateName(s.currentState))
+ self.put(s.previousStateKey(), stateName(s.previousState))
self.putInt(s.sequenceInStateKey(), s.sequenceInState)
def delProjectStats(self,s):
@@ -206,6 +213,10 @@
""" Hopefully means it wasn't there... """
try:
del self.db[s.currentStateKey()]
+ except:
+ """ Hopefully means it wasn't there... """
+ try:
+ del self.db[s.previousStateKey()]
except:
""" Hopefully means it wasn't there... """
try: