From 37ae2435878b7dd76b812328878be620a93a30c9 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 10 Nov 2015 13:22:08 -0800 Subject: [PATCH] made get_file_lines rely on get_file_content which deals with many error conditions that the former did not. --- lib/ansible/module_utils/facts.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index d7105b5a87e..4120a51fb5b 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -2982,12 +2982,13 @@ def get_file_content(path, default=None, strip=True): return data def get_file_lines(path): - '''file.readlines() that closes the file''' - datafile = open(path) - try: - return datafile.readlines() - finally: - datafile.close() + '''get list of lines from file''' + data = get_file_content(path) + if data: + ret = data.splitlines() + else: + ret = [] + return ret def ansible_facts(module): facts = {}