From 8397c5defc2d2e708c1857dfa9b57e1a67bcddfe Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 22 Apr 2021 13:55:10 -0400 Subject: [PATCH] Only close datfile if datfile is a file If going by filename alone, there will be no file handle to close. Correct by not attempting a close in such a case. --- confluent_server/confluent/plugins/hardwaremanagement/ipmi.py | 3 ++- .../confluent/plugins/hardwaremanagement/redfish.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index f9b73f29..3a1706b2 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -1539,7 +1539,8 @@ class IpmiHandler(object): try: self.ipmicmd.apply_license(filename, data=datfile) finally: - datfile.close() + if datfile is not None: + datfile.close() if len(self.element) == 3: self.output.put(msg.ChildCollection('all')) i = 1 diff --git a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py index 20fde9da..53cddfc5 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py @@ -1384,7 +1384,8 @@ class IpmiHandler(object): try: self.ipmicmd.apply_license(filename, data=datfile) finally: - datfile.close() + if datfile is not None: + datfile.close() if len(self.element) == 3: self.output.put(msg.ChildCollection('all')) i = 1