Avoid creation of tmp files in HOME

This commit is contained in:
jfa 2022-12-06 19:00:18 +03:00
parent 7c90108313
commit 656b91bf45

View 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)
else:
# 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:
print("ERROR: Failed to save study in HDF file: ",theFilenameToSave)
salome.sg.updateObjBrowser()