summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMads Jensen <mads.jensen@eficode.com>2019-12-21 13:01:38 +0100
committerFelix Fontein <felix@fontein.de>2019-12-21 13:01:38 +0100
commita0e6bf366e107915a256e8f79c0a15ad7f2be228 (patch)
tree703b9ced4f2a9e8994f37d97ac5eaa9b550d9a0c /contrib
parentb580f2929dd9048e0d2752463b62994d1114ae1b (diff)
downloadansible-a0e6bf366e107915a256e8f79c0a15ad7f2be228.tar.gz
Use context manager for file handling in misc files. (#65372)
The file handles are left open in those files.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/inventory/spacewalk.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/inventory/spacewalk.py b/contrib/inventory/spacewalk.py
index e94298c308..dc96b1fe3b 100755
--- a/contrib/inventory/spacewalk.py
+++ b/contrib/inventory/spacewalk.py
@@ -89,7 +89,8 @@ def spacewalk_report(name):
p.wait()
fh.close()
- lines = open(cache_filename, 'r').readlines()
+ with open(cache_filename, 'r') as f:
+ lines = f.readlines()
keys = lines[0].strip().split(',')
# add 'spacewalk_' prefix to the keys
keys = ['spacewalk_' + key for key in keys]