SF.net SVN: gar:[23348] csw/mgar/gar/v2/lib/python/chkdbcat.py
guengel at users.sourceforge.net
guengel at users.sourceforge.net
Sun Apr 6 11:24:57 CEST 2014
Revision: 23348
http://sourceforge.net/p/gar/code/23348
Author: guengel
Date: 2014-04-06 09:24:55 +0000 (Sun, 06 Apr 2014)
Log Message:
-----------
Information mail will now be composed using cheetah templates.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/chkdbcat.py
Modified: csw/mgar/gar/v2/lib/python/chkdbcat.py
===================================================================
--- csw/mgar/gar/v2/lib/python/chkdbcat.py 2014-04-06 08:52:57 UTC (rev 23347)
+++ csw/mgar/gar/v2/lib/python/chkdbcat.py 2014-04-06 09:24:55 UTC (rev 23348)
@@ -8,6 +8,7 @@
CheckDBCat.notify().
"""
from email.mime.text import MIMEText
+from Cheetah import Template
import cjson
import datetime
import dateutil.parser
@@ -456,27 +457,30 @@
class InformMaintainer(object):
- MAIL_CAT_BROKEN_HEADER = u"""Hi
+ """Inform maintainers about broken database catalog
+ """
+
+ MAIL_TEMPLATE = u"""Hi there
+
You uploaded following packages
-"""
+#for pkg in $pkg_data
+ * $pkg["fullname"]
+#end for
- MAIL_CAT_BROKEN_FOOTER = u"""
which may (or may not) have broken the catalog for
- %s %s %s
+ $catrel[0] $catrel[1] $catrel[2]
-since the last successful check on %s.
+since the last successful check on $date.
Please check the package(s) and re-upload if necessary.
Here is the output from chkcat:
-%s
+$stdout
-%s
-
Your Check Database Catalog script
"""
@@ -492,13 +496,16 @@
def _compose_mail(self, from_address):
"""Compose Mail"""
- msg = InformMaintainer.MAIL_CAT_BROKEN_HEADER
- for p in self._pkginfo:
- msg = msg + p['fullname'] + "\n"
- msg = msg + InformMaintainer.MAIL_CAT_BROKEN_FOOTER
+ namespace = {
+ 'pkg_data': self._pkginfo,
+ 'catrel': self._cat_tuple,
+ 'date': self._date,
+ 'stdout': self._chkcat_stdout
+ }
- mail = MIMEText(msg % (self._cat_tuple +
- (str(self._date), self._chkcat_stdout, self._chkcat_stderr)))
+ t = Template.Template(InformMaintainer.MAIL_TEMPLATE, searchList=[namespace])
+
+ mail = MIMEText(unicode(t))
mail['From'] = from_address
mail['To'] = self._addr
mail['Subject'] = "[chkdbcat] Database Catalog broken by recent upload"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list