mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Close all open filehandle (#50544)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
committed by
Brian Coca
parent
94a1d86d70
commit
db8702cdb8
@@ -231,7 +231,9 @@ class ACIModule(object):
|
||||
self.params['certificate_name'] = os.path.basename(os.path.splitext(self.params['private_key'])[0])
|
||||
|
||||
try:
|
||||
sig_key = load_privatekey(FILETYPE_PEM, open(self.params['private_key'], 'r').read())
|
||||
with open(self.params['private_key'], 'r') as priv_key_fh:
|
||||
private_key_content = priv_key_fh.read()
|
||||
sig_key = load_privatekey(FILETYPE_PEM, private_key_content)
|
||||
except Exception:
|
||||
self.module.fail_json(msg='Cannot load private key %s' % self.params['private_key'])
|
||||
|
||||
|
||||
@@ -203,7 +203,8 @@ class NetworkConfig(object):
|
||||
self._items = self.parse(s)
|
||||
|
||||
def loadfp(self, fp):
|
||||
return self.load(open(fp).read())
|
||||
with open(fp) as f:
|
||||
return self.load(f.read())
|
||||
|
||||
def parse(self, lines, comment_tokens=None):
|
||||
toplevel = re.compile(r'\S')
|
||||
|
||||
Reference in New Issue
Block a user