ajack 2003/12/04 15:16:24
Modified: python/gump engine.py config.py
python/gump/utils note.py
python/gump/test integrator.py syndicator.py
python/gump/model state.py
python/gump/output __init__.py
python/gump/document xdoc.py forrest.py
Added: python/gump/syndication rss.py __init__.py
Removed: python/gump/output rss.py
Log:
1) Tweaks to RSS content
2) Prepare syndication for Atom (RSS is one choice).
Revision Changes Path
1.36 +7 -5 jakarta-gump/python/gump/engine.py
Index: engine.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- engine.py 3 Dec 2003 18:36:13 -0000 1.35
+++ engine.py 4 Dec 2003 23:16:23 -0000 1.36
@@ -32,7 +32,7 @@
from gump.output.statsdb import *
from gump.output.repository import JarRepository
from gump.output.nag import nag
-from gump.output.rss import syndicate
+from gump.syndication import syndicate
###############################################################################
# Initialize
@@ -493,10 +493,12 @@
#
# Display report output...
#
- for report in project.getReports():
- reportDir=report.getResolvedPath()
- project.addInfo('Reports in: ' + reportDir)
- catDirectoryContentsAsWork(project,reportDir)
+ if project.hasReport():
+ project.addInfo('Project produces reports')
+ for report in project.getReports():
+ reportDir=report.getResolvedPath()
+ project.addInfo('Reports in: ' + reportDir)
+ catDirectoryContentsAsWork(project,reportDir)
"""
1.9 +1 -1 jakarta-gump/python/gump/config.py
Index: config.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/config.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- config.py 3 Dec 2003 18:36:13 -0000 1.8
+++ config.py 4 Dec 2003 23:16:23 -0000 1.9
@@ -121,7 +121,7 @@
class setting:
"""Configuration of hardcoded settings"""
- version="2.0.2-alpha-0001"
+ version="2.0.2-alpha-0002"
# :TODO: Add "minimum version" checks...
ws_version="0.4"
1.1 jakarta-gump/python/gump/syndication/rss.py
Index: rss.py
===================================================================
#!/usr/bin/env python
# $Header: /home/cvs/jakarta-gump/python/gump/rss.py,v 1.7 2003/09/11 21:11:42 ajack
Exp $
# $Revision: 1.7 $
# $Date: 2003/09/11 21:11:42 $
#
# ====================================================================
#
# The Apache Software License, Version 1.1
#
# Copyright (c) 2003 The Apache Software Foundation. All rights
# reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. The end-user documentation included with the redistribution, if
# any, must include the following acknowlegement:
# "This product includes software developed by the
# Apache Software Foundation (http://www.apache.org/)."
# Alternately, this acknowlegement may appear in the software itself,
# if and wherever such third-party acknowlegements normally appear.
#
# 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
# Foundation" must not be used to endorse or promote products derived
# from this software without prior written permission. For written
# permission, please contact [EMAIL PROTECTED]
#
# 5. Products derived from this software may not be called "Apache"
# nor may "Apache" appear in their names without prior written
# permission of the Apache Group.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation. For more
# information on the Apache Software Foundation, please see
# <http://www.apache.org/>.
"""
Highly experimental RSS feeds.
"""
import os
import time
from xml.sax.saxutils import escape
from gump import log
from gump.model.state import *
from gump.model.project import ProjectStatistics
from gump.syndication import Syndicator
###############################################################################
# Local time zone, in offset from GMT
TZ='%+.2d:00' % (-time.timezone/3600)
###############################################################################
class Image:
def __init__(self,url,title,link):
self.url=url
self.title=title
self.link=link
def startItem(self):
self.rssStream.write(' <image>\n')
# Mandatory Fields
self.rssStream.write((' <url>%s</url>\n') %(escape(self.url)))
self.rssStream.write((' <link>%s</link>\n') %(escape(self.link)))
self.rssStream.write((' <title>%s</title>\n') %(escape(self.title)))
def endItem(self):
self.rssStream.write(' </image>\n')
def serialize(self,rssStream):
self.rssStream = rssStream
self.rssStream.write(' <image>\n')
# Mandatory Fields
self.rssStream.write((' <url>%s</url>\n') %(escape(self.url)))
self.rssStream.write((' <link>%s</link>\n') %(escape(self.link)))
self.rssStream.write((' <title>%s</title>\n') %(escape(self.title)))
self.rssStream.write(' </image>\n')
class Item:
def __init__(self,title,link,description,subject,date,url=None,image=None):
self.title=title
self.link=link
self.description=description
self.subject=subject
self.date=date
self.url=url
self.image=image
def serialize(self,rssStream):
self.rssStream = rssStream
self.rssStream.write(' <item>\n')
# Mandatory Fields
self.rssStream.write((' <title>Jakarta Gump: %s</title>\n')
%(escape(self.title)))
self.rssStream.write((' <link>%s</link>\n') %(escape(self.link)))
self.rssStream.write((' <description>%s</description>\n')
%(escape(self.description)))
self.rssStream.write((' <dc:subject>%s</dc:subject>\n')
%(escape(self.subject)))
self.rssStream.write((' <dc:date>%s</dc:date>\n') %(escape(self.date)))
# Optional Fields
if self.image:
self.rssStream.write((' <image>%s</image>\n') %(escape(self.image)))
if self.url:
self.rssStream.write((' <url>%s</url>\n') %(escape(self.url)))
self.rssStream.write(' </item>\n')
class Channel:
def __init__(self,title,link,description,image=None):
self.title=title
self.link=link
self.description=description
self.image=image
self.items=[]
def startChannel(self):
self.rssStream.write(' <channel>\n')
# Mandatory Fields
self.rssStream.write((' <title>Jakarta Gump: %s</title>\n')
%(escape(self.title)))
self.rssStream.write((' <link>%s</link>\n') %(escape(self.link)))
self.rssStream.write((' <description>%s</description>\n')
%(escape(self.description)))
# Optional Fields
if self.image:
self.image.serialize(self.rssStream)
# Admin stuff
self.rssStream.write("""
<admin:generatorAgent
rdf:resource="http://cvs.apache.org/viewcvs/jakarta-gump/python/gump/output/rss.py"/>
<admin:errorReportsTo rdf:resource="mailto:[EMAIL PROTECTED]"/>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updatePeriod>daily</sy:updatePeriod>
""")
def endChannel(self):
self.rssStream.write(' </channel>\n')
def serialize(self,rssStream):
self.rssStream = rssStream
self.startChannel()
# Serialize all items
for item in self.items:
item.serialize(self.rssStream)
self.endChannel()
def addItem(self,item):
self.items.append(item)
class RSS:
def __init__(self,file,channel=None):
self.rssFile=file
self.channels=[]
if channel: self.addChannel(channel)
def startRSS(self):
self.rssStream.write("""<rss version="2.0"
xmlns:admin="http://webns.net/mvcb/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">""")
def endRSS(self):
# complete the rss feed
self.rssStream.write('</rss>\n')
log.info("RSS Newsfeed written to : " + self.rssFile);
def serialize(self):
log.info("RSS Newsfeed to : " + self.rssFile);
self.rssStream = open(self.rssFile,'w')
self.startRSS()
for channel in self.channels:
channel.serialize(self.rssStream)
self.endRSS()
# Close the file.
self.rssStream.close()
def addChannel(self,channel):
self.channels.append(channel)
def getCurrentChannel(self):
return self.channels[len(self.channels)-1]
def addItem(self,item,channel=None):
if not channel: channel = self.getCurrentChannel()
channel.addItem(item)
class RSSSyndicator(Syndicator):
def __init__(self):
Syndicator.__init__(self)
self.gumpImage=Image('http://jakarta.apache.org/gump/images/bench.png',
\
'Jakarta Gump', \
'http://jakarta.apache.org/gump/')
def syndicate(self,run):
# Main syndication document
self.run = run
self.workspace=run.getWorkspace()
self.rssFile=os.path.abspath(os.path.join( \
self.workspace.logdir,'index.rss'))
self.rss=RSS(self.rssFile, \
Channel('Jakarta Gump', \
self.workspace.logurl, \
"""Life is like a box of chocolates""", \
self.gumpImage))
# build information
for module in self.workspace.getModules():
self.syndicateModule(module,self.rss)
self.rss.serialize()
def syndicateModule(self,module,mainRSS):
rssFile=self.run.getOptions().getResolver().getFile(module,'index','.rss')
moduleURL=self.run.getOptions().getResolver().getUrl(module)
moduleRSS=RSS(rssFile, \
Channel('Jakarta Gump : Module ' + escape(module.getName()), \
moduleURL, \
escape(module.getDescription()), \
self.gumpImage))
for project in module.getProjects():
self.syndicateProject(project,moduleRSS,mainRSS)
moduleRSS.serialize()
def syndicateProject(self,project,moduleRSS,mainRSS):
rssFile=self.run.getOptions().getResolver().getFile(project,project.getName(),'.rss')
projectURL=self.run.getOptions().getResolver().getUrl(project)
projectRSS=RSS(rssFile, \
Channel('Jakarta Gump : Project ' + escape(project.getName()), \
projectURL, \
escape(project.getDescription()), \
self.gumpImage))
s=project.getStats()
datestr=time.strftime('%Y-%m-%d')
timestr=time.strftime('%H:%M:%S')
#
# Get a decent description
#
content=self.getProjectContent(project,self.run)
item=Item(('%s %s %s') %
(project.getName(),project.getStateDescription(),datestr), \
projectURL, \
content, \
project.getModule().getName() + ":" + project.getName(), \
('%sT%s%s') % (datestr,timestr,TZ))
# Generate changes
if not s.currentState == STATE_NONE and \
not s.currentState == STATE_UNSET:
projectRSS.addItem(item)
moduleRSS.addItem(item)
# State changes that are newsworthy...
if s.sequenceInState == 1 \
and not s.currentState == STATE_PREREQ_FAILED \
and not s.currentState == STATE_UNSET \
and not s.currentState == STATE_NONE \
and not s.currentState == STATE_COMPLETE :
mainRSS.addItem(item)
projectRSS.serialize()
1.1 jakarta-gump/python/gump/syndication/__init__.py
Index: __init__.py
===================================================================
#!/usr/bin/env python
# $Header: /home/cvs/jakarta-gump/python/gump/rss.py,v 1.7 2003/09/11 21:11:42 ajack
Exp $
# $Revision: 1.7 $
# $Date: 2003/09/11 21:11:42 $
#
# ====================================================================
#
# The Apache Software License, Version 1.1
#
# Copyright (c) 2003 The Apache Software Foundation. All rights
# reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. The end-user documentation included with the redistribution, if
# any, must include the following acknowlegement:
# "This product includes software developed by the
# Apache Software Foundation (http://www.apache.org/)."
# Alternately, this acknowlegement may appear in the software itself,
# if and wherever such third-party acknowlegements normally appear.
#
# 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
# Foundation" must not be used to endorse or promote products derived
# from this software without prior written permission. For written
# permission, please contact [EMAIL PROTECTED]
#
# 5. Products derived from this software may not be called "Apache"
# nor may "Apache" appear in their names without prior written
# permission of the Apache Group.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation. For more
# information on the Apache Software Foundation, please see
# <http://www.apache.org/>.
"""
Highly experimental RSS feeds.
"""
import os
import time
from xml.sax.saxutils import escape
from gump import log
from gump.model.state import *
from gump.model.project import ProjectStatistics
# tell Python what modules make up the gump.syndication package
__all__ = ["rss","atom"]
class Syndicator:
def __init__(self): pass
#
# Populate a method called 'document(run)'
#
def syndicate(self,run):
if not hasattr(self,'syndicateRun'):
raise RuntimeException, 'Complete [' + self.__class__ + '] with
syndicateRun(self,run)'
if not callable(self.syndicateRun):
raise RuntimeException, 'Complete [' + self.__class__ + '] with a
callable syndicateRun(self,run)'
log.info('Syndicate run using [' + `self` + ']')
self.syndicateRun(run)
def getProjectContent(self,project,run):
resolver=run.getOptions().getResolver()
stats=project.getStats()
content='Project ' + project.getName() \
+ ' : ' \
+ project.getStateDescription() \
+ ' ' \
+ project.getReasonDescription() \
+ '\n\n'
if not stats.previousState == STATE_NONE \
and not stats.previousState == STATE_UNSET:
content += 'Previous state: ' \
+ stateName(stats.previousState) \
+ '\n\n'
self.addSundries(project,content)
return content
def getModuletContent(self,module,run):
resolver=self.run.getOptions().getResolver()
stats=module.getStats()
content='Module ' + module.getName() \
+ ' : ' \
+ module.getStateDescription() \
+ ' ' \
+ module.getReasonDescription() \
+ '\n\n'
if not stats.previousState == STATE_NONE \
and not stats.previousState == STATE_UNSET:
content += 'Previous state: ' \
+ stateName(stats.previousState) \
+ '\n\n'
self.addSundries(module,content)
return content
def addSundries(self,object,content):
resolver=self.run.getOptions().getResolver()
if object.annotations:
content += '<table>'
for note in object.annotations:
content += ('<tr><td>' \
+ note.getLevelName() + '</td><td>' \
+ note.getText() + '</td></tr>\n')
content += '<table>'
if object.worklist:
content += '<table>'
for work in object.worklist:
url=resolver.getAbsoluteUrl(work)
state=stateName(work.state)
content += ('<tr><td><a href=\'' + \
url + '\'>' + work.getName() + \
'</a></td><td>' + state + \
'</td></tr>\n')
content += '<table>'
def syndicate(run):
simple=RSSSyndicator()
simple.syndicate(run)
#atom=AtomSyndicator()
#atom.syndicate(run)
1.3 +8 -4 jakarta-gump/python/gump/utils/note.py
Index: note.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/utils/note.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- note.py 3 Dec 2003 18:36:13 -0000 1.2
+++ note.py 4 Dec 2003 23:16:24 -0000 1.3
@@ -90,7 +90,13 @@
self.text=text
def __str__(self):
- return levelName(self.level) + ":" + self.text
+ return levelName(self.level) + ":" + self.text
+
+ def getLevelName(self):
+ return levelName(self.level)
+
+ def getText(self):
+ return self.text
def dump(self, indent=0, output=sys.stdout):
output.write(getIndent(indent)+str(self)+'\n')
@@ -132,9 +138,7 @@
if note.level >= level:
return 1
return 0
-
-
-
+
def dump(self, indent=0, output=sys.stdout):
""" Display the contents of this object """
if self.annotations:
1.2 +1 -1 jakarta-gump/python/gump/test/integrator.py
Index: integrator.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/test/integrator.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- integrator.py 1 Dec 2003 17:34:08 -0000 1.1
+++ integrator.py 4 Dec 2003 23:16:24 -0000 1.2
@@ -69,7 +69,7 @@
import gump.config
from gump.gumprun import GumpRun
from gump.engine import GumpEngine
-from gump.output.rss import syndicate
+from gump.output.syndication import syndicate
from gump.test import getWorkedTestWorkspace
from gump.test.pyunit import UnitTestSuite
1.2 +8 -2 jakarta-gump/python/gump/test/syndicator.py
Index: syndicator.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/test/syndicator.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- syndicator.py 1 Dec 2003 17:34:08 -0000 1.1
+++ syndicator.py 4 Dec 2003 23:16:24 -0000 1.2
@@ -68,7 +68,8 @@
from gump import log
import gump.config
from gump.gumprun import GumpRun
-from gump.output.rss import syndicate
+from gump.syndication import syndicate
+from gump.syndication.rss import RSSSyndicator
from gump.test import getWorkedTestWorkspace
from gump.test.pyunit import UnitTestSuite
@@ -85,5 +86,10 @@
self.run=GumpRun(self.workspace)
def testRSS(self):
- syndicate(self.run)
+ simple=RSSSyndicator()
+ simple.syndicate(self.run)
+
+ #def testAtom(self):
+ # simple=AtomSyndicator()
+ # simple.syndicate(self.run)
1.8 +4 -0 jakarta-gump/python/gump/model/state.py
Index: state.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/model/state.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- state.py 26 Nov 2003 01:26:28 -0000 1.7
+++ state.py 4 Dec 2003 23:16:24 -0000 1.8
@@ -168,6 +168,7 @@
return self.reason
def getReasonDescription(self):
+ if self.isReasonUnset(): return ''
return reasonString(self.getReason())
#
@@ -188,6 +189,9 @@
def isUnset(self):
return STATE_NONE==self.state \
or STATE_UNSET==self.state
+
+ def isReasonUnset(self):
+ return REASON_UNSET==self.reason
def isUnsetOrOk(self):
return self.isUnset() or self.isOk()
1.3 +2 -2 jakarta-gump/python/gump/output/__init__.py
Index: __init__.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/output/__init__.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- __init__.py 20 Nov 2003 20:51:48 -0000 1.2
+++ __init__.py 4 Dec 2003 23:16:24 -0000 1.3
@@ -59,5 +59,5 @@
# <http://www.apache.org/>.
-# tell Python what modules make up the gump.model package
-__all__ = ["nag","repository","rss","statsdb","xref"]
+# tell Python what modules make up the gump.output package
+__all__ = ["nag","repository","statsdb","xref"]
1.6 +3 -0 jakarta-gump/python/gump/document/xdoc.py
Index: xdoc.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/document/xdoc.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- xdoc.py 3 Dec 2003 18:36:13 -0000 1.5
+++ xdoc.py 4 Dec 2003 23:16:24 -0000 1.6
@@ -674,5 +674,8 @@
def createParagraph(self,text=None,transient=0):
return self.storePiece(XDocParagraph(self.createSubContext(transient),text))
+ def createNote(self,text=None):
+ return self.storePiece(XDocNote(self.createSubContext(),text))
+
1.29 +4 -4 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- forrest.py 3 Dec 2003 23:02:40 -0000 1.28
+++ forrest.py 4 Dec 2003 23:16:24 -0000 1.29
@@ -435,7 +435,7 @@
projectsSection=document.createSection('Projects with issues...')
projectsTable=projectsSection.createTable(['Name','Affected', \
- 'Duration\nin state''Project State','Elapsed'])
+ 'Duration\nin state','Project State','Elapsed'])
pcount=0
for project in sortedProjectList:
if not gumpSet.inSequence(project): continue
@@ -1034,7 +1034,7 @@
annotationsSection=xdocNode.createSection('Annotations')
if annotatable.containsNasties():
- annotationsSection.createWarning('Some warnings and/ or errors are
present')
+ annotationsSection.createWarning('Some warnings and/or errors are
present within these annotations.')
annotationsTable=annotationsSection.createTable()
for note in annotations:
@@ -1081,10 +1081,10 @@
for work in worklist:
workRow=workTable.createRow()
- workRow.createComment(workTypeName(work.type))
+ workRow.createComment(work.getName())
self.insertLink(work,workable,workRow.createData())
- workRow.createData(workTypeName(work.type))
+ workRow.createData(work.getName())
workRow.createData(stateName(work.state))
workRow.createData(secsToDate(work.result.start_time))
workRow.createData(secsToElapsedString(work.getElapsedSecs()))
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]