[Sugar-devel] SL Bug #2063

Mukul Gupta mukul at seeta.in
Wed Oct 13 16:19:00 EDT 2010


David,

Thank you. Appreciate your motivation and feedback.

Regards,

Mukul Gupta


On Thu, Oct 14, 2010 at 1:41 AM, Mukul Gupta <mukul at seeta.in> wrote:

> Please find my explanations on the code added as comments.
>
> 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()
>
> ''' Defining an Error Alert function in the Journal Activity Class which
> displays the message as
>
> Operation could not be performed
> Please check the logviewer activity for details
> and an OK button
> '''
>
>
> +    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
>
> '''
> Defining a function which logs the unhandled exception as well as calls the
> Error Alert in the Journal whenever any uncaught exception occurs
> '''
>
> +def _alert_excepthook(exc_type, exc_value, traceback):
> +    logging.exception('Unhandled Python exception: %s', repr((exc_type,
> exc_value, traceback)))
> +    _journal.uncaught_exception_alert()
> +
> '''
> 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.
> '''
>
> +sys.excepthook = _alert_excepthook
> +
>  def get_journal():
>      global _journal
>      if _journal is None:
> --
> 1.7.0.4
>
>
>
> On Thu, Oct 14, 2010 at 1:33 AM, David Farning <dfarning at gmail.com> wrote:
>
>> On Wed, Oct 13, 2010 at 2:50 PM, 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 ")
>> > +    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:
>> > --
>> > 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,
>> >
>> > Regards,
>> >
>> > Mukul Gupta
>>
>> Mukual,
>>
>> Well asked question.
>>
>> 1. You followed the 'show me the code' principle.  That shows that you
>> have thought through the problem far enough for a draft
>> implementation.
>>
>> 2. You are asking for specif help on two specif areas.  Based on the
>> draft code and specifc questions, it is easy for a reviewer to give
>> you the help.
>>
>> david
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101014/9d257606/attachment.html>


More information about the Sugar-devel mailing list