mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
inline exceptions
This commit is contained in:
parent
e3a59f8cf7
commit
9fc21a61dc
1 changed files with 11 additions and 5 deletions
16
aqt/main.py
16
aqt/main.py
|
@ -897,24 +897,30 @@ will be lost. Continue?"""))
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def onDebug(self):
|
def onDebug(self):
|
||||||
d = QDialog()
|
d = self.debugDiag = QDialog()
|
||||||
frm = aqt.forms.debug.Ui_Dialog()
|
frm = aqt.forms.debug.Ui_Dialog()
|
||||||
frm.setupUi(d)
|
frm.setupUi(d)
|
||||||
d.connect(frm.line, SIGNAL("returnPressed()"), lambda: self.onDebugRet(frm))
|
d.connect(frm.line, SIGNAL("returnPressed()"), lambda: self.onDebugRet(frm))
|
||||||
d.exec_()
|
d.show()
|
||||||
|
|
||||||
def onDebugRet(self, frm):
|
def onDebugRet(self, frm):
|
||||||
import pprint
|
import pprint, traceback
|
||||||
line = frm.line.text()
|
line = frm.line.text()
|
||||||
if not line:
|
if not line:
|
||||||
return
|
return
|
||||||
def card():
|
def card():
|
||||||
return self.reviewer.card.__dict__
|
return self.reviewer.card.__dict__
|
||||||
locals = dict(mw=self, card=card)
|
locals = dict(mw=self, card=card)
|
||||||
ret = eval(line, globals(), locals)
|
newline = "\n"
|
||||||
|
try:
|
||||||
|
ret = eval(line, globals(), locals)
|
||||||
|
except Exception, e:
|
||||||
|
newline = ""
|
||||||
|
ret = traceback.format_exc()
|
||||||
if not isinstance(ret, basestring):
|
if not isinstance(ret, basestring):
|
||||||
ret = pprint.pformat(ret)
|
ret = pprint.pformat(ret)
|
||||||
frm.log.appendPlainText(">>> %s\n%s\n" % (line, ret))
|
frm.log.appendPlainText(">>> %s\n%s%s" % (line, ret, newline))
|
||||||
|
frm.log.ensureCursorVisible()
|
||||||
|
|
||||||
# System specific code
|
# System specific code
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
Loading…
Reference in a new issue