console fixes
- add fileno method since console occludes sys.stdout - fix editor spawning - don't store sys.stdout, since this is not guaranteed to be the real stdout
This commit is contained in:
parent
ac417a6567
commit
6f69b11c26
@ -109,8 +109,10 @@ class ConsoleWidget(QtGui.QWidget):
|
|||||||
pickle.dump(pf, history)
|
pickle.dump(pf, history)
|
||||||
|
|
||||||
def runCmd(self, cmd):
|
def runCmd(self, cmd):
|
||||||
self.stdout = sys.stdout
|
#cmd = str(self.input.lastCmd)
|
||||||
self.stderr = sys.stderr
|
|
||||||
|
orig_stdout = sys.stdout
|
||||||
|
orig_stderr = sys.stderr
|
||||||
encCmd = re.sub(r'>', '>', re.sub(r'<', '<', cmd))
|
encCmd = re.sub(r'>', '>', re.sub(r'<', '<', cmd))
|
||||||
encCmd = re.sub(r' ', ' ', encCmd)
|
encCmd = re.sub(r' ', ' ', encCmd)
|
||||||
|
|
||||||
@ -132,8 +134,8 @@ class ConsoleWidget(QtGui.QWidget):
|
|||||||
self.write("</div>\n", html=True, scrollToBottom=True)
|
self.write("</div>\n", html=True, scrollToBottom=True)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
sys.stdout = self.stdout
|
sys.stdout = orig_stdout
|
||||||
sys.stderr = self.stderr
|
sys.stderr = orig_stderr
|
||||||
|
|
||||||
sb = self.ui.historyList.verticalScrollBar()
|
sb = self.ui.historyList.verticalScrollBar()
|
||||||
sb.setValue(sb.maximum())
|
sb.setValue(sb.maximum())
|
||||||
@ -178,7 +180,6 @@ class ConsoleWidget(QtGui.QWidget):
|
|||||||
self.displayException()
|
self.displayException()
|
||||||
|
|
||||||
def execMulti(self, nextLine):
|
def execMulti(self, nextLine):
|
||||||
#self.stdout.write(nextLine+"\n")
|
|
||||||
if nextLine.strip() != '':
|
if nextLine.strip() != '':
|
||||||
self.multiline += "\n" + nextLine
|
self.multiline += "\n" + nextLine
|
||||||
return
|
return
|
||||||
@ -214,7 +215,7 @@ class ConsoleWidget(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread()
|
isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread()
|
||||||
if not isGuiThread:
|
if not isGuiThread:
|
||||||
self.stdout.write(strn)
|
sys.__stdout__.write(strn)
|
||||||
return
|
return
|
||||||
|
|
||||||
sb = self.output.verticalScrollBar()
|
sb = self.output.verticalScrollBar()
|
||||||
@ -237,6 +238,11 @@ class ConsoleWidget(QtGui.QWidget):
|
|||||||
else:
|
else:
|
||||||
sb.setValue(scroll)
|
sb.setValue(scroll)
|
||||||
|
|
||||||
|
|
||||||
|
def fileno(self):
|
||||||
|
# Need to implement this since we temporarily occlude sys.stdout, and someone may be looking for it (faulthandler, for example)
|
||||||
|
return 1
|
||||||
|
|
||||||
def displayException(self):
|
def displayException(self):
|
||||||
"""
|
"""
|
||||||
Display the current exception and stack.
|
Display the current exception and stack.
|
||||||
@ -319,8 +325,8 @@ class ConsoleWidget(QtGui.QWidget):
|
|||||||
if editor is None:
|
if editor is None:
|
||||||
return
|
return
|
||||||
tb = self.currentFrame()
|
tb = self.currentFrame()
|
||||||
lineNum = tb.tb_lineno
|
lineNum = tb.f_lineno
|
||||||
fileName = tb.tb_frame.f_code.co_filename
|
fileName = tb.f_code.co_filename
|
||||||
subprocess.Popen(self.editor.format(fileName=fileName, lineNum=lineNum), shell=True)
|
subprocess.Popen(self.editor.format(fileName=fileName, lineNum=lineNum), shell=True)
|
||||||
|
|
||||||
def updateSysTrace(self):
|
def updateSysTrace(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user