From 3ed3a5f43aeba8d7cbad11e93ef76a66678450d5 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 26 Jan 2016 14:52:41 -0500 Subject: [PATCH] Make retry file generation not use StringIO --- lib/ansible/executor/playbook_executor.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py index 42dca10c06..d109b5296a 100644 --- a/lib/ansible/executor/playbook_executor.py +++ b/lib/ansible/executor/playbook_executor.py @@ -19,7 +19,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import StringIO import getpass import locale import os @@ -256,14 +255,10 @@ class PlaybookExecutor: information in group_vars/host_vars but that is ok, and expected. ''' - buf = StringIO.StringIO() - for x in replay_hosts: - buf.write("%s\n" % x) - try: - fd = open(retry_path, 'w') - fd.write(buf.getvalue()) - fd.close() + with open(retry_path, 'w') as fd: + for x in replay_hosts: + fd.write("%s\n" % x) except Exception as e: display.error("Could not create retry file '%s'. The error was: %s" % (retry_path, e)) return False