Add parameters to terminate() that specify an (optional) error message to display on termination.

This commit is contained in:
Daniel Burrows 2006-12-01 11:54:12 +01:00
parent 0483beb3b8
commit 0ee7dfd435
3 changed files with 20 additions and 3 deletions

View File

@ -525,9 +525,14 @@ class Blinkenlights(BlinkenBase, UIBase):
finally:
s.c.unlock()
def terminate(s, exitstatus = 0):
def terminate(s, exitstatus = 0, errortitle = None, errormsg = None):
s.c.stop()
UIBase.terminate(s, exitstatus)
if errormsg <> None:
if errortitle <> None:
sys.stderr.write('%s: %s\n'%(errortitle, errormsg))
else:
sys.stderr.write('%s\n' % errormsg)
UIBase.terminate(s, exitstatus = exitstatus, errortitle = errortitle, errormsg = errormsg)
def threadException(s, thread):
s.c.stop()

View File

@ -246,6 +246,13 @@ class VerboseUI(UIBase):
tf = s.availablethreadframes.pop()
tf.destroy()
s.tflock.release()
def terminate(s, exitstatus = 0, errortitle = None, errormsg = None):
if errormsg <> None:
if errortitle == None:
errortitle = "Error"
TextOKDialog(errortitle, errormsg)
UIBase.terminate(s, exitstatus = exitstatus, errortitle = None, errormsg = None)
def threadException(s, thread):
exceptionstr = s.getThreadExceptionString(thread)

View File

@ -301,8 +301,13 @@ class UIBase:
def mainException(s):
s._msg(s.getMainExceptionString())
def terminate(s, exitstatus = 0):
def terminate(s, exitstatus = 0, errortitle = None, errormsg = None):
"""Called to terminate the application."""
if errormsg <> None:
if errortitle <> None:
sys.stderr.write('ERROR: %s\n\n%s\n'%(errortitle, errormsg))
else:
sys.stderr.write('%s\n' % errormsg)
sys.exit(exitstatus)
def threadExited(s, thread):