From: Guillaume SUTRA Date: Tue, 31 Jan 2023 14:28:52 +0000 (+0100) Subject: fix ResourceWarning: unclosed file INSTALL/KERNEL/bin/salome/VERSION X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fgsa%2Fbackport97;p=modules%2Fkernel.git fix ResourceWarning: unclosed file INSTALL/KERNEL/bin/salome/VERSION --- diff --git a/src/Utils/Utils_Identity.py b/src/Utils/Utils_Identity.py index a3b119c79..72f7d33b1 100644 --- a/src/Utils/Utils_Identity.py +++ b/src/Utils/Utils_Identity.py @@ -77,11 +77,10 @@ def getapplipath(): return os.environ.get("APPLI",".salome_"+versnb) try: - file = open(os.path.join(os.environ["KERNEL_ROOT_DIR"],"bin","salome","VERSION"), "r") - s = file.readline() + with open(os.path.join(os.environ["KERNEL_ROOT_DIR"],"bin","salome","VERSION"), "r") as file: + s = file.readline() versnb = string.strip(string.split(s, ":")[1]) dirname=".salome_"+versnb - file.close() except: versnb = "" dirname=".salome"