]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
fix ResourceWarning: unclosed file INSTALL/KERNEL/bin/salome/VERSION gsa/backport97
authorGuillaume SUTRA <guillaume.sutra@cea.fr>
Tue, 31 Jan 2023 14:28:52 +0000 (15:28 +0100)
committerGuillaume SUTRA <guillaume.sutra@cea.fr>
Fri, 17 Feb 2023 13:53:24 +0000 (14:53 +0100)
src/Utils/Utils_Identity.py

index a3b119c7960a4551b79ba670d9b97f6c93d6689a..72f7d33b1bbe1a263cef59bf26a75df10d3a6ff6 100644 (file)
@@ -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"