My plugin does some basic geoprocessing functionalities and write the output as csv file. What i want is when i open some already writed output csv file in a writable mode and try to replace the same csv file for the newoutput, i got an error which is attached below. Code is also attached for reference.
def writeToFile(self, lsOfCities, filePath):
fileCSV = open(filePath, "w")
for i in lsOfCities:
fileCSV.write(i)
fileCSV.write(",")
fileCSV.write("\n")
QMessageBox.information(self.dlg, "Number of Cities Near", str(len(lsOfCities)) + " cities are written to "+filePath)
fileCSV.close()
self.dlg.close()
I want my plugin to show a warning message instead of below error.