diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2015-01-09 12:21:25 +0100 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2015-01-09 12:21:25 +0100 |
commit | 1d158e5e00566bc8dc87d721da9777252e817e04 (patch) | |
tree | 7ba59eb3e0a8e9c584ac7336e3273f64e0d62d72 /app/taskqueue/tasks.py | |
parent | a61910b832d7ee913fa336ac16e15dff4da1bb8e (diff) |
Send email report only if specified in the json.
Change-Id: Ic33eb9c1a80823650173f8a5acb01324084bb0d4
Diffstat (limited to 'app/taskqueue/tasks.py')
-rw-r--r-- | app/taskqueue/tasks.py | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/app/taskqueue/tasks.py b/app/taskqueue/tasks.py index 8179e20..c5f5cfb 100644 --- a/app/taskqueue/tasks.py +++ b/app/taskqueue/tasks.py @@ -123,32 +123,33 @@ def schedule_boot_report(json_obj, db_options, mail_options, countdown): j_get = json_obj.get to_addrs = [] - job = j_get(models.JOB_KEY) - kernel = j_get(models.KERNEL_KEY) - - boot_emails = j_get(models.BOOT_REPORT_SEND_TO_KEY, None) - generic_emails = j_get(models.REPORT_SEND_TO_KEY, None) - - if boot_emails is not None: - if isinstance(boot_emails, types.ListType): - to_addrs.extend(boot_emails) - elif isinstance(boot_emails, types.StringTypes): - to_addrs.append(boot_emails) - - if generic_emails is not None: - if isinstance(generic_emails, types.ListType): - to_addrs.extend(generic_emails) - elif isinstance(generic_emails, types.StringTypes): - to_addrs.append(generic_emails) - - if to_addrs: - send_boot_report.apply_async( - [job, kernel, to_addrs, db_options, mail_options], - countdown=countdown) - else: - utils.LOG.warn( - "No email addresses specified for '%s-%s': boot report " - "cannot be sent", job, kernel) + if bool(j_get(models.SEND_BOOT_REPORT_KEY, False)): + job = j_get(models.JOB_KEY) + kernel = j_get(models.KERNEL_KEY) + + boot_emails = j_get(models.BOOT_REPORT_SEND_TO_KEY, None) + generic_emails = j_get(models.REPORT_SEND_TO_KEY, None) + + if boot_emails is not None: + if isinstance(boot_emails, types.ListType): + to_addrs.extend(boot_emails) + elif isinstance(boot_emails, types.StringTypes): + to_addrs.append(boot_emails) + + if generic_emails is not None: + if isinstance(generic_emails, types.ListType): + to_addrs.extend(generic_emails) + elif isinstance(generic_emails, types.StringTypes): + to_addrs.append(generic_emails) + + if to_addrs: + send_boot_report.apply_async( + [job, kernel, to_addrs, db_options, mail_options], + countdown=countdown) + else: + utils.LOG.warn( + "No send email addresses specified for '%s-%s': boot report " + "cannot be sent", job, kernel) @taskc.app.task(name="send-boot-report") |