I am having problems with deleting files on disk after using "processing.runalg()" in a plugin I created when running it in windows. I have no problem in linux.
I found an issue regarding the same topic at https://hub.qgis.org/issues/12502, and was wondering if the issue in had been fixed in qgis 2.18.
The code is simple as follows, where outName is the path to the output chosen by the user, and tarNames is a list of file names to be processed:
import processing import sys, gdal_merge as gm rlayer = QgsRasterLayer(os.path.join(out,inputName), "input") args = ['-of', "GTiff", '-n', "0", '-a_nodata', "0", '-separate', '-ot', "UInt32",'-o', out+"/"+tmpName] args.extend([out+"/"+t for t in tarNames]) sys.argv = args gm.main() processing.runalg("gdalogr:warpreproject", {"INPUT":os.path.join(out,tmpName), "SOURCE_SRS":"EPSG:"+str(rlayer.crs().postgisSrid()), "DEST_SRS":"EPSG:32724", "NO_DATA":0, "METHOD":0, "RTYPE":3, "OUTPUT":os.path.join(out,outName)}) os.remove(os.path.join(out,tmpName)) os.remove fails, saying that the file is not available. As I mentioned, I don't have this issue in linux.
I tried to implement the workaround proposed in Releasing PyQGIS file locks?, but it does not solve the problem.
The only solution I have for the moment is to create a bunch of temp files with unique names and have the user delete them by hand... less than optimal. The temp file is created on disk by gdal_merge.py, I did not find an option to create it in memory. If anybody has a solution for that, I am very interested. I understand this is a separate question, and I am happy to post it if there is a solution.