From 50d8adcfee55804d3102209281c2d50a771df11c Mon Sep 17 00:00:00 2001 From: easyw Date: Sat, 14 Dec 2019 22:45:56 +0100 Subject: [PATCH] creating the temp .stp file in a temporary dir --- src/Mod/Import/stepZ.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Mod/Import/stepZ.py b/src/Mod/Import/stepZ.py index 3236d035fa..29a8916976 100644 --- a/src/Mod/Import/stepZ.py +++ b/src/Mod/Import/stepZ.py @@ -152,32 +152,36 @@ def export(objs,filename): namefpath = os.path.join(basepath,fname) outfpath = os.path.join(basepath,fname)+u'.stpZ' + outfpathT = os.path.join(tempdir,fname)+u'.stpZ' outfpath_stp = os.path.join(basepath,fname)+u'.stp' + outfpathT_stp = os.path.join(tempdir,fname)+u'.stp' + outfpath_base = basepath #outfpath_str = mkz_string(os.path.join(basepath,fname)) outfpath_str = os.path.join(basepath,fname)+u'.stp' + outfpathT_str = os.path.join(tempdir,fname)+u'.stp' - if os.path.exists(outfpath_stp): - sayzw("File cannot be compressed because a file with the same name exists '"+ outfpath_stp +"'") + if os.path.exists(outfpathT_stp): + sayzw("File cannot be compressed because a file with the same name exists '"+ outfpathT_stp +"'") QtGui.QApplication.restoreOverrideCursor() reply = QtGui.QMessageBox.information(None,"info", "File cannot be compressed because\na file with the same name exists\n'"+ outfpath_stp + "'") else: - ImportGui.export(objs,outfpath_stp) - with builtin.open(outfpath_stp, 'rb') as f_in: + ImportGui.export(objs,outfpathT_stp) + with builtin.open(outfpathT_stp, 'rb') as f_in: file_content = f_in.read() new_f_content = file_content f_in.close() - with gz.open(outfpath_str, 'wb') as f_out: + with gz.open(outfpathT_str, 'wb') as f_out: f_out.write(new_f_content) f_out.close() if os.path.exists(outfpath): os.remove(outfpath) - os.rename(outfpath_str, outfpath) - #os.remove(outfpath_stp) + os.rename(outfpathT_str, outfpath) + #os.remove(outfpathT_stp) else: - os.rename(outfpath_str, outfpath) - #os.remove(outfpath_stp) + os.rename(outfpathT_str, outfpath) + #os.remove(outfpathT_stp) ####