From e64de2ff887a2fc330f34dc5a77dab0a81c9a872 Mon Sep 17 00:00:00 2001 From: Gregory Duchatelet Date: Mon, 17 Dec 2012 13:46:50 +0100 Subject: [PATCH 1/2] Bugfix: in hosts with python-2.5, hash keys needs flatten string. --- library/async_status | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/async_status b/library/async_status index ef5dbe06e0..e249fdeb8b 100644 --- a/library/async_status +++ b/library/async_status @@ -49,6 +49,7 @@ author: Michael DeHaan import datetime import traceback +import sys def main(): @@ -89,6 +90,13 @@ def main(): if not 'started' in data: data['finished'] = 1 data['ansible_job_id'] = jid + + # Fix error: TypeError: exit_json() keywords must be strings + if sys.version_info[0] == 2 and sys.version_info[1] < 6: + for k in data.keys(): + v = data[k] + del data[k] + data[str(k)] = v module.exit_json(**data) # this is magic, see lib/ansible/module_common.py From 29f985aa2e5e20636538bfa284dabc7aaecc5d99 Mon Sep 17 00:00:00 2001 From: Gregory Duchatelet Date: Mon, 17 Dec 2012 21:07:36 +0100 Subject: [PATCH 2/2] do not conditionalize this for older Python, fix indentation, better use of hash iteration. --- library/async_status | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/library/async_status b/library/async_status index e249fdeb8b..d24d6f3383 100644 --- a/library/async_status +++ b/library/async_status @@ -49,7 +49,6 @@ author: Michael DeHaan import datetime import traceback -import sys def main(): @@ -90,13 +89,10 @@ def main(): if not 'started' in data: data['finished'] = 1 data['ansible_job_id'] = jid - - # Fix error: TypeError: exit_json() keywords must be strings - if sys.version_info[0] == 2 and sys.version_info[1] < 6: - for k in data.keys(): - v = data[k] - del data[k] - data[str(k)] = v + + # Fix error: TypeError: exit_json() keywords must be strings + data = dict([(str(k), v) for k, v in data.iteritems()]) + module.exit_json(**data) # this is magic, see lib/ansible/module_common.py