Skip to content

Commit

Permalink
[sextante] Added checking in case model file cannot be save due to pe…
Browse files Browse the repository at this point in the history
…rmissions
  • Loading branch information
volaya committed Apr 30, 2013
1 parent bd5cdaf commit cc490fd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions python/plugins/sextante/modeler/ModelerDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
import sys

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

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

def saveAs(self):
Expand All @@ -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
Expand Down

0 comments on commit cc490fd

Please sign in to comment.