[conduit/gsoc09_alexandre: 6/24] Better use of exceptions targeted at not interfering KeyboardInterrupt.
- From: Alexandre Rosenfeld <arosenfeld src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [conduit/gsoc09_alexandre: 6/24] Better use of exceptions targeted at not interfering KeyboardInterrupt.
- Date: Thu, 13 Aug 2009 04:11:43 +0000 (UTC)
commit 348ddc35f3bc563d0b7493810e782327e41029d5
Author: Alexandre Rosenfeld <airmind gmail com>
Date: Tue Jul 7 02:21:31 2009 -0300
Better use of exceptions targeted at not interfering KeyboardInterrupt.
conduit/DBus.py | 8 +---
conduit/MappingDB.py | 2 +-
conduit/ModuleWrapper.py | 97 ++++++++++++++++++++++----------------------
conduit/SyncSet.py | 2 +-
conduit/Synchronization.py | 2 +-
5 files changed, 54 insertions(+), 57 deletions(-)
---
diff --git a/conduit/DBus.py b/conduit/DBus.py
index d4024c9..253f8fe 100644
--- a/conduit/DBus.py
+++ b/conduit/DBus.py
@@ -280,9 +280,7 @@ class ConduitDBusItem(DBusItem):
raise ConduitException("Simple exporter must only have one sink")
#Need to call get_icon so that the icon_name/path is loaded
- try:
- self.conduit.datasinks[0].get_icon()
- except:
+ if not self.conduit.datasinks[0].get_icon():
log.warn("DBus could not lookup dp icon")
info = {}
@@ -329,9 +327,7 @@ class DataProviderDBusItem(DBusItem):
def GetInformation(self):
self._print("GetInformation")
#Need to call get_icon so that the icon_name/path is loaded
- try:
- self.dataprovider.get_icon()
- except:
+ if not self.dataprovider.get_icon():
log.warn("DBus could not lookup dp icon")
info = {}
diff --git a/conduit/MappingDB.py b/conduit/MappingDB.py
index f52ea9a..6acbc64 100644
--- a/conduit/MappingDB.py
+++ b/conduit/MappingDB.py
@@ -90,7 +90,7 @@ class MappingDB:
filename = os.path.abspath(f)
try:
self._open_db_and_check_structure(filename)
- except:
+ except Exception:
os.unlink(filename)
self._open_db_and_check_structure(filename)
diff --git a/conduit/ModuleWrapper.py b/conduit/ModuleWrapper.py
index 1f6a385..0fe696a 100644
--- a/conduit/ModuleWrapper.py
+++ b/conduit/ModuleWrapper.py
@@ -190,18 +190,20 @@ class ModuleWrapper:
may override this function
"""
import gtk
- if not self.icon.has_key(size) or self.icon[size] is None:
+ if size not in self.icon or self.icon[size] is None:
if self.module_type in ["source", "sink", "twoway", "category"]:
- try:
- info = gtk.icon_theme_get_default().lookup_icon(self.icon_name, size, 0)
+ info = gtk.icon_theme_get_default().lookup_icon(self.icon_name, size, 0)
+ if info:
self.icon[size] = info.load_icon()
self.icon_path = info.get_filename()
- except:
+ else:
self.icon[size] = None
log.warn("Could not load icon %s for %s" % (self.icon_name, self.name))
#Last resort: Try the non icon-naming-spec compliant icon
self.icon_name = "conduit"
info = gtk.icon_theme_get_default().lookup_icon(self.icon_name, size, 0)
+ if not info:
+ return None
self.icon[size] = info.load_icon()
self.icon_path = info.get_filename()
@@ -226,52 +228,51 @@ class ModuleWrapper:
if self.descriptiveIcon is None:
if self.module_type in ["source", "sink", "twoway"]:
- try:
- icon = self.get_icon(isize)
- arrowName = "conduit-"+self.module_type
- arrow = gtk.icon_theme_get_default().load_icon(arrowName, asize, 0)
-
- #Composite the arrow to the right of the icon
- dest = gtk.gdk.Pixbuf(
- colorspace=gtk.gdk.COLORSPACE_RGB,
- has_alpha=True,
- bits_per_sample=8,
- width=bwidth,
- height=bheight
- )
- dest.fill(0)
+ icon = self.get_icon(isize)
+ if not icon:
+ return None
+ arrowName = "conduit-"+self.module_type
+ arrow = gtk.icon_theme_get_default().load_icon(arrowName, asize, 0)
- #Composite the icon on the left
- icon.composite(
- dest=dest,
- dest_x=0, #right of icon
- dest_y=0, #at the top
- dest_width=isize, #use whole arrow 1:1
- dest_height=isize, #ditto
- offset_x=0,
- offset_y=0,
- scale_x=1,
- scale_y=1,
- interp_type=gtk.gdk.INTERP_NEAREST,
- overall_alpha=255
+ #Composite the arrow to the right of the icon
+ dest = gtk.gdk.Pixbuf(
+ colorspace=gtk.gdk.COLORSPACE_RGB,
+ has_alpha=True,
+ bits_per_sample=8,
+ width=bwidth,
+ height=bheight
)
- #Arrow on the right
- arrow.composite(
- dest=dest,
- dest_x=isize, #right of icon
- dest_y=isize-asize, #at the bottom
- dest_width=asize, #use whole arrow 1:1
- dest_height=asize, #ditto
- offset_x=isize, #move self over to the right
- offset_y=isize-asize,#at the bottom
- scale_x=1,
- scale_y=1,
- interp_type=gtk.gdk.INTERP_NEAREST,
- overall_alpha=255
- )
- self.descriptiveIcon = dest
- except:
- log.warn("Error getting icon\n%s" % traceback.format_exc())
+ dest.fill(0)
+
+ #Composite the icon on the left
+ icon.composite(
+ dest=dest,
+ dest_x=0, #right of icon
+ dest_y=0, #at the top
+ dest_width=isize, #use whole arrow 1:1
+ dest_height=isize, #ditto
+ offset_x=0,
+ offset_y=0,
+ scale_x=1,
+ scale_y=1,
+ interp_type=gtk.gdk.INTERP_NEAREST,
+ overall_alpha=255
+ )
+ #Arrow on the right
+ arrow.composite(
+ dest=dest,
+ dest_x=isize, #right of icon
+ dest_y=isize-asize, #at the bottom
+ dest_width=asize, #use whole arrow 1:1
+ dest_height=asize, #ditto
+ offset_x=isize, #move self over to the right
+ offset_y=isize-asize,#at the bottom
+ scale_x=1,
+ scale_y=1,
+ interp_type=gtk.gdk.INTERP_NEAREST,
+ overall_alpha=255
+ )
+ self.descriptiveIcon = dest
elif self.module_type == "category":
self.descriptiveIcon = self.get_icon(isize)
diff --git a/conduit/SyncSet.py b/conduit/SyncSet.py
index 84fef59..aa2d290 100644
--- a/conduit/SyncSet.py
+++ b/conduit/SyncSet.py
@@ -264,7 +264,7 @@ class SyncSet(gobject.GObject):
if len(key) > 0:
self._restore_dataprovider(cond, key, name, sink, xml_version, False)
- except:
+ except Exception:
log.warn("Error parsing %s. Exception:\n%s" % (xmlSettingFilePath, traceback.format_exc()))
os.remove(xmlSettingFilePath)
diff --git a/conduit/Synchronization.py b/conduit/Synchronization.py
index aa19e15..e44abf1 100644
--- a/conduit/Synchronization.py
+++ b/conduit/Synchronization.py
@@ -452,7 +452,7 @@ class SyncWorker(_ThreadedWorker):
try:
put_data(sourceWrapper, sinkWrapper, fromData, fromDataRid, True)
- except:
+ except Exception:
log.warn("Forced Put Failed\n%s" % traceback.format_exc())
def check_thread_not_cancelled(self, dataprovidersToCancel):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]