David,<br><br><span dir="ltr" id=":3j">Thank you. Appreciate your motivation and feedback.<br><br>Regards,<br><br>Mukul Gupta<br></span><br><br><div class="gmail_quote">On Thu, Oct 14, 2010 at 1:41 AM, Mukul Gupta <span dir="ltr"><<a href="mailto:mukul@seeta.in">mukul@seeta.in</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><span dir="ltr">Please find my explanations on the code added as comments.</span><div dir="ltr">
<div class="im"><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 class="im"><br>Operation could not be performed<br></div><div class="im">Please check the logviewer activity for details<br>
</div>and an OK button<br>
'''<div class="im"><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 class="im"><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>'''<div class="im"><br>
+sys.excepthook = _alert_excepthook<br>
+<br>
def get_journal():<br>
global _journal<br>
if _journal is None:<br><font color="#888888">
-- <br>
1.7.0.4
</font><br></div></div><div><div></div><div class="h5"><br><br><br><div class="gmail_quote">On Thu, Oct 14, 2010 at 1:33 AM, David Farning <span dir="ltr"><<a href="mailto:dfarning@gmail.com" target="_blank">dfarning@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>On Wed, Oct 13, 2010 at 2:50 PM, Mukul Gupta <<a href="mailto:mukul@seeta.in" target="_blank">mukul@seeta.in</a>> wrote:<br>
> Team,<br>
><br>
</div><div><div></div><div>> Wish to have your feedback on the design aspect of the ticket 2063 (Sugar<br>
> should bring up an alert when an unhandled Python exception occurs) - please<br>
> find the git diff attached below. This is an attempt to display an alert<br>
> when an unhandled Python exception occurs in the journal. Unfortunately,<br>
> when the exception takes place in journalactivity.py , I am neither unable<br>
> to notice the Journal Icon (it disappears),<br>
><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>
> + def uncaught_exception_alert(self):<br>
> + alert = ErrorAlert(title="Operation could not be performed",<br>
> 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>
> +def _alert_excepthook(exc_type, exc_value, traceback):<br>
> + logging.exception('Unhandled Python exception: %s', repr((exc_type,<br>
> exc_value, traceback)))<br>
> + _journal.uncaught_exception_alert()<br>
> +<br>
> +sys.excepthook = _alert_excepthook<br>
> +<br>
> def get_journal():<br>
> global _journal<br>
> if _journal is None:<br>
> --<br>
> 1.7.0.4<br>
><br>
> I wish to request you to please review the code and suggest desired changes,<br>
> 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<br>
> we be looking forward to be the venue for adding the functionality?<br>
> Adding it in journalactivity.py doesn't seem to serve all purposes. It<br>
> has to be added somewhere which is being used all the time.<br>
><br>
> 2. Wish if you could recommend on the GUI feature that could be used for<br>
> displaying the alert message to the user.<br>
><br>
> Looking forward to for your valuable suggestions,<br>
><br>
> Regards,<br>
><br>
> Mukul Gupta<br>
<br>
</div></div>Mukual,<br>
<br>
Well asked question.<br>
<br>
1. You followed the 'show me the code' principle. That shows that you<br>
have thought through the problem far enough for a draft<br>
implementation.<br>
<br>
2. You are asking for specif help on two specif areas. Based on the<br>
draft code and specifc questions, it is easy for a reviewer to give<br>
you the help.<br>
<font color="#888888"><br>
david<br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>