<div class="gmail_quote">Bernie,<br>
<br></div><div class="gmail_quote">Wish to have your feedback on the
design aspect of the ticket 2063 (Sugar should bring up an alert when an
unhandled Python exception occurs) - please find the git diff attached
below. This is an attempt to display an alert when an unhandled Python
exception occurs in the journal. Unfortunately, when the exception takes
place in journalactivity.py , I am neither unable to notice the Journal
Icon (it disappears), </div>
<br><span dir="ltr">Please find my explanations on the code added as comments.</span><div><br>diff --git a/journalactivity.py b/journalactivity.py<br>
index 44cc018..36a2e2e 100644<br>
--- a/journalactivity.py<br>
+++ b/journalactivity.py<br>
@@ -358,8 +358,20 @@ class JournalActivity(Window):<br>
self.show_main_view()<br>
self.search_grab_focus()<br>
<br></div>''' Defining an Error Alert function in the Journal Activity Class which displays the message as<div><br>Operation could not be performed<br></div><div>Please check the logviewer activity for details<br>
</div>and an OK button<br>
'''<div><br> <br>
+ def uncaught_exception_alert(self):<br>
+ alert = ErrorAlert(title="Operation could not be performed", msg="Please check the logviewer activity for details ")<br>
+ alert.connect('response', self.__alert_response_cb)<br>
+ self.add_alert(alert)<br>
+ alert.show()<br>
+<br>
_journal = None<br>
<br></div>
'''<br>Defining a function which logs the unhandled exception as well as
calls the Error Alert in the Journal whenever any uncaught exception
occurs<br>'''<div><br>+def _alert_excepthook(exc_type, exc_value, traceback):<br>
+ logging.exception('Unhandled Python exception: %s', repr((exc_type, exc_value, traceback)))<br>
+ _journal.uncaught_exception_alert() <br>
+<br></div>'''<br>When an exception is raised and uncaught, sys.excepthook is called with three arguments, the exception class, exception
instance, and a traceback object.The function _alert_excepthook is called only when an unhandled exception occurs.<br>'''<br>
+sys.excepthook = _alert_excepthook<br>
+<br>
def get_journal():<br>
global _journal<br>
if _journal is None:<br><br><br>I wish to request you to please review the code and suggest desired changes, if any.<br>
<br>
Moreover, I have two important questions regarding the bug.<br>
<br>
1. To catch all unhandled python exceptions in sugar, where exactly
should we be looking forward to be the venue for adding the
functionality?<div><br>
Adding it in journalactivity.py doesn't seem to serve all purposes.
It has to be added somewhere which is being used all the time.<br>
<br></div>
2. Wish if you could recommend on the GUI feature that could be used for displaying the alert message to the user.<br>
<br>Looking forward to for your valuable suggestions,<div><div><br>
<br>
Regards,<br><font color="#888888">
<br>
Mukul Gupta<br>
Research Engineer,SEETA
</font></div></div><div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}</style>