[Pkg-debile-commits] [debile-master] 71/126: add emails
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:56:17 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch scan-build-html
in repository debile-master.
commit 397a0e4bb66cb675ddfe95be88e8b5e540410ebc
Author: Paul Tagliamonte <tag at pault.ag>
Date: Sun Jun 9 01:07:45 2013 -0400
add emails
---
lucy/mail.py | 17 +++++++++++------
lucy/server.py | 24 +++++++++++++++++++++++-
lucy/templates/mails/failed | 4 +---
3 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/lucy/mail.py b/lucy/mail.py
index 1353081..902d178 100644
--- a/lucy/mail.py
+++ b/lucy/mail.py
@@ -1,13 +1,18 @@
from email.mime.text import MIMEText
+from email.parser import Parser
+from jinja2 import Template
+from io import StringIO
import smtplib
+import os
-def send_mail(subject, to, text):
- msg = MIMEText(text)
- msg['Subject'] = subject
- msg['From'] = "lucy at localhost" # Meh
- msg['To'] = to
+TEMPLATE_ROOT = os.path.join(os.path.dirname(__file__), "templates/mails")
+
+def send_mail(template, **context):
+ path = Template(open("%s/%s" % (TEMPLATE_ROOT, template)).read())
+ buf = StringIO(path.render(**context))
+ email = Parser().parse(buf)
s = smtplib.SMTP('localhost')
- s.send_message(msg)
+ s.send_message(email)
s.quit()
diff --git a/lucy/server.py b/lucy/server.py
index 17df4ff..1be93d8 100644
--- a/lucy/server.py
+++ b/lucy/server.py
@@ -1,6 +1,7 @@
from lucy import Machine, Job, Source, Binary, Report
from lucy.archive import uuid_to_path
from lucy.core import get_config
+from lucy.mail import send_mail
from xmlrpc.server import SimpleXMLRPCServer
from xmlrpc.server import SimpleXMLRPCRequestHandler
@@ -16,6 +17,22 @@ NAMESPACE = threading.local()
config = get_config()
+def send_failed_email(job, package, report):
+ source = package
+ if package._type == 'binaries':
+ source = package.get_source()
+ uploader = source.get_owner()
+
+ send_mail(
+ 'failed',
+ uploader=uploader,
+ package=package,
+ job=job,
+ report=report,
+ source=source
+ )
+
+
class LucyInterface(object):
def get_source_package(self, package):
@@ -128,7 +145,12 @@ class LucyInterface(object):
os.makedirs(path)
report['log_path'] = os.path.join(uuid_path, 'log')
- return report.save()
+ rid = report.save()
+
+ if failed:
+ send_failed_email(job, package, report)
+
+ return rid
def close_job(self, job):
"""
diff --git a/lucy/templates/mails/failed b/lucy/templates/mails/failed
index bca87b9..b1879a5 100644
--- a/lucy/templates/mails/failed
+++ b/lucy/templates/mails/failed
@@ -1,9 +1,7 @@
To: {{uploader.email}}
+From: lucy at debuild.me
CC: paultag at debian.org
Subject: FAILED: {{job.type}}: {{source.source}}/{{source.version}}
-X-Lucy-Job: {{job._id}}
-X-Lucy-Package: {{package._id}}
-X-Lucy-Report: {{report._id}}
Hello, {{uploader.name}},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git
More information about the Pkg-debile-commits
mailing list