Skip to content
Permalink
Browse files

[sextante] Added checking in case model file cannot be save due to pe…

…rmissions
  • Loading branch information
volaya committed Apr 30, 2013
1 parent bd5cdaf commit cc490fd7acd36614e11aad61d322c09b45e21d3c
Showing with 16 additions and 2 deletions.
  1. +16 −2 python/plugins/sextante/modeler/ModelerDialog.py
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
import sys

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -154,6 +155,7 @@ def runModel(self):
dlg.exec_()

def save(self):
if
self.saveModel(False)

def saveAs(self):
@@ -179,8 +181,20 @@ def saveModel(self, saveAs):
self.alg.descriptionFile = filename
if filename:
text = self.alg.serialize()
fout = codecs.open(filename, "w", encoding='utf-8')
#fout = open(filename, "w")
try:
fout = codecs.open(filename, "w", encoding='utf-8')
except:
if saveAs:
QMessageBox.warning(self,
self.tr("I/O error"),
self.tr("Unable to save edits. Reason:\n %1").arg(unicode(sys.exc_info()[1]))
)
else:
QMessageBox.warning(self,
self.tr("Can't save model"),
self.tr("This model can't be saved in its original location\n(probably you do not have permission to do it).\nPlease, use the 'Save as...' option.")
)
return
fout.write(text)
fout.close()
self.update = True

0 comments on commit cc490fd

Please sign in to comment.
You can’t perform that action at this time.