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

index 596317dab64023aaad6a9d55f296e7e540c3536a..be8991e49b186ebd64b2b89d341f528445c01662 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 Exception:
   versnb = ""
   dirname=".salome"