h-d-m handle empty properties

Kay Sievers kay.sievers at vrfy.org
Fri Jul 1 09:20:42 PDT 2005


Want to get rid of the patches I found in the SUSE package... :)
This makes hal-device-manager handle empty properties where a value is
expected.

Ok to commit?

Thanks,
Kay
-------------- next part --------------
Index: tools/device-manager/Device.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Device.py,v
retrieving revision 1.2
diff -u -p -r1.2 Device.py
--- tools/device-manager/Device.py	22 Dec 2003 04:03:10 -0000	1.2
+++ tools/device-manager/Device.py	1 Jul 2005 16:14:11 -0000
@@ -21,7 +21,7 @@ class Device:
     def populate_gtk_tree(self, tree_model, dont_show_virtual, representation):
         # see if we should show virtual devices
         if dont_show_virtual:
-            if self.properties.has_key("info.virtual"):
+            try:
                 if self.properties["info.virtual"]:
                     # do show all block devices, ide channels
                     if not self.properties["info.bus"] in ["block", "ide_host"]:
@@ -32,7 +32,8 @@ class Device:
                                                 dont_show_virtual,
                                                 representation)
                         return
-
+            except:
+                pass
         if self.parent_device==None:
             self.row = None
         else:
@@ -47,6 +48,8 @@ class Device:
                 title_name = self.properties["info.product"]
             except KeyError:
                 title_name = "Unknown Device"
+            except TypeError:
+                title_name = "Unknown Device"
             tree_model.set_value(self.row, Const.TITLE_COLUMN, title_name)
             tree_model.set_value(self.row, Const.UDI_COLUMN, self.device_name)
 
Index: tools/device-manager/DeviceManager.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/DeviceManager.py,v
retrieving revision 1.24
diff -u -p -r1.24 DeviceManager.py
--- tools/device-manager/DeviceManager.py	13 May 2005 16:27:10 -0000	1.24
+++ tools/device-manager/DeviceManager.py	1 Jul 2005 16:14:11 -0000
@@ -266,6 +266,9 @@ class DeviceManager(LibGladeApplication)
             except KeyError:
                 # no parent, must be parent of virtual_root
                 parent_name = "/"
+            except TypeError:
+                print "Error: no properties for device %s"%name
+                continue
             device = Device(name, parent_name, properties)
             self.device_list.append(device)
 
Index: tools/device-manager/Representation.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Representation.py,v
retrieving revision 1.14
diff -u -p -r1.14 Representation.py
--- tools/device-manager/Representation.py	27 Apr 2005 19:35:47 -0000	1.14
+++ tools/device-manager/Representation.py	1 Jul 2005 16:14:11 -0000
@@ -47,7 +47,13 @@ class Representation:
         # Default to abstract icon
         icon = self.icons["abstract"]
 
-        product = device.properties.get("info.product", "")
+        try:
+            product = device.properties["info.product"]
+        except KeyError:
+            product = "Unknown"
+        except TypeError:
+            return icon
+            
         if product=="Computer":
             return self.icons["computer"]
 
-------------- next part --------------
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal


More information about the Hal mailing list