Skip to content
Permalink
Browse files

[pyqgis-console] some fix for run script and restore tabs

  • Loading branch information
slarosa committed Apr 16, 2013
1 parent 708a99c commit 2c1f7e3e15c2918f3751b349f5c2afdc566f3b72
Showing with 11 additions and 10 deletions.
  1. +1 −3 python/console/console.py
  2. +10 −7 python/console/console_editor.py
@@ -421,9 +421,6 @@ def saveScriptFile(self):
QMessageBox.warning(self, "Save Error",
"Failed to save %s: %s" % (tabWidget.path, e))

self.tabListScript.append(tabWidget.path)
self.updateTabListScript(script=None)

def saveAsScriptFile(self):
tabWidget = self.tabEditorWidget.currentWidget()
if tabWidget is None:
@@ -432,6 +429,7 @@ def saveAsScriptFile(self):
"Save File As",
tabWidget.path, "Script file (*.py)")
if not filename.isEmpty():
self.tabListScript.remove(tabWidget.path)
tabWidget.path = filename
self.saveScriptFile()

@@ -349,14 +349,17 @@ def runScriptCode(self):
else:
try:
p = subprocess.Popen(['python', filename], shell=False, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
output = p.stderr.read()

if output:
traceback = p.stderr.read()
out = p.stdout.read()
if traceback:
print "## %s" % datetime.datetime.now()
print "## Script error: %s" % name
sys.stderr.write(output)
sys.stderr.write(traceback)
else:
print "## %s" % datetime.datetime.now()
print "## Script executed successfully: %s" % name
sys.stdout.write(out)
del p

#execfile(unicode(filename))
except IOError, error:
print 'Cannot execute file %s. Error: %s' % (filename, error.strerror)
@@ -434,7 +437,6 @@ def save(self):
return
msgText = QCoreApplication.translate('PythonConsole',
'Script was correctly saved.')
self.pc.updateTabListScript(self.path, action='append')
self.pc.callWidgetMessageBarEditor(msgText)
# Rename the original file, if it exists
overwrite = os.path.exists(self.path)
@@ -451,7 +453,8 @@ def save(self):
fN = self.path.split('/')[-1]
self.mw.setTabTitle(self, fN)
self.newEditor.setModified(False)

self.pc.updateTabListScript(self.path, action='append')

def changeFont(self):
self.newEditor.refreshLexerProperties()

0 comments on commit 2c1f7e3

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