[Dextrose] [Design]: SL Bug #2063 (Sugar should bring up an alert when an unhandled Python exception occurs)

Manusheel Gupta manu at seeta.in
Thu Oct 21 19:03:44 EDT 2010


Added the details of the bug and the tag for clarity.

Manu

On Fri, Oct 22, 2010 at 4:32 AM, Manusheel Gupta <manu at seeta.in> wrote:

> Tim,
>
> Thanks for the feedback.
>
> On Thu, Oct 14, 2010 at 2:11 AM, Tim McNamara <paperless at timmcnamara.co.nz
> > wrote:
>
>> On 14 October 2010 08:50, Mukul Gupta <mukul at seeta.in> wrote:
>>
>>> Team,
>>>
>>> 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):
>>>          self.show_main_view()
>>>          self.search_grab_focus()
>>>
>>> +    def uncaught_exception_alert(self):
>>> +        alert = ErrorAlert(title="Operation could not be performed",
>>> msg="Please check the logviewer activity for details ")
>>>
>>
>> We can improve the helpfulness of this message. For example, we can tell
>> people which file to open in the log. I would like to give some recommended
>> steps to help get problems fixed, but I haven't included it here.
>>
>
>
>
>> Also, if they don't have the log viewer activity, then they may feel
>> helpless:
>>
>>
> Right. Point noted.
>
>
>
>>
>> def uncaught_exception_alert(self):
>>     from glob import glob
>>     from os import system
>>
>>     logger = ... # should be easy to find
>>     recentlog = glob("{0}*".format(logger.filename))[-1]
>>     last_log_line = system("tail -n 1 {0}".format(recentlog))
>>
>>     alert = ErrorAlert(title=_("Sorry, something went wrong"),
>>         msg = _("Please check the file {0} for details.\nThe last line of
>> that file is:\n{1}").format(
>>             recentlog,
>>             last_log_line))
>>     ...
>>
>>
>
>
> I also don't like the function name uncaught_exception_alert. Functions
>> should generally begin with verbs. Perhaps handle_uncaught_exception?
>>
>>
> +1. Yes, we'll use the nomenclature verb_object.
>
>
>
>
>>  _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:
>>> --
>>> 1.7.0.4
>>>
>>>
>>> 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,
>>>
>>
>> _______________________________________________
>> Sugar-devel mailing list
>> Sugar-devel at lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/dextrose/attachments/20101022/517ccb07/attachment-0001.html>


More information about the Dextrose mailing list