[Sugar-devel] SL Bug #2063

Mukul Gupta mukul at seeta.in
Wed Oct 13 15:50:26 EDT 2010


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),

diff --git a/journalactivity.py b/journalactivity.py
index 44cc018..36a2e2e 100644
--- a/journalactivity.py
+++ b/journalactivity.py
@@ -358,8 +358,20 @@ class JournalActivity(Window):

+    def uncaught_exception_alert(self):
+        alert = ErrorAlert(title="Operation could not be performed",
msg="Please check the logviewer activity for details ")
+    alert.connect('response', self.__alert_response_cb)
+    self.add_alert(alert)
+    alert.show()
 _journal = None

+def _alert_excepthook(exc_type, exc_value, traceback):
+    logging.exception('Unhandled Python exception: %s', repr((exc_type,
exc_value, traceback)))
+    _journal.uncaught_exception_alert()
+sys.excepthook = _alert_excepthook
 def get_journal():
     global _journal
     if _journal is None:

I wish to request you to please review the code and suggest desired changes,
if any.

Moreover, I have two important questions regarding the bug.

1. To catch all unhandled python exceptions in sugar, where exactly should
we be looking forward to be the venue for adding the functionality?

    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.

2. Wish if you could recommend on the GUI feature that could be used for
displaying the alert message to the user.

Looking forward to for your valuable suggestions,


Mukul Gupta
Research Engineer,SEETA

On Tue, Oct 12, 2010 at 12:46 AM, Mukul Gupta <mukul at seeta.in> wrote:

> Team,
> I had a discussion with Aleksey this morning at IRC on the feedback
> recommended yesterday. Thank you Daniel and Tomeu. Appreciate your ideas and
> pointers.
> We brainstormed on how the implementation of this functionality could be
> done, and found that whenever any uncaught exception is raised, the
> interpreter calls the sys.excepthook(type,value,traceback).
> Wish to have the feedback on whether excepthook implementation would be
> helpful to our use-case both short-term and long-term. Also, it would be
> wonderful if feedback could be shared on its implementation in the context
> of Sugar, or otherwise.
> Looking forward to hearing from you.
> Regards,
> Mukul Gupta
> On Mon, Oct 11, 2010 at 2:14 PM, Manusheel Gupta <manu at seeta.in> wrote:
>> Tomeu and Daniel,
>> On Mon, Oct 11, 2010 at 1:50 PM, Tomeu Vizoso <tomeu at sugarlabs.org>wrote:
>>> On Mon, Oct 11, 2010 at 09:57, Daniel Drake <dsd at laptop.org> wrote:
>>> > On 10 October 2010 20:14, Mukul Gupta <mukul at seeta.in> wrote:
>>> >> With reference to SL Bug # 2063 which deals with bringing some kind of
>>> >> notification alert whenever an unhandled python exception occurs, I
>>> had a
>>> >> few doubts. There are two approaches that I can think of.
>>> >
>>> > Neither of these sounds sensible.
>>> >
>>> > What's wrong with the obvious solution of popping up a dialog when the
>>> > exception occurs?
>>> >
>>> > Technically the exceptions are not unhandled, if they were unhandled
>>> > then sugar would crash. I guess we're referring to exceptions that are
>>> > not handled gracefully and instead fall back to a catch-all handler
>>> > which does not have the knowledge to act on them.
>>> This is what abrt does with python (and other) processes, maybe we
>>> could reuse it or at least steal some of the ideas:
>>> https://fedorahosted.org/abrt/
>> Thank you for the feedback and pointers. Appreciate it.
>>  We'll discuss the approach shared by you this afternoon.
>> Regards,
>> Manu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101014/574bb54e/attachment.html>

More information about the Sugar-devel mailing list