[Checkins] SVN: zope.repositorypolicy/trunk/s Snapshot: merge Jens' summary mail into the main mail script.
Christian Theune
ct at gocept.com
Mon Mar 29 03:22:32 EDT 2010
Log message for revision 110277:
Snapshot: merge Jens' summary mail into the main mail script.
Changed:
U zope.repositorypolicy/trunk/setup.py
U zope.repositorypolicy/trunk/src/zope/repositorypolicy/repository.py
-=-
Modified: zope.repositorypolicy/trunk/setup.py
===================================================================
--- zope.repositorypolicy/trunk/setup.py 2010-03-29 01:44:59 UTC (rev 110276)
+++ zope.repositorypolicy/trunk/setup.py 2010-03-29 07:22:31 UTC (rev 110277)
@@ -23,7 +23,6 @@
[console_scripts]
zope-org-check-repos = zope.repositorypolicy.repository:main
zope-org-check-repos-mail = zope.repositorypolicy.repository:main_mail
- zope-org-check-repos-summarymail = zope.repositorypolicy.repository:main_summarymail
zope-org-check-project = zope.repositorypolicy.project:main
zope-org-fix-project = zope.repositorypolicy.copyright:main
""")
Modified: zope.repositorypolicy/trunk/src/zope/repositorypolicy/repository.py
===================================================================
--- zope.repositorypolicy/trunk/src/zope/repositorypolicy/repository.py 2010-03-29 01:44:59 UTC (rev 110276)
+++ zope.repositorypolicy/trunk/src/zope/repositorypolicy/repository.py 2010-03-29 07:22:31 UTC (rev 110277)
@@ -34,7 +34,7 @@
checker = zope.repositorypolicy.project.Checker(working_dir)
checker.run()
for entry in checker.log:
- yield '%s/%s:%s' % (project, branch, entry)
+ yield (project, branch, entry)
finally:
shutil.rmtree(working_dir)
@@ -67,68 +67,59 @@
print entry
sys.exit(result)
+MAIL_TEMPLATE = """\
+The packages and branches listed below have failed one or
+more repository policy checks. To see more detailed output,
+use the "zope.repositorypolicy" package and run its script
+"zope-org-check-project" against a checkout of the branch
+in question.
-def main_mail():
- smtp_host, sender_address, target_address, httpbase, logbase = sys.argv[1:]
+The full log of errors can be found here: %(log_url)s
- stamp = datetime.datetime.now().isoformat()
- logname = 'report-%s.txt' % stamp
- log = open(os.path.join(logbase, logname), 'w')
+Summary
+-------
- checker = Checker()
- errors = 0
- for entry in checker.run():
- errors += 1
- log.write(entry+'\n')
- log.close()
+%(project_branches)s
- if errors:
- subject = 'FAILURE: Repository policy check found %s errors' % errors
- else:
- subject = 'OK: Repository policy check found no errors'
+--\x20
+This message was generated automatically.
+"""
- body = ('The log can be found at %s/%s\r\n\r\n-- \r\n'
- 'This message was generated automatically.' % (httpbase, logname))
- mailserver = smtplib.SMTP(smtp_host)
- msg = ('From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s' %
- (sender_address, target_address, subject, body))
- mailserver.sendmail(sender_address, [target_address], msg)
- mailserver.quit()
+def main_mail():
+ smtp_host, sender_address, target_address, httpbase, logbase = sys.argv[1:]
-SUMMARY_TEMPLATE = """\
-The packages and branches listed below have failed one or
-more repository policy checks. To see more detailed output,
-use the "zope.repositorypolicy" package and run its script
-"zope-org-check-project" against a checkout of the branch
-in question.
-
-%s
-
-"""
-
-def main_summarymail():
- smtp_host, sender_address, target_address = sys.argv[1:]
stamp = datetime.datetime.now().isoformat()
- branches = set([])
+ logname = 'report-%s.txt' % stamp
+ log = open(os.path.join(logbase, logname), 'w')
+ projects = {}
+
checker = Checker()
- for entry in checker.run():
- branches.add(entry.split(':')[0])
+ for project, branch, error in checker.run():
+ projects.setdefault(project, [])
+ projects[project].append(branch)
+ log.write('%s/%s:%s\n' % (project, branch, error))
+ log.close()
- if branches:
- subject = 'FAILURE: Repository policy check failed on %i branches' % len(branches)
+ if projects:
+ subject = ('FAILURE: Repository policy check found'
+ 'errors in %s projects' % len(projects))
else:
subject = 'OK: Repository policy check found no errors'
- branches = list(branches)
- branches.sort()
+ mail['log_url'] = httpbase + '/' + logname
+ mail['project_branches'] = ''
+ for project in sorted(projects):
+ mail['project_branches'] += (
+ project + '\n' +
+ ('\t%s\n' % for x in projects[project]) +
+ '\n')
- body = SUMMARY_TEMPLATE % '\n'.join(branches)
+ body = MAIL_TEMPLATE % mail
mailserver = smtplib.SMTP(smtp_host)
msg = ('From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s' %
(sender_address, target_address, subject, body))
mailserver.sendmail(sender_address, [target_address], msg)
mailserver.quit()
-
More information about the checkins
mailing list