ajack 2004/01/06 13:35:46 Modified: python/gump/syndication rss.pyc syndicator.pyc rss.py syndicator.py python/gump/utils launcher.py python/gump/test syndicator.py python/gump/document forrest.py Added: python/gump/syndication atom.py Log: 1) Removed some stray print statements 2) Noted when a project isn't built by gump (in project docs) 3) Some tinkering around Atom. Revision Changes Path 1.5 +13 -19 jakarta-gump/python/gump/syndication/rss.pyc <<Binary file>> 1.4 +13 -6 jakarta-gump/python/gump/syndication/syndicator.pyc <<Binary file>> 1.11 +6 -22 jakarta-gump/python/gump/syndication/rss.py Index: rss.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/syndication/rss.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- rss.py 14 Dec 2003 17:57:39 -0000 1.10 +++ rss.py 6 Jan 2004 21:35:45 -0000 1.11 @@ -287,7 +287,7 @@ self.syndicateModule(module,self.rss) self.rss.serialize() - + def syndicateModule(self,module,mainRSS): rssFile=self.run.getOptions().getResolver().getFile(module,'index','.rss') @@ -299,8 +299,7 @@ moduleUrl, \ escape(module.getDescription()), \ self.gumpImage)) - - s=module.getStats() + datestr=time.strftime('%Y-%m-%d') timestr=time.strftime('%H:%M:%S') @@ -319,18 +318,11 @@ ('%sT%s%s') % (datestr,timestr,TZ)) # Generate changes, only if the module had changed - if module.isUpdated(): - if not s.currentState == STATE_NONE and \ - not s.currentState == STATE_UNSET: + if module.isUpdated() and not module.getState().isUnset(): 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 \ - and not module.isPackaged() : + if self.moduleOughtBeWidelySyndicated(module): mainRSS.addItem(item) for project in module.getProjects(): @@ -350,7 +342,6 @@ escape(project.getDescription()), \ self.gumpImage)) - s=project.getStats() datestr=time.strftime('%Y-%m-%d') timestr=time.strftime('%H:%M:%S') @@ -368,19 +359,12 @@ ('%sT%s%s') % (datestr,timestr,TZ)) # Generate changes, only if the module changed - if project.getModule().isUpdated(): - if not s.currentState == STATE_NONE and \ - not s.currentState == STATE_UNSET: + if project.getModule().isUpdated() and not project.getState().isUnset(): 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 \ - and not project.isPackaged() : + if self.projectOughtBeWidelySyndicated(project) : mainRSS.addItem(item) projectRSS.serialize() 1.8 +34 -7 jakarta-gump/python/gump/syndication/syndicator.py Index: syndicator.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/syndication/syndicator.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- syndicator.py 9 Dec 2003 00:48:36 -0000 1.7 +++ syndicator.py 6 Jan 2004 21:35:45 -0000 1.8 @@ -185,13 +185,40 @@ return content + def moduleOughtBeWidelySyndicated(self, module): + stats=module.getStats() + + return stats.sequenceInState == 1 \ + and not stats.currentState == STATE_PREREQ_FAILED \ + and not stats.currentState == STATE_UNSET \ + and not stats.currentState == STATE_NONE \ + and not stats.currentState == STATE_COMPLETE \ + and not module.isPackaged() + + def projectOughtBeWidelySyndicated(self, project): + + stats=project.getStats() + + return stats.sequenceInState == 1 \ + and not stats.currentState == STATE_PREREQ_FAILED \ + and not stats.currentState == STATE_UNSET \ + and not stats.currentState == STATE_NONE \ + and not stats.currentState == STATE_COMPLETE \ + and not project.isPackaged() def syndicate(run): - - from gump.syndication.rss import RSSSyndicator - simple=RSSSyndicator() - simple.syndicate(run) - - #atom=AtomSyndicator() - #atom.syndicate(run) \ No newline at end of file + + try: + from gump.syndication.rss import RSSSyndicator + simple=RSSSyndicator() + simple.syndicate(run) + except: + pass + + try: + from gump.syndication.atom import AtomSyndicator + atom=AtomSyndicator() + atom.syndicate(run) + except: + pass \ No newline at end of file 1.1 jakarta-gump/python/gump/syndication/atom.py Index: atom.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 Atom 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.config import setting from gump.syndication.syndicator import Syndicator ############################################################################### # Local time zone, in offset from GMT TZ='%+.2d:00' % (-time.timezone/3600) ############################################################################### class Entry: """ An entry (news item) in an Atom Feed. Note: Can be added to more than one feed at once. """ def __init__(self,title,link,description,content=None): self.title=title self.link=link self.description=description self.content=content def serializeToStream(self, stream, modified): # Write the header part... stream.write(""" <entry> <title>%s</title> <link rel="alternate" type="text/html" href="%s"/> <modified>%s</modified> """ \ % (self.description, self.link, modified) ) if self.content: stream.write("""<content>%s</content>""" \ % (escape(self.content)) ) # Write the trailer part... stream.write(""" </entry>\n""") class AtomFeed: def __init__(self,url,file,title,link,description): self.url=url self.file=file self.title=title self.link=link self.description=description self.entries=[] def addEntry(self,entry): self.entries += entry def serializeToStream(self, stream, modified): # Write the header part... stream.write("""<?xml version="1.0" encoding="utf-8"?> <feed version="0.3" xmlns="http://purl.org/atom/ns#"> <title>%s</title> <link rel="alternate" type="text/html" href="%s"/> <modified>%s</modified> """ % (self.description, self.link, modified) ) for entry in self.entries: entry.serializeToStream(stream, modified) # Write the trailer part... stream.write(""" </feed> """) def serialize(self): log.info("Atom Feed to : " + self.file); stream = open(self.file,'w') modified='known2bBogus' try: self.serializeToStream(stream,modified) except: pass # Close the file. stream.close() class AtomSyndicator(Syndicator): def __init__(self): Syndicator.__init__(self) def syndicate(self,run): # Main syndication document self.run = run self.workspace=run.getWorkspace() feedFile=self.run.getOptions().getResolver().getFile(self.workspace,'index','.atom') feedUrl=self.run.getOptions().getResolver().getUrl(self.workspace,'index','.atom') self.feed=AtomFeed(feedUrl,feedFile, \ 'Jakarta Gump', \ self.workspace.logurl, \ """Life is like a box of chocolates""") # build information for module in self.workspace.getModules(): self.syndicateModule(module,self.feed) self.feed.serialize() def syndicateModule(self,module,mainFeed): feedFile=self.run.getOptions().getResolver().getFile(module,'index','.atom') feedUrl=self.run.getOptions().getResolver().getUrl(module,'index','.atom') moduleUrl=self.run.getOptions().getResolver().getUrl(module) moduleFeed=AtomFeed(feedUrl,feedFile, 'Gump : Module ' + escape(module.getName()), \ moduleUrl, \ escape(module.getDescription())) datestr=time.strftime('%Y-%m-%d') timestr=time.strftime('%H:%M:%S') # # Get a decent description # content=self.getModuleContent(module,self.run) # # # entry=Entry(('%s %s %s') % (module.getName(),module.getStateDescription(),datestr), \ moduleUrl, \ module.getName(), \ content) # Generate changes, only if the module had changed if module.isUpdated(): if not s.currentState == STATE_NONE and \ not s.currentState == STATE_UNSET: moduleFeed.addEntry(entry) # State changes that are newsworthy... if self.moduleOughtBeWidelySyndicated(module): mainFeed.addEntry(entry) # Syndicate each project for project in module.getProjects(): self.syndicateProject(project,moduleFeed,mainFeed) moduleFeed.serialize() def syndicateProject(self,project,moduleFeed,mainFeed): feedFile=self.run.getOptions().getResolver().getFile(project,project.getName(),'.atom') feedUrl=self.run.getOptions().getResolver().getUrl(project,'index','.atom') projectUrl=self.run.getOptions().getResolver().getUrl(project) projectFeed=AtomFeed(feedUrl, feedFile, \ 'Gump : Project ' + escape(project.getName()), \ projectUrl, \ escape(project.getDescription())) datestr=time.strftime('%Y-%m-%d') timestr=time.strftime('%H:%M:%S') # # Get a decent description # content=self.getProjectContent(project,self.run) # # entry=Entry(('%s %s %s') % (project.getName(),project.getStateDescription(),datestr), \ projectUrl, \ project.getModule().getName() + ":" + project.getName(), \ content ) # Generate changes, only if the project changed if project.getModule().isUpdated(): if not s.currentState == STATE_NONE and \ not s.currentState == STATE_UNSET: projectFeed.addEntry(entry) moduleFeed.addEntry(entry) # State changes that are newsworthy... if self.projectOughtBeWidelySyndicated(project) : mainFeed.addEntry(entry) projectFeed.serialize() 1.7 +0 -1 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- launcher.py 16 Dec 2003 20:43:42 -0000 1.6 +++ launcher.py 6 Jan 2004 21:35:46 -0000 1.7 @@ -466,7 +466,6 @@ result.exit_code=systemReturn log.debug('Command -> [' + str(systemReturn)+ '] [Sig:' + str(result.signal) + ' / Exit:' + str(result.exit_code) + '].') - print 'Command -> [' + str(systemReturn)+ '] [Sig:' + str(result.signal) + ' / Exit:' + str(result.exit_code) + '].' # # Assume timed out if signal terminated 1.3 +4 -3 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- syndicator.py 4 Dec 2003 23:16:24 -0000 1.2 +++ syndicator.py 6 Jan 2004 21:35:46 -0000 1.3 @@ -70,6 +70,7 @@ from gump.gumprun import GumpRun from gump.syndication import syndicate from gump.syndication.rss import RSSSyndicator +from gump.syndication.atom import AtomSyndicator from gump.test import getWorkedTestWorkspace from gump.test.pyunit import UnitTestSuite @@ -89,7 +90,7 @@ simple=RSSSyndicator() simple.syndicate(self.run) - #def testAtom(self): - # simple=AtomSyndicator() - # simple.syndicate(self.run) + def testAtom(self): + simple=AtomSyndicator() + simple.syndicate(self.run) 1.41 +6 -2 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.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- forrest.py 19 Dec 2003 00:23:02 -0000 1.40 +++ forrest.py 6 Jan 2004 21:35:46 -0000 1.41 @@ -270,6 +270,7 @@ syndRow=definitionTable.createRow() syndRow.createData('Syndication') syndRow.createData().createFork('index.rss','RSS') + syndRow.createData().createFork('index.atom','Atom') textRow=definitionTable.createRow() textRow.createData('Workspace Documentation') @@ -889,6 +890,9 @@ if project.isPackaged(): document.createNote('This is a packaged project, not Gumped.') + elif not project.hasBuildCommand(): + document.createNote('This project is not built by Gump.') + stateSection=document.createSection('State') @@ -947,11 +951,11 @@ # x.write('<p><strong>Project Config :</strong> <link href=\'%s\'>XML</link></p>' \ # % (getModuleProjectRelativeUrl(modulename,project.name)) ) - self.documentWorkList(document,project,'Project-level Work') + self.documentWorkList(document,project,'Project-level Work') miscSection=document.createSection('Miscellaneous') - if project.hasBuildCommand(): + if project.hasBuildCommand(): if project.hasAnt(): self.documentProperties(miscSection, project.getAnt(), 'Ant Properties')
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]