]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Avoid creation of tmp files in HOME
authorjfa <jfa@opencascade.com>
Tue, 6 Dec 2022 16:00:18 +0000 (19:00 +0300)
committerjfa <jfa@opencascade.com>
Tue, 6 Dec 2022 16:00:18 +0000 (19:00 +0300)
src/GEOM_SWIG/PAL_MESH_028_geometry.py

index 3df3687e8b850aa1e2deb324141f59db8e27828f..4ee3257f6af329a5c2993abd199acc24b900e475 100644 (file)
@@ -76,15 +76,25 @@ geompy.addToStudy(Prism_1, "Prism_1")
 
 #Save Study (9.1)
 theHomePath = os.path.expanduser("~")
+
+# Remove study file if it already exists
 theFilenameToSave = theHomePath + "/Pyramid.hdf"
 if os.access(theFilenameToSave, os.F_OK):
     if os.access(theFilenameToSave, os.W_OK):
         os.remove(theFilenameToSave)
-        salome.myStudy.SaveAs(theFilenameToSave, 0, 0)
     else:
         print("You have no enough permissions to overwrite HDF file: ",theFilenameToSave)
+
+# Save study
+salome.myStudy.SaveAs(theFilenameToSave, 0, 0)
+
+# Check and remove result file
+if os.access(theFilenameToSave, os.F_OK):
+    if os.access(theFilenameToSave, os.W_OK):
+        os.remove(theFilenameToSave)
+    else:
+        print("You have no enough permissions to delete HDF file: ",theFilenameToSave)
 else:
-    salome.myStudy.SaveAs(theFilenameToSave, 0, 0)
-    
+    print("ERROR: Failed to save study in HDF file: ",theFilenameToSave)
 
 salome.sg.updateObjBrowser()