[packagekit] packagekit: Branch 'master' - 2 commits

Richard Hughes hughsient at kemper.freedesktop.org
Thu Dec 20 09:37:49 PST 2007


 docs/html/pk-authors.html    |   15 ---------------
 python/packagekit/backend.py |   22 +++++++++++++++++++++-
 2 files changed, 21 insertions(+), 16 deletions(-)

New commits:
commit c08df06d1ce14ec3070786481d71f3f3a46707a8
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Thu Dec 20 11:14:31 2007 +0100

    python backend: Added Exception Handler so unhandled exception are sendt as a error signal to packagekit, should work for all python backends there use PackageKitBaseBackend as parent class

diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index d14c5f7..d7128f2 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -22,6 +22,7 @@
 
 # imports
 import sys
+import traceback
 import types
 from enums import *
 
@@ -30,6 +31,8 @@ from enums import *
 class PackageKitBaseBackend:
 
     def __init__(self,cmds):
+        # Setup a custom exception handler
+        installExceptionHandler(self)
         self.cmds = cmds
         self._locked = False
 
@@ -458,4 +461,21 @@ class PackagekitProgress:
         incr = int(f*deltapct)
         self.percent = startpct + incr
 
-        
+def exceptionHandler(typ, value, tb, base):
+    # Restore original exception handler
+    sys.excepthook = sys.__excepthook__
+    etb = traceback.extract_tb(tb)
+    errmsg = 'Error Type: %s;' % str(typ)
+    errmsg += 'Error Value: %s;' % str(value)
+    for tub in etb:
+        f,l,m,c = tub # file,lineno, function, codeline
+        errmsg += '  File : %s , line %s, in %s;' % (f,str(l),m)
+        errmsg += '    %s;' % c
+    # send the traceback to PackageKit
+    print errmsg
+    base.error(ERROR_INTERNAL_ERROR,errmsg,exit=True)
+    
+    
+def installExceptionHandler(base):
+    sys.excepthook = lambda typ, value, tb: exceptionHandler(typ, value, tb,base)
+    
\ No newline at end of file
commit 33794448792999b492eef27ab6fd2933ccaa1734
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Dec 19 21:51:11 2007 +0000

    get rid of the Person on the authors page

diff --git a/docs/html/pk-authors.html b/docs/html/pk-authors.html
index 5572d8f..745e786 100644
--- a/docs/html/pk-authors.html
+++ b/docs/html/pk-authors.html
@@ -173,21 +173,6 @@
  </td>
 </tr>
 
-<tr>
- <td>
-  <img src="img/author-unknown.png" alt="[img]"/><!-- image should be 120px wide -->
- </td>
- <td>
-  <h2>A Person</h2>
-  <p>
-   Details needed...
-  </p>
-  <p>
-   <b>Responsible for: foo backend</b>
-  </p>
- </td>
-</tr>
-
 </table>
 
 <p>Back to the <a href="index.html">main page</a></p>



More information about the PackageKit mailing list