[SCM] live-studio branch, master, updated. 7c824ca82f58ad0a21bce6bea2f1675d859cec1a

Chris Lamb lamby at debian.org
Sat Jul 31 01:02:05 UTC 2010


The following commit has been merged in the master branch:
commit 7c824ca82f58ad0a21bce6bea2f1675d859cec1a
Author: Chris Lamb <lamby at debian.org>
Date:   Fri Jul 30 21:00:30 2010 -0400

    Send emails when build completes

diff --git a/live_studio/build/management/commands/queue_runner.py b/live_studio/build/management/commands/queue_runner.py
index 2075216..b9b05d2 100644
--- a/live_studio/build/management/commands/queue_runner.py
+++ b/live_studio/build/management/commands/queue_runner.py
@@ -8,7 +8,10 @@ import tempfile
 import subprocess
 
 from django.conf import settings
+from django.core.mail import send_mail
+from django.template.loader import render_to_string
 from django.core.management.base import NoArgsCommand, make_option
+from django.contrib.sites.models import Site
 
 from live_studio.build.models import Build
 from live_studio.templatetags.text import command_line_options
@@ -91,6 +94,8 @@ class Command(NoArgsCommand):
 
                 self.log.info("Building #%d in %s", build.pk, tempdir)
 
+                status = 'failure'
+
                 try:
                     os.chdir(tempdir)
 
@@ -124,6 +129,8 @@ class Command(NoArgsCommand):
                         filename=filename,
                     )
 
+                    status = 'success'
+
                     self.log.info("#%d built successfully", build.pk)
                 except:
                     self.log.exception("#%d failed", build.pk)
@@ -134,6 +141,23 @@ class Command(NoArgsCommand):
                     call(logfile, ('lh', 'clean', '--purge'))
                     shutil.rmtree(tempdir)
 
+                    ec = {
+                        'site': Site.objects.get_current(),
+                        'build': build,
+                    }
+
+                    subject = render_to_string(
+                        'builds/%s_subject.txt' % status,
+                        ec,
+                    )
+
+                    send_mail(
+                        ''.join(subject.splitlines()),
+                        render_to_string('builds/%s_body.txt' % status, ec),
+                        settings.DEFAULT_FROM_EMAIL,
+                        (build.config.user.email,),
+                    )
+
                     self.log.info("Finished processing #%d", build.pk)
 
             except IndexError:
diff --git a/templates/builds/failure_body.txt b/templates/builds/failure_body.txt
new file mode 100644
index 0000000..f0b757b
--- /dev/null
+++ b/templates/builds/failure_body.txt
@@ -0,0 +1,12 @@
+
+Hi,
+
+Your Debian Live Studio build FAILED to build successfully.
+
+You can view the build log here:
+
+ http://{{ site.domain }}{{ build.log_url }}
+
+Alternatively, you can adjust and rebuild your configuration:
+
+ http://{{ site.domain }}{{ build.config.get_absolute_url }}
diff --git a/templates/builds/failure_subject.txt b/templates/builds/failure_subject.txt
new file mode 100644
index 0000000..8074f82
--- /dev/null
+++ b/templates/builds/failure_subject.txt
@@ -0,0 +1 @@
+Your Debian Live Studio build FAILED
diff --git a/templates/builds/success_body.txt b/templates/builds/success_body.txt
new file mode 100644
index 0000000..da4447f
--- /dev/null
+++ b/templates/builds/success_body.txt
@@ -0,0 +1,15 @@
+
+Hi,
+
+Your Debian Live Studio build completed successfully. You may
+download it here:
+
+ http://{{ site.domain }}{{ build.result_url }}
+
+You can also view the build log:
+
+ http://{{ site.domain }}{{ build.log_url }}
+
+Alternatively, you can adjust and rebuild your configuration:
+
+ http://{{ site.domain }}{{ build.config.get_absolute_url }}
diff --git a/templates/builds/success_subject.txt b/templates/builds/success_subject.txt
new file mode 100644
index 0000000..d8133fa
--- /dev/null
+++ b/templates/builds/success_subject.txt
@@ -0,0 +1 @@
+Your Debian Live Studio build completed successfully

-- 
live-studio



More information about the debian-live-changes mailing list