From c812e85f65c090a00d1ec0ad6340255deeb490cc Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 22 Jun 2016 11:51:15 -0400 Subject: [PATCH] Change email notification formatting. Instead of pretty printing the datastructure we'll now dump out the result in json format with indent=4 for pretty viewing. --- awx/main/notifications/base.py | 4 ++-- awx/main/notifications/email_backend.py | 4 ++-- awx/main/tasks.py | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/awx/main/notifications/base.py b/awx/main/notifications/base.py index 8129c33e27..a68c88ed46 100644 --- a/awx/main/notifications/base.py +++ b/awx/main/notifications/base.py @@ -1,7 +1,7 @@ # Copyright (c) 2016 Ansible, Inc. # All Rights Reserved. -import pprint +import json from django.utils.encoding import smart_text from django.core.mail.backends.base import BaseEmailBackend @@ -16,5 +16,5 @@ class TowerBaseEmailBackend(BaseEmailBackend): body['id'], body['status'], body['url'])) - body_actual += pprint.pformat(body, indent=4) + body_actual += json.dumps(body, indent=4) return body_actual diff --git a/awx/main/notifications/email_backend.py b/awx/main/notifications/email_backend.py index 0c5b6efa2d..7ca5690b28 100644 --- a/awx/main/notifications/email_backend.py +++ b/awx/main/notifications/email_backend.py @@ -1,7 +1,7 @@ # Copyright (c) 2016 Ansible, Inc. # All Rights Reserved. -import pprint +import json from django.utils.encoding import smart_text from django.core.mail.backends.smtp import EmailBackend @@ -27,5 +27,5 @@ class CustomEmailBackend(EmailBackend): body['id'], body['status'], body['url'])) - body_actual += pprint.pformat(body, indent=4) + body_actual += json.dumps(body, indent=4) return body_actual diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 37e2ed6560..558e99291a 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -269,7 +269,8 @@ def handle_work_error(self, task_id, subtasks=None): friendly_name = "System Job" else: # Unknown task type - break + logger.warn("Unknown task type: {}".format(each_task['type'])) + continue if first_task is None: first_task = instance first_task_id = instance.id