hal/tools/device-manager Device.py, 1.2, 1.3 DeviceManager.py, 1.24, 1.25 Representation.py, 1.14, 1.15

Kay Sievers kay at freedesktop.org
Fri Jul 1 10:49:46 PDT 2005


Update of /cvs/hal/hal/tools/device-manager
In directory gabe:/tmp/cvs-serv4029/tools/device-manager

Modified Files:
	Device.py DeviceManager.py Representation.py 
Log Message:
2005-07-01  Kay Sievers  <kay.sievers at vrfy.org>

        * tools/device-manager/Device.py:
        * tools/device-manager/DeviceManager.py:
        * tools/device-manager/Representation.py:
        Make h-d-m tolerate expected device properties which are empty.



Index: Device.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Device.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Device.py	22 Dec 2003 04:03:10 -0000	1.2
+++ Device.py	1 Jul 2005 17:49:44 -0000	1.3
@@ -21,7 +21,7 @@
     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 @@
                                                 dont_show_virtual,
                                                 representation)
                         return
-
+            except:
+                pass
         if self.parent_device==None:
             self.row = None
         else:
@@ -47,6 +48,8 @@
                 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: DeviceManager.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/DeviceManager.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- DeviceManager.py	13 May 2005 16:27:10 -0000	1.24
+++ DeviceManager.py	1 Jul 2005 17:49:44 -0000	1.25
@@ -266,6 +266,9 @@
             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: Representation.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Representation.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Representation.py	27 Apr 2005 19:35:47 -0000	1.14
+++ Representation.py	1 Jul 2005 17:49:44 -0000	1.15
@@ -47,7 +47,13 @@
         # 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"]
 




More information about the hal-commit mailing list