From: jfa Date: Tue, 6 Dec 2022 16:00:18 +0000 (+0300) Subject: Avoid creation of tmp files in HOME X-Git-Tag: V9_11_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=656b91bf45b68a8702f5f87ca020580e5702eb61;p=modules%2Fgeom.git Avoid creation of tmp files in HOME --- diff --git a/src/GEOM_SWIG/PAL_MESH_028_geometry.py b/src/GEOM_SWIG/PAL_MESH_028_geometry.py index 3df3687e8..4ee3257f6 100644 --- a/src/GEOM_SWIG/PAL_MESH_028_geometry.py +++ b/src/GEOM_SWIG/PAL_MESH_028_geometry.py @@ -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()