* [PATCH] build-many-glibcs: don't crash if email is not configured
@ 2017-02-16 22:08 Zack Weinberg
2017-02-16 22:20 ` Joseph Myers
0 siblings, 1 reply; 4+ messages in thread
From: Zack Weinberg @ 2017-02-16 22:08 UTC (permalink / raw)
To: libc-alpha; +Cc: joseph
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.
OK?
* 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.
---
scripts/build-many-glibcs.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index d2947e676b..4f724ced6f 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -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,
--
2.11.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] build-many-glibcs: don't crash if email is not configured
2017-02-16 22:08 [PATCH] build-many-glibcs: don't crash if email is not configured Zack Weinberg
@ 2017-02-16 22:20 ` Joseph Myers
2017-02-16 22:42 ` Zack Weinberg
0 siblings, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2017-02-16 22:20 UTC (permalink / raw)
To: Zack Weinberg; +Cc: libc-alpha
On Thu, 16 Feb 2017, Zack Weinberg wrote:
> 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.
>
> OK?
>
> * 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.
I'm not sure what self.email_warning is for, given it's only set to True
right before the script exits (so will always be False when tested). OK
without that variable.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] build-many-glibcs: don't crash if email is not configured
2017-02-16 22:20 ` Joseph Myers
@ 2017-02-16 22:42 ` Zack Weinberg
2017-02-16 23:09 ` Joseph Myers
0 siblings, 1 reply; 4+ messages in thread
From: Zack Weinberg @ 2017-02-16 22:42 UTC (permalink / raw)
To: Joseph Myers; +Cc: GNU C Library
On Thu, Feb 16, 2017 at 5:19 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Thu, 16 Feb 2017, Zack Weinberg wrote:
>
>> 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.
>>
>> OK?
>>
>> * 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.
>
> I'm not sure what self.email_warning is for, given it's only set to True
> right before the script exits (so will always be False when tested).
Not so; bot_build_mail is called at the end of each "action" in a cycle:
for a in actions:
if must_build[a]:
build_time = datetime.datetime.utcnow()
print('Rebuilding %s at %s.' % (a, str(build_time)))
self.bot_run_self([], a)
self.load_build_state_json()
self.bot_build_mail(a, build_time)
print('Bot cycle done at %s.' % str(datetime.datetime.utcnow()))
And it takes the "action" as an argument, so making it send mail only
once for the entire process would be a fair bit of surgery. Given
that, do you still want self.email_warning removed? It seems to me it
would be annoying to get the warning more than once per invocation.
zw
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] build-many-glibcs: don't crash if email is not configured
2017-02-16 22:42 ` Zack Weinberg
@ 2017-02-16 23:09 ` Joseph Myers
0 siblings, 0 replies; 4+ messages in thread
From: Joseph Myers @ 2017-02-16 23:09 UTC (permalink / raw)
To: Zack Weinberg; +Cc: GNU C Library
On Thu, 16 Feb 2017, Zack Weinberg wrote:
> Not so; bot_build_mail is called at the end of each "action" in a cycle:
>
> for a in actions:
> if must_build[a]:
> build_time = datetime.datetime.utcnow()
> print('Rebuilding %s at %s.' % (a, str(build_time)))
> self.bot_run_self([], a)
> self.load_build_state_json()
> self.bot_build_mail(a, build_time)
> print('Bot cycle done at %s.' % str(datetime.datetime.utcnow()))
>
> And it takes the "action" as an argument, so making it send mail only
> once for the entire process would be a fair bit of surgery. Given
> that, do you still want self.email_warning removed? It seems to me it
> would be annoying to get the warning more than once per invocation.
Thanks for the correction. The patch is OK as-is.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-16 23:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 22:08 [PATCH] build-many-glibcs: don't crash if email is not configured Zack Weinberg
2017-02-16 22:20 ` Joseph Myers
2017-02-16 22:42 ` Zack Weinberg
2017-02-16 23:09 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).