mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Close all open filehandle (#50544)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
94a1d86d70
commit
db8702cdb8
21 changed files with 81 additions and 47 deletions
|
@ -623,7 +623,8 @@ def main():
|
|||
stack_params['StackName'] = module.params['stack_name']
|
||||
|
||||
if module.params['template'] is not None:
|
||||
stack_params['TemplateBody'] = open(module.params['template'], 'r').read()
|
||||
with open(module.params['template'], 'r') as template_fh:
|
||||
stack_params['TemplateBody'] = template_fh.read()
|
||||
elif module.params['template_body'] is not None:
|
||||
stack_params['TemplateBody'] = module.params['template_body']
|
||||
elif module.params['template_url'] is not None:
|
||||
|
@ -636,7 +637,8 @@ def main():
|
|||
|
||||
# can't check the policy when verifying.
|
||||
if module.params['stack_policy'] is not None and not module.check_mode and not module.params['create_changeset']:
|
||||
stack_params['StackPolicyBody'] = open(module.params['stack_policy'], 'r').read()
|
||||
with open(module.params['stack_policy'], 'r') as stack_policy_fh:
|
||||
stack_params['StackPolicyBody'] = stack_policy_fh.read()
|
||||
|
||||
template_parameters = module.params['template_parameters']
|
||||
|
||||
|
|
|
@ -218,11 +218,14 @@ def cert_action(module, iam, name, cpath, new_name, new_path, state,
|
|||
def load_data(cert, key, cert_chain):
|
||||
# if paths are provided rather than lookups read the files and return the contents
|
||||
if cert and os.path.isfile(cert):
|
||||
cert = open(cert, 'r').read().rstrip()
|
||||
with open(cert, 'r') as cert_fh:
|
||||
cert = cert_fh.read().rstrip()
|
||||
if key and os.path.isfile(key):
|
||||
key = open(key, 'r').read().rstrip()
|
||||
with open(key, 'r') as key_fh:
|
||||
key = key_fh.read().rstrip()
|
||||
if cert_chain and os.path.isfile(cert_chain):
|
||||
cert_chain = open(cert_chain, 'r').read()
|
||||
with open(cert_chain, 'r') as cert_chain_fh:
|
||||
cert_chain = cert_chain_fh.read()
|
||||
return cert, key, cert_chain
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue