Re: [Sugar-devel] [DESIGN] SL Bug# 2063 : Sugar should bring up an alert when an unhandled Python exception occurs

2010-10-25 Thread Gonzalo Odiard
Probably that is not a good ticket to start to hack in Sugar.
Actually, there are a few python process running all the time,
sugar-session, datastore-service, and in sugar < 0.90,
sugar-presence-service.

Gonzalo

On Mon, Oct 25, 2010 at 3:29 PM, Mukul Gupta  wrote:

> Bernie,
>
> 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),
>
> 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:
>
>
> 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
> Research Engineer,SEETA
>
> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


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

2010-10-21 Thread Manusheel Gupta
On Fri, Oct 22, 2010 at 4:57 AM, Manusheel Gupta  wrote:

>
>
> On Thu, Oct 14, 2010 at 5:59 AM,  wrote:
>
>> Hi
>>
>> Sorry if I do not fully understand this. The proposal is that an
>> ErrorAlert will be created which must be dismissed by its OK button. Is
>> there any possibility that a large number of errors can be created, each
>> needing to be manually dismissed?
>>
>
>
> Good question. Yes, this can surely happen, and we do need to take care of
> this use-case.
>
>
>
>
>>
>> > 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
>>
>> Option 1, example
>>
>> Operation could not be performed
>> Please check the logviewer activity for details
>>
>> Option 2 example
>> Sorry, something went wrong
>> Please check the file shell.log for details.
>>
>> The last line of that file is:
>> TypeError: integer expected got float
>>
>> It is very unlikely that primary school students will be able to make any
>> sense of the log and not much better for secondary school students. Anybody
>> who could interpret the log would probably know about the Log activity. So I
>> wouldn't ask them with "please check" but rather offer it as a possibility.
>>
>> My suggested rewording:
>> Sorry, something went wrong.
>> For more information, use the Log Activity
>> to view the file shell.log.
>>
>> The last line of that file is:
>> TypeError: integer expected got float
>>
>
>
>
I re-thought about the wording.  Still feel it is a bit complex for our
user-base. I might be incorrect.

We'll keep this wording for now, till we get a simpler one from the field.

Manu





>
>
>
>
>> ___
>> Sugar-devel mailing list
>> Sugar-devel@lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


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

2010-10-21 Thread Manusheel Gupta
On Thu, Oct 14, 2010 at 5:59 AM,  wrote:

> Hi
>
> Sorry if I do not fully understand this. The proposal is that an ErrorAlert
> will be created which must be dismissed by its OK button. Is there any
> possibility that a large number of errors can be created, each needing to be
> manually dismissed?
>


Good question. Yes, this can surely happen, and we do need to take care of
this use-case.




>
> > 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
>
> Option 1, example
> Operation could not be performed
> Please check the logviewer activity for details
>
> Option 2 example
> Sorry, something went wrong
> Please check the file shell.log for details.
> The last line of that file is:
> TypeError: integer expected got float
>
> It is very unlikely that primary school students will be able to make any
> sense of the log and not much better for secondary school students. Anybody
> who could interpret the log would probably know about the Log activity. So I
> wouldn't ask them with "please check" but rather offer it as a possibility.
>
> My suggested rewording:
> Sorry, something went wrong.
> For more information, use the Log Activity
> to view the file shell.log.
> The last line of that file is:
> TypeError: integer expected got float
>


Thank you for the pointer. Indeed very helpful. Yes, context and delivery of
the exception message is indeed the key here.

Any further inputs? Kindly share.

Manu




> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


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

2010-10-21 Thread Manusheel Gupta
Added the details of the bug and the tag for clarity.

Manu

On Fri, Oct 22, 2010 at 4:32 AM, Manusheel Gupta  wrote:

> Tim,
>
> Thanks for the feedback.
>
> On Thu, Oct 14, 2010 at 2:11 AM, Tim McNamara  > wrote:
>
>> On 14 October 2010 08:50, Mukul Gupta  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@lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>>
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


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

2010-10-21 Thread Manusheel Gupta
Tim,

Thanks for the feedback.

On Thu, Oct 14, 2010 at 2:11 AM, Tim McNamara
wrote:

> On 14 October 2010 08:50, Mukul Gupta  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@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel