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=ec0be347e6deea20381437ff0ffeec15acc6ddc2;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 596317dab..be8991e49 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 Exception: versnb = "" dirname=".salome"