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 2004/01/28 23:54:51 UTC
cvs commit: jakarta-gump/python/gump/test/resources/full1 module2.xml module1.xml
ajack 2004/01/28 14:54:51
Modified: python/gump engine.py
python/gump/test nagging.py
python/gump/syndication rss.py
python/gump/output xref.py nag.py
python/gump/net mailer.py
python/gump/test/resources/full1 module2.xml module1.xml
Log:
Getting ready for nagging...
Revision Changes Path
1.49 +4 -2 jakarta-gump/python/gump/engine.py
Index: engine.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- engine.py 28 Jan 2004 00:13:39 -0000 1.48
+++ engine.py 28 Jan 2004 22:54:49 -0000 1.49
@@ -135,9 +135,11 @@
#
# Only an 'all' is an official build, for them:
#
- # Nag and provide RSS
+ # Send Naggin E-mails
#
- if run.getGumpSet().isFull() and run.getWorkspace().isNag():
+ if 1:
+# if run.getGumpSet().isFull() \
+# and run.getWorkspace().isNag():
log.info('Nag about failures... ')
1.2 +40 -4 jakarta-gump/python/gump/test/nagging.py
Index: nagging.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/test/nagging.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nagging.py 28 Jan 2004 00:13:39 -0000 1.1
+++ nagging.py 28 Jan 2004 22:54:49 -0000 1.2
@@ -70,7 +70,8 @@
from gump.gumprun import GumpRun
from gump.test import getWorkedTestWorkspace
from gump.test.pyunit import UnitTestSuite
-from gump.output.nag import nag,getContent
+from gump.output.nag import nag,Nagger
+from gump.net.mailer import *
class NaggingTestSuite(UnitTestSuite):
def __init__(self):
@@ -86,14 +87,49 @@
def testNagContents(self):
+ nagger=Nagger(self.run)
+
# For all modules...
for module in self.workspace.getModules():
print 'Get Content For Module : ' + module.getName()
- print getContent(self.run,self.workspace,module,'Testing Module...')
+ print nagger.getContent(module,'test','Testing Module...')
for project in module.getProjects():
print 'Get Content For Project : ' + project.getName()
- print getContent(self.run,self.workspace,project,'Testing Project...')
+ print nagger.getContent(project,'test','Testing Project...')
+
+ def testNagAddresses(self):
+
+ nagger=Nagger(self.run)
+
+ # For all modules...
+ for module in self.workspace.getModules():
+ print 'Get Addresses For Module : ' + module.getName()
+ addresses=nagger.getAddressPairs(module)
+ for addr in addresses:
+ print 'AddressPair : ' + str(addr)
+ for project in module.getProjects():
+ print 'Get Addresses For Project : ' + project.getName()
+ addresses=nagger.getAddressPairs(project)
+ for addr in addresses:
+ print 'AddressPair : ' + str(addr)
+
+ def testNagEmails(self):
+
+ nagger=Nagger(self.run)
+
+ # For all modules...
+ for module in self.workspace.getModules():
+ for project in module.getProjects():
+ print 'Get E-mail For Project : ' + project.getName()
+ addresses=nagger.getAddressPairs(project)
+ for addr in addresses:
+ toAddrs=[ addr.getToAddress() ]
+ email=EmailMessage( toAddrs, \
+ addr.getFromAddress(), \
+ 'Test Subject', \
+ 'Test Content')
+ print str(email)
- def testNag(self):
+ def testNag(self):
nag(self.run)
1.17 +4 -4 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- rss.py 20 Jan 2004 21:55:23 -0000 1.16
+++ rss.py 28 Jan 2004 22:54:50 -0000 1.17
@@ -334,7 +334,7 @@
def syndicateProject(self,project,moduleRSS,mainRSS):
rssFile=self.run.getOptions().getResolver().getFile(project,project.getName(),'.rss')
- rssUrl=self.run.getOptions().getResolver().getUrl(project,'index','.rss')
+ rssUrl=self.run.getOptions().getResolver().getUrl(project,project.getName(),'.rss')
projectUrl=self.run.getOptions().getResolver().getUrl(project)
projectRSS=RSS(rssUrl, rssFile, \
1.8 +6 -4 jakarta-gump/python/gump/output/xref.py
Index: xref.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/output/xref.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- xref.py 28 Jan 2004 00:13:39 -0000 1.7
+++ xref.py 28 Jan 2004 22:54:50 -0000 1.8
@@ -168,7 +168,9 @@
for module in self.workspace.getModules():
for project in module.getProjects():
metadataLocation=str(project.xml.href)
-
+
+ print project.getName() + ' : ' + metadataLocation + "\n";
+
if metadataLocation:
if not self.descriptorLocationToProject.has_key(metadataLocation):
self.descriptorLocationToProject[metadataLocation]=[]
1.7 +256 -175 jakarta-gump/python/gump/output/nag.py
Index: nag.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/output/nag.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- nag.py 28 Jan 2004 00:13:39 -0000 1.6
+++ nag.py 28 Jan 2004 22:54:50 -0000 1.7
@@ -78,201 +78,282 @@
from gump.net.mailer import *
from gump.utils import *
-def nag(run):
+LINE='------------------------------------------------- G U M P Y\n'
- workspace=run.getWorkspace()
- gumpSet=run.getGumpSet()
-
- #
- # Belt and braces...
- #
- if not workspace.isNag():
- return
+class AddressPair:
+ def __init__(self,toAddr,fromAddr):
+ self.toAddr=toAddr
+ self.fromAddr=fromAddr
+
+ def __str__(self):
+ return '[To:' + self.toAddr + ', From:' + self.fromAddr + ']'
+
+ def getToAddress(self):
+ return self.toAddr
+
+ def getFromAddress(self):
+ return self.fromAddr
- #
- # Nag about the workspace (if it needs it)
- #
- if workspace.isFailed():
- nagWorkspace(run,workspace)
-
- # For all modules...
- for module in workspace.getModules():
- if not gumpSet.inModules(module): continue
+class Nagger:
+
+ def __init__(self,run):
+ self.run = run
+ self.workspace=run.getWorkspace()
+ self.gumpSet=run.getGumpSet()
+
+ self.unsent=''
+ self.unwanted=''
+
+
+ def nag(self):
+
+ #
+ # Belt and braces...
+ #
+ if not self.workspace.isNag():
+ return
+
+ # A bit paranoid, ought just rely upon object being
+ # destroyed,
+ self.sent=''
+ self.unwanted=''
+
+ #
+ # Nag about the workspace (if it needs it)
+ #
+ if self.workspace.isFailed():
+ self.nagWorkspace(run,self.workspace)
+
+ # For all modules...
+ for module in self.workspace.getModules():
+ if not self.gumpSet.inModules(module): continue
- if module.isFailed():
- try:
- log.info('Nag for module: ' + module.getName())
+ if module.isFailed():
+ try:
+ log.info('Nag for module: ' + module.getName())
+ self.nagModule(module)
- nagModule(run,workspace,module)
-
- except Exception, details:
- log.error("Failed to send nag e-mails for module " + module.getName()\
- + " : " + str(details), exc_info=1)
- else:
- for project in module.getProjects():
- if project.isFailed() :
- if not gumpSet.inSequence(project): continue
-
- try:
+ except Exception, details:
+ log.error("Failed to send nag e-mails for module " + module.getName()\
+ + " : " + str(details), exc_info=1)
+ else:
+ for project in module.getProjects():
+ if project.isFailed() :
+ if not self.gumpSet.inSequence(project): continue
- log.info('Nag for project: ' + project.getName())
- nagProject(run,workspace,project)
- except Exception, details:
- log.error("Failed to send nag e-mails for project " + project.getName()\
+ try:
+ log.info('Nag for project: ' + project.getName())
+ self.nagProject(project)
+
+ except Exception, details:
+ log.error("Failed to send nag e-mails for project " + project.getName()\
+ " : " + str(details), exc_info=1)
-def nagWorkspace(run,workspace):
- """ Nag for the workspace """
- content=getContent(workspace, "There is a workspace problem... \n")
- sendEmail(workspace,workspace.mailinglist,workspace.email,workspace.prefix+': Gump Workspace Problem ',content)
-
-def nagModule(run,workspace,module):
- """ Nag to a specific module's <nag entry """
- content=''
-
- #
- # Form the content...
- #
- content+=getContent(run,workspace,module,"Module: " + module.getName() + "\n")
-
- #
- # Form the sujhect
- #
- subject=workspace.prefix+': '+module.getName()+' '+lower(stateName(module.getState()))
+ # Belt and braces (nag to us if not nag to them)
+ if self.unwanted:
+ self.sendEmail(self.workspace.mailinglist,self.workspace.email, \
+ 'All dressed up, with nowhere to go...',self.unwanted)
+
+ # A bit paranoid, ought just rely upon object being
+ # destroyed,
+ self.unwanted=''
+
+ # Belt and braces (nag to us if not nag to them)
+ if self.sent:
+ self.sendEmail(self.workspace.mailinglist,self.workspace.email, \
+ 'Unable to send...',self.unsent)
+
+ # A bit paranoid, ought just rely upon object being
+ # destroyed,
+ self.sent=''
+
+ def addUnwanted(self,subject,content):
+ self.addStuff(self.unwanted,subject,content)
- nags=0
- for nagEntry in module.xml.nag:
- try:
- #
- # Form and send the e-mail...
- #
- toaddr=getattr(nagEntry,'to',workspace.mailinglist)
- fromaddr=getattr(nagEntry,'from',workspace.mailinglist)
-
- sendEmail(workspace,toaddr,fromaddr,subject,content)
-
- nags+=1
- except Exception, details:
- log.error("Failed to send nag e-mail for module " + module.name \
- + " : " + str(details))
- log.error(content, exc_info=1)
+ def addUnsent(self,subject,content):
+ self.addStuff(self.sent,subject,content)
+
+ def addStuff(self,store,subject,content):
+ if store:
+ store += '-------------------------------------------------------------\n'
+ store += subject
+ store += "\n"
+ store += content
+ store += "\n"
+
+ def nagWorkspace(self):
+ """ Nag for the workspace """
+ content=self.getContent(self.workspace,'index',"There is a workspace problem... \n")
+
+ self.sendEmail(self.workspace.mailinglist, \
+ self.workspace.email, \
+ self.workspace.prefix+': Gump Workspace Problem ',content)
+
+ def nagModule(self,module):
+ """ Nag to a specific module's <nag entry """
+ content=''
+
+ #
+ # Form the content...
+ #
+ content+=self.getContent(module,'index',"Module: " + module.getName() + "\n")
+
+ #
+ # Form the subject
+ #
+ subject=self.workspace.prefix+ \
+ ': '+module.getName()+' '+ \
+ lower(stateName(module.getState()))
+
+ self.sendEmails(self.getAddressPairs(module),subject,content)
- # Belt and braces (nag to us if not nag to them)
- if not nags:
- sendEmail(workspace,workspace.mailinglist,workspace.mailinglist,subject,content)
-
-
-def nagProject(run,workspace,project):
- """ Nag to a specific project's <nag entry """
- content=''
-
- module=project.getModule()
-
- #
- # Form the content...
- #
- displayedModule=0
- displayedProject=0
- if not module.isSuccess():
- displayedModule=1
- content+=getContent(run,workspace,module,"Module: " + module.getName() + "\n")
-
- if not project.isSuccess():
- displayedProject=1
- content+=getContent(run,workspace,project,"Project: " + project.getName() + "\n" )
-
- # No clue why this would happen, but fallback safe...
- if not displayedModule and not displayedProject:
- content+=getContent(run,workspace,module,"Module: " + module.getName() + "\n")
- content+=getContent(run,workspace,project,"Project: " + project.getName() + "\n")
-
- #
- # Form the sujhect
- #
- subject=workspace.prefix+': '+module.getName()+'/'+project.getName()+' '+lower(stateName(project.getState()))
- nags=0
- for nagEntry in project.xml.nag:
- try:
+ def nagProject(self,project):
+ """ Nag to a specific project's <nag entry """
+ content=''
+
+ module=project.getModule()
+
+ #
+ # Form the content...
+ #
+ displayedModule=0
+ displayedProject=0
+ if not module.isSuccess():
+ displayedModule=1
+ content+=self.getContent(module,'index',"Module: " + module.getName() + "\n")
+
+ if not project.isSuccess():
+ displayedProject=1
+ content+=self.getContent(project, project.getName(), "Project: " + project.getName() + "\n" )
+
+ # No clue why this would happen, but fallback safe...
+ if not displayedModule and not displayedProject:
+ content+=self.getContent(module,'index',"Module: " + module.getName() + "\n")
+ content+="\n"
+ content+=self.getContent(project,project.getName(), "Project: " + project.getName() + "\n")
+
+ #
+ # Form the subject
+ #
+ subject=self.workspace.prefix+': ' \
+ +module.getName()+'/'+project.getName() \
+ +' '+lower(stateName(project.getState()))
+
+ # Send those e-mails
+ self.sendEmails(self.getAddressPairs(project),subject,content)
+
+ def getAddressPairs(self, object):
+ nags=[]
+
+ for nagEntry in object.xml.nag:
#
- # Form and send the e-mail...
+ # Determine where to send
#
- toaddr=getattr(nagEntry,'to',workspace.mailinglist)
- fromaddr=getattr(nagEntry,'from',workspace.mailinglist)
+ toaddr=getattr(nagEntry,'to',self.workspace.mailinglist)
+ fromaddr=getattr(nagEntry,'from',self.workspace.email)
+
+ nags.append(AddressPair(toaddr,fromaddr))
+
+ return nags
+
+
+ def sendEmails(self, addressPairs, subject, content):
+ if addressPairs:
+ for pair in addressPairs:
+ self.sendEmail(pair.getToAddress(), pair.getFromAddress(), \
+ subject, content)
+ else:
+ self.addUnwanted(subject,content)
+
+ def sendEmail(self, toaddr, fromaddr, subject, content):
+ #
+ # We send to a list, but a list of one is fine..
+ #
+ toaddrs=[ toaddr ]
+
+ #
+ # Form the user visable part ...
+ #
+ email=EmailMessage( toaddrs, \
+ fromaddr, \
+ subject, \
+ content)
+
+ try:
- sendEmail(workspace,toaddr,fromaddr,subject,content)
+ #print '-------------------------------------------------------------------'
+ #print 'To:' + `toaddr`
+ #print 'From:' + `fromaddr`
+ #print 'Subject:' + `subject`
+ #print 'Server:' + `self.workspace.mailserver`
+ #print 'e-mail:' + `email`
+ # Fire ...
+ mail(toaddrs,fromaddr,email,self.workspace.mailserver)
- nags+=1
except Exception, details:
- log.error("Failed to send nag e-mail for project " + project.name \
- + " : " + str(details))
- log.error(content, exc_info=1)
-
- # Belt and braces (nag to us if not nag to them)
- if not nags:
- sendEmail(workspace,workspace.mailinglist,workspace.mailinglist,subject,content)
-
-def sendEmail(workspace, toaddr, fromaddr, subject, content):
- #
- # We send to a list, but a list of one is fine..
- #
- toaddrs=[ toaddr ]
-
- #
- # Form the user visable part ...
- #
- email=EmailMessage( toaddrs, \
- fromaddr, \
- subject, \
- content)
+ log.error("Failed to send nag e-mail: " + str(details), \
+ exc_info=1)
- print 'To:' + `toaddrs`
- print 'From:' + `toaddrs`
- print 'Subject:' + `toaddrs`
- print 'Server:' + `workspace.mailserver`
- print 'e-mail:' + `email`
-
- # Fire ...
- #mail(toaddrs,fromaddr,email,workspace.mailserver)
+ self.addUnsent(subject,content)
+
-def getContent(run,workspace,object,message=''):
- content=''
+ def getContent(self,object,feedPrefix=None,message=None):
+ content=''
- # Optional message
- if message:
- content=message
-
- #
- # Add State (and reason)
- #
- content += "State: " + object.getStateDescription() + "\n"
+ # Optional message
+ if message:
+ content=message
+
+ #
+ # Add State (and reason)
+ #
+ content += "State: " + object.getStateDescription() + "\n"
- if not object.hasReason():
- content += "Reason: " + object.getReasonDescription() + "\n"
+ if not object.hasReason():
+ content += "Reason: " + object.getReasonDescription() + "\n"
- #
- # Link them back here...
- #
- url=run.getOptions().getResolver().getUrl(object)
- content += "URL: " + url + "\n"
-
- #
- # Add an info/error/etc...
- #
- #if object.annotations:
- # content += "\n\nAnnotations:\n"
- # for note in object.annotations:
- # content += (' - %s - %s\n' % (levelName(note.level), note.text))
-
- #
- # Work
- #
- #if object.worklist:
- # content+="\n\nWork Items:\n"
- # for workitem in object.worklist:
- # content+=workitem.overview()+"\n"
+ #
+ # Link them back here...
+ #
+ url=self.run.getOptions().getResolver().getUrl(object)
+ content += "URL: " + url + "\n"
+
+ if feedPrefix:
+ #
+ # Link them back here...
+ #
+ rssurl=self.run.getOptions().getResolver().getUrl(object,feedPrefix,'.rss')
+ content += "RSS: " + rssurl + "\n"
+
+ #
+ # Link them back here...
+ #
+ atomurl=self.run.getOptions().getResolver().getUrl(object,feedPrefix,'.atom')
+ content += "Atom: " + atomurl + "\n"
+
+ #
+ # Add an info/error/etc...
+ #
+ if object.annotations:
+ content += LINE
+ content += "\n\nAnnotations:\n"
+ for note in object.annotations:
+ content += (' - %s - %s\n' % (levelName(note.level), note.text))
+
+ #
+ # Work
+ #
+ if object.worklist:
+ content+="\n\n"
+ for workitem in object.worklist:
+ content += LINE
+ content+=workitem.overview()+"\n"
- return content
+ return content
+def nag(run):
+ nagger=Nagger(run)
+ nagger.nag()
1.3 +6 -0 jakarta-gump/python/gump/net/mailer.py
Index: mailer.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/net/mailer.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mailer.py 9 Jan 2004 19:57:19 -0000 1.2
+++ mailer.py 28 Jan 2004 22:54:50 -0000 1.3
@@ -68,6 +68,12 @@
import smtplib, string
class EmailMessage:
+
+ def __repr__(self):
+ return str(self)
+
+ def __str__(self):
+ return self.getSerialized()
# A *list* if recipients
# A single sender
1.10 +2 -2 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- module2.xml 23 Jan 2004 23:32:26 -0000 1.9
+++ module2.xml 28 Jan 2004 22:54:50 -0000 1.10
@@ -26,8 +26,8 @@
<license name="LICENSE"/>
- <nag from="Gump Integration Build <gump@jakarta.apache.org>"
- to="gump@jakarta.apache.org"/>
+ <nag from="Mr Dev 2 <dev2@jakarta.apache.org>"
+ to="project2@jakarta.apache.org"/>
</project>
</module>
1.5 +5 -2 jakarta-gump/python/gump/test/resources/full1/module1.xml
Index: module1.xml
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gump/test/resources/full1/module1.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- module1.xml 21 Jan 2004 18:52:30 -0000 1.4
+++ module1.xml 28 Jan 2004 22:54:50 -0000 1.5
@@ -7,6 +7,9 @@
<cvs repository="repository1"/>
+ <nag from="Ms. Dev 1 <dev1@jakarta.apache.org>"
+ to="project1@jakarta.apache.org"/>
+
<project name="project1">
<package>org.apache.project1</package>
@@ -20,8 +23,8 @@
<license name="LICENSE"/>
- <nag from="Gump Integration Build <gump@jakarta.apache.org>"
- to="gump@jakarta.apache.org"/>
+ <nag from="Ms. Dev 1 <dev1@jakarta.apache.org>"
+ to="project1@jakarta.apache.org"/>
</project>
</module>