Skip to content

Commit

Permalink
[pyqgis-console] some fix for run script and restore tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Apr 16, 2013
1 parent 708a99c commit 2c1f7e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 1 addition & 3 deletions python/console/console.py
Expand Up @@ -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:
Expand All @@ -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()

Expand Down
17 changes: 10 additions & 7 deletions python/console/console_editor.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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()

Expand Down

0 comments on commit 2c1f7e3

Please sign in to comment.