ajack 2003/12/11 10:56:27
Modified: python/gump engine.py check.py config.py
python/gump/utils launcher.py __init__.py
python/gump/model rawmodel.py ant.py property.py
python/gump/test/resources/full1 module2.xml
python/gump/test model.py utils.py
python/gump/syndication rss.pyc syndicator.pyc
python/gump/document forrest.py
Log:
1) http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25436
If property name or value contains ' ' or shell quote or shell escape then quoting
is done:
We get ' on 'nix, " on M$
We get \ -> \\
We get ' -> \'
No other whitespace (but space) is supported
2) Fix for restoring <ant <property (broken in big rework)
3) Wrapping text (inside <source) to try to keep 'prettier'
4) Added 'Properties' display to Workspace and Project (Ant)
5) Added unit tests
6) Started work on continuous (loop) but incomplete.
Revision Changes Path
1.41 +12 -1 jakarta-gump/python/gump/engine.py
Index: engine.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- engine.py 8 Dec 2003 16:34:14 -0000 1.40
+++ engine.py 11 Dec 2003 18:56:26 -0000 1.41
@@ -91,7 +91,18 @@
workspace.addWarning(message)
log.warn(message)
- def integrate(self,run):
+ def continuous(self):
+
+ while 0:
+
+ try:
+ # Do the integration
+ ok=self.integrate(run)
+ except:
+ log.error('Failed to integrate...')
+ pass
+
+ def integrate(self,run):
#
# Prepare the context
1.35 +34 -32 jakarta-gump/python/gump/check.py
Index: check.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/check.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- check.py 18 Nov 2003 00:29:49 -0000 1.34
+++ check.py 11 Dec 2003 18:56:26 -0000 1.35
@@ -68,14 +68,16 @@
import traceback
import logging
-from gump import log
-from gump.logic import getBuildSequenceForProjects, getProjectsForProjectExpression
-from gump.config import dir, default, handleArgv,
-from gump.model import Workspace, Module, Project
-from gump.context import Workspace, CommandWorkItem, WORK_TYPE_CHECK, STATE_SUCCESS
-from gump.tools import tailFileToString
+import os.path
+import os
+import sys
+import logging
-from gump.launcher import getCmdFromString, execute
+from gump import log
+from gump.engine import GumpEngine
+from gump.gumprun import GumpRun, GumpRunOptions, GumpSet
+from gump.utils.commandLine import handleArgv
+from gump.model.loader import WorkspaceLoader
###############################################################################
# Initialize
@@ -86,7 +88,7 @@
# Functions
###############################################################################
-def check(workspace, expr='*', context=GumpContext(),display=1):
+def check(workspace,run,display=1):
"""dump all dependencies to build a project to the output"""
projects=getProjectsForProjectExpression(expr)
@@ -238,29 +240,29 @@
# print " install the artifacts of " + missed +" manually."
#
+
# static void main()
if __name__=='__main__':
- # init logging
- logging.basicConfig()
-
- #set verbosity to show all messages of severity >= default.logLevel
- log.setLevel(default.logLevel)
-
- args = handleArgv(sys.argv,0)
- ws=args[0]
- ps=args[1]
-
- # get parsed workspace definition
- workspace=load(ws)
-
- context=GumpContext()
-
- #
- checkEnvironment(workspace,context,0)
+ # Process command line
+ args = handleArgv(sys.argv)
+ ws=args[0]
+ ps=args[1]
+
+ # get parsed workspace definition
+ workspace=WorkspaceLoader().load(ws)
+
+
+ # TODO populate...
+ options=GumpRunOptions()
+
+ # The Run Details...
+ run=GumpRun(workspace,ps,options)
+
- # check
- result = check(workspace, ps, context, 1)
- # bye!
- sys.exit(result)
+ #
+ log.info('Gump Integration complete. Exit code:' + str(result))
+
+ # bye!
+ sys.exit(result)
\ No newline at end of file
1.10 +4 -0 jakarta-gump/python/gump/config.py
Index: config.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/config.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- config.py 4 Dec 2003 23:16:23 -0000 1.9
+++ config.py 11 Dec 2003 18:56:26 -0000 1.10
@@ -115,8 +115,12 @@
if not os.name == 'dos' and not os.name == 'nt':
classpathSeparator=':'
+ shellQuote='\''
+ shellEscape='\\'
else:
classpathSeparator=';'
+ shellQuote='"'
+ shellEscape='\\'
class setting:
"""Configuration of hardcoded settings"""
1.4 +38 -4 jakarta-gump/python/gump/utils/launcher.py
Index: launcher.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/utils/launcher.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- launcher.py 3 Dec 2003 18:36:13 -0000 1.3
+++ launcher.py 11 Dec 2003 18:56:26 -0000 1.4
@@ -96,6 +96,21 @@
self.separator=separator
self.prefix=prefix
+
+ def isRequiresQuoting(self):
+ if self.name:
+ if ' ' in self.name: return 1
+ if default.shellQuote in self.name: return 1
+ if default.shellEscape in self.name: return 1
+
+ if self.value:
+ if ' ' in self.value: return 1
+ if default.shellQuote in self.value: return 1
+ if default.shellEscape in self.value: return 1
+
+ return 0
+
+
def getParameterFromString(strp):
"""Extract a Parameter Object from a String"""
parts=split(strp,'=')
@@ -152,16 +167,35 @@
def formatCommandLine(self):
line = ''
for param in self.list:
+ requiresQuoting=param.isRequiresQuoting()
+
+ if requiresQuoting:
+ line+=default.shellQuote
+
if param.prefix:
line += param.prefix
- line += param.name
+
+ #
+ # Deal w/ escaping quotes
+ #
+ line += self.getEscapedEntry(param.name)
val = param.value
if val:
line += param.separator
- line += val
- line += " "
+ line += self.getEscapedEntry(val)
+
+ if requiresQuoting:
+ line+=default.shellQuote
+ line += ' '
+
return line
-
+
+ def getEscapedEntry(self,entry):
+ if not entry: return
+
escapedEntry=entry.replace(default.shellEscape,default.shellEscape+default.shellEscape)
+
escapedEntry=escapedEntry.replace(default.shellQuote,default.shellEscape+default.shellQuote)
+ return escapedEntry
+
def items(self):
return self.list
1.11 +24 -0 jakarta-gump/python/gump/utils/__init__.py
Index: __init__.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/utils/__init__.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- __init__.py 9 Dec 2003 22:26:09 -0000 1.10
+++ __init__.py 11 Dec 2003 18:56:26 -0000 1.11
@@ -310,6 +310,30 @@
s += sc
return s
+
+def wrapLine(line,wrapLen=100, eol='\n', marker='[WRAPPED]'):
+ #
+ # Provide some wrapping (at ~ 100)
+ #
+ if len(line) > wrapLen:
+ startPosn=0
+ endPosn=wrapLen
+ increment=wrapLen
+ totalLen=len(line)
+ wrappedLine=''
+ while increment > 0:
+ wrappedLine+=line[startPosn:endPosn]
+ if totalLen - endPosn > wrapLen:
+ increment=wrapLen
+ else:
+ increment=(totalLen - endPosn)
+ if increment:
+ wrappedLine+=eol+marker
+ startPosn+=increment
+ endPosn+=increment
+ print `startPosn` + " : " + `endPosn` + " : " + `totalLen` + ' : ' +
`increment`
+
+ return wrappedLine
def getIndent(depth=0):
indent=''
1.7 +1 -0 jakarta-gump/python/gump/model/rawmodel.py
Index: rawmodel.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/model/rawmodel.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- rawmodel.py 1 Dec 2003 17:34:07 -0000 1.6
+++ rawmodel.py 11 Dec 2003 18:56:27 -0000 1.7
@@ -216,6 +216,7 @@
# represents a <property/> element
class XMLProperty(GumpXMLModelObject):
+
def getName(self):
return self.name
1.10 +15 -10 jakarta-gump/python/gump/model/ant.py
Index: ant.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/model/ant.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ant.py 1 Dec 2003 20:48:12 -0000 1.9
+++ ant.py 11 Dec 2003 18:56:27 -0000 1.10
@@ -101,8 +101,12 @@
# into dependencies
#
for property in self.xml.property:
- self.expandProperty(property,project,workspace)
+ self.expandProperty(property,project,workspace)
+ self.importProperty(property)
+ #
+ # Expands
+ #
def expandProperty(self,property,project,workspace):
# Check if the property comes from another project
@@ -151,21 +155,22 @@
#
for depend in self.xml.depend:
# Generate the property
- property=XMLProperty(depend.__dict__)
- property['reference']='jarpath'
+ xmlproperty=XMLProperty(depend.__dict__)
+ xmlproperty['reference']='jarpath'
- # Name the property...
+ # Name the xmlproperty...
if depend.property:
- property['name']=depend.property
- elif not hasattr(property,'name') or not property['name']:
+ xmlproperty['name']=depend.property
+ elif not hasattr(xmlproperty,'name') or not xmlproperty['name']:
# :TODO: Reconsider later, but default to project name for now...
- property['name']=depend.project
+ xmlproperty['name']=depend.project
project.addWarning('Unnamed property for [' + project.name + '] in
depend on: ' + depend.project )
# :TODO: AJ added this, no idea if it is right/needed.
- if depend.id: property['ids']= depend.id
+ if depend.id: xmlproperty['ids']= depend.id
# Store it
- self.expandProperty(property,project,workspace)
+ self.expandProperty(xmlproperty,project,workspace)
+ self.importProperty(xmlproperty)
#
@@ -178,7 +183,7 @@
# Import the properties..
PropertyContainer.importProperties(self,self.xml)
- # Compelte them all
+ # Complete them all
self.completeProperties(workspace)
self.setComplete(1)
1.7 +8 -1 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- property.py 18 Nov 2003 22:54:50 -0000 1.6
+++ property.py 11 Dec 2003 18:56:27 -0000 1.7
@@ -168,12 +168,19 @@
def getProperty(self,name):
return self.properties[name]
+ def hasProperties(self):
+ if self.properties: return 1
+ return 0
+
def getProperties(self):
return self.properties.values()
def importProperties(self,xml):
for xmlproperty in xml.property:
- self.addProperty(Property(xmlproperty,self))
+ self.importProperty(xmlproperty)
+
+ def importProperty(self,xmlproperty):
+ self.addProperty(Property(xmlproperty,self))
def completeProperties(self,workspace=None):
if not workspace: workspace=self
1.6 +2 -0 jakarta-gump/python/gump/test/resources/full1/module2.xml
Index: module2.xml
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/test/resources/full1/module2.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- module2.xml 26 Nov 2003 16:08:39 -0000 1.5
+++ module2.xml 11 Dec 2003 18:56:27 -0000 1.6
@@ -12,6 +12,8 @@
<ant target="gump">
<property name="ant.home" reference="home" project="project1"/>
+ <property name="containsSpaces" value="a b c '' d e"/>
+ <depend property="project1.jar" project="project1"/>
</ant>
<depend project="project1" inherit="runtime"/>
1.11 +11 -1 jakarta-gump/python/gump/test/model.py
Index: model.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/test/model.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- model.py 5 Dec 2003 00:51:50 -0000 1.10
+++ model.py 11 Dec 2003 18:56:27 -0000 1.11
@@ -212,5 +212,15 @@
for report in self.project3.getReports():
self.assertNonZero('Need a directory', report.getResolvedPath())
+
+ def testProperties(self):
+ self.assertTrue('Has <ant <property',
self.project2.getAnt().hasProperties())
-
\ No newline at end of file
+ #for property in self.project2.getAnt().getProperties():
+ # print `property`
+
+ commandLine=self.project2.getBuildCommand().formatCommandLine()
+ self.assertIn('Need ant.home', 'ant.home', commandLine)
+ self.assertIn('Need project1.jar', 'project1.jar', commandLine)
+
+ print commandLine
\ No newline at end of file
1.2 +25 -0 jakarta-gump/python/gump/test/utils.py
Index: utils.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/test/utils.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- utils.py 20 Nov 2003 20:51:49 -0000 1.1
+++ utils.py 11 Dec 2003 18:56:27 -0000 1.2
@@ -62,6 +62,7 @@
"""
from gump.utils import *
+from gump.utils.launcher import Parameters
from gump.test.pyunit import UnitTestSuite
class UtilsTestSuite(UnitTestSuite):
@@ -112,4 +113,28 @@
rough=getGeneralDifferenceDescription(self.now, twoYearsBefore)
self.assertIn('Date Diff String', '2 years', rough)
+
+ def testSpacesInCommandLines(self):
+ params=Parameters()
+ params.addParameter('NoSpaces', 'aaaaa','=')
+ params.addParameter('WithValueSpaces', 'aa aa a','=')
+ params.addParameter('With Name Spaces', 'aaaaa','=')
+ params.addParameter('WithQuotesAndSpaces', 'aa \' \" aa a','=')
+ params.addParameter('WithEscapes', 'aa\\a','=')
+
+ print params.formatCommandLine()
+
+ params=Parameters()
+ params.addPrefixedParameter('-D','X', 'aaaaa','=')
+ params.addPrefixedParameter('-D','Y', 'aa aa a','=')
+ params.addPrefixedParameter('-D','Z', 'aa \' aa a','=')
+ params.addPrefixedParameter('-D','Z', 'aa \" aa a','=')
+
+ print params.formatCommandLine()
+
+ def testWrap(self):
+
line='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
+ print wrapLine(line)
+
line='1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'
+ print wrapLine(line)
1.3 +27 -29 jakarta-gump/python/gump/syndication/rss.pyc
<<Binary file>>
1.3 +19 -21 jakarta-gump/python/gump/syndication/syndicator.pyc
<<Binary file>>
1.35 +25 -1 jakarta-gump/python/gump/document/forrest.py
Index: forrest.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/document/forrest.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- forrest.py 10 Dec 2003 15:33:02 -0000 1.34
+++ forrest.py 11 Dec 2003 18:56:27 -0000 1.35
@@ -320,6 +320,8 @@
detailsTable.createEntry("Prefix: ", workspace.prefix)
detailsTable.createEntry("Signature: ", workspace.signature)
+ self.documentProperties(detailsSection, workspace, 'Workspace Properties')
+
# Does this workspace send nag mails?
if workspace.xml.nag:
nag='true'
@@ -949,9 +951,14 @@
miscSection=document.createSection('Miscellaneous')
if project.hasBuildCommand():
+
+ if project.hasAnt():
+ self.documentProperties(miscSection, project.getAnt(), 'Ant
Properties')
+
(classpath,bootclasspath)=project.getClasspathLists()
self.displayClasspath(miscSection, classpath,'Classpath',project)
- self.displayClasspath(miscSection, bootclasspath,'Boot
Classpath',project)
+ self.displayClasspath(miscSection, bootclasspath,'Boot
Classpath',project)
+
self.documentXML(miscSection,project)
@@ -1048,6 +1055,20 @@
# when not string get the object link and <link it...
noteRow.createData(note.text)
+ def documentProperties(self,xdocNode,propertyContainer,title='Properties'):
+
+ properties=propertyContainer.getProperties()
+ if not properties: return
+
+ propertiesSection=xdocNode.createSection(title)
+
+ propertiesTable=propertiesSection.createTable(['Name','Value','XML'])
+ for property in properties:
+ propertyRow=propertiesTable.createRow()
+ propertyRow.createData(property.getName())
+ propertyRow.createData(property.getValue())
+ propertyRow.createData(property.getViewData())
+
def documentXML(self,xdocNode,xmlOwner):
xml=xmlOwner.xml
@@ -1226,6 +1247,9 @@
o=open(output, 'r')
line=o.readline()
while line:
+
+ line=wrapLine(line,'...<br/>',' ',100)
+
length = len(line)
size += length
# Crude to 'ensure' that escaped
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]