build-many-glibcs: don't crash if email is not configured
authorZack Weinberg <zackw@panix.com>
Thu, 16 Feb 2017 21:57:35 +0000 (16:57 -0500)
committerZack Weinberg <zackw@panix.com>
Fri, 17 Feb 2017 00:04:11 +0000 (19:04 -0500)
The 'bot-cycle' action for build-many-glibcs is a convenient way to
not have to remember all the steps in keeping a many-glibcs tree up
to date ... or it would be, if the script could send mail _optionally_.
Make it so by skipping the mail step if mail isn't configured.

* scripts/build-many-glibcs.py (bot_build_mail):  If the
bot_config does not contain all of the necessary email-
related settings, just print a warning and continue.

ChangeLog
scripts/build-many-glibcs.py

index 514753d9eca653c9eaf0050aa3385ebb46f06f35..17f9b165e3fc4e53af29fa06d4f99685b953b449 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-16  Zack Weinberg  <zackw@panix.com>
+
+       * scripts/build-many-glibcs.py (bot_build_mail): If the
+       bot_config does not contain all of the necessary email-
+       related settings, just print a warning and continue.
+
 2017-02-16  Zack Weinberg  <zackw@panix.com>
 
        * crypt/md5.h: Test _LIBC with #if defined, not #if.
index d2947e676b45647862cd4e9d033bfc00afe8d591..4f724ced6f0086a95a2bcd606d93e55641c48993 100755 (executable)
@@ -122,6 +122,7 @@ class Context(object):
         self.load_versions_json()
         self.load_build_state_json()
         self.status_log_list = []
+        self.email_warning = False
 
     def get_script_text(self):
         """Return the text of this script."""
@@ -1003,6 +1004,15 @@ class Context(object):
 
     def bot_build_mail(self, action, build_time):
         """Send email with the results of a build."""
+        if not ('email-from' in self.bot_config and
+                'email-server' in self.bot_config and
+                'email-subject' in self.bot_config and
+                'email-to' in self.bot_config):
+            if not self.email_warning:
+                print("Email not configured, not sending.")
+                self.email_warning = True
+            return
+
         build_time = build_time.replace(microsecond=0)
         subject = (self.bot_config['email-subject'] %
                    {'action': action,