Re: [sugar] [PATCH] adding a bad device to the frame shouldn't crash sugar

2008-06-04 Thread Martin Dengler
On Wed, Jun 04, 2008 at 11:44:09AM +0200, Tomeu Vizoso wrote:
 Looks good to me. Small comments inline:
 
  +import logging
  +logger = logging.getLogger('DevicesTray')
 
 What about moving the import along with the others and declaring the
 logger at the module level as in activitiesring.py?

Sure.  I saw that code after I thought of the patch, but figured
someone might want the patch changes to be all in one place in the
file (just so you know why I did it that way).  Changed as you
suggested.

  +logger.warn(Not able to add icon for device [%s], because of 
  +an error (%s). Continuing. % (device, message))
 
 May be better to print the __repr__ of the device, with %r instead of
 %s. In some classes, __str__ won't be as good a description of the
 instance as __repr__.

Sure.

 Thanks,
 
 Tomeu

Martin


pgpLiPoXKaVrb.pgp
Description: PGP signature
___
Sugar mailing list
Sugar@lists.laptop.org
http://lists.laptop.org/listinfo/sugar


[sugar] [PATCH] adding a bad device to the frame shouldn't crash sugar

2008-06-03 Thread Martin Dengler
---
 src/view/frame/devicestray.py |   16 +++-
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/view/frame/devicestray.py b/src/view/frame/devicestray.py
index 1accdad..1b7f3d1 100644
--- a/src/view/frame/devicestray.py
+++ b/src/view/frame/devicestray.py
@@ -35,11 +35,17 @@ class DevicesTray(HTray):
   self.__device_disappeared_cb)
 
 def _add_device(self, device):
-view = deviceview.create(device)
-# TODO: *Tray classes don't allow yet to set the alignment.
-self.add_item(view)
-view.show()
-self._device_icons[device.get_id()] = view
+try:
+view = deviceview.create(device)
+# TODO: *Tray classes don't allow yet to set the alignment.
+self.add_item(view)
+view.show()
+self._device_icons[device.get_id()] = view
+except Exception, message:
+import logging
+logger = logging.getLogger('DevicesTray')
+logger.warn(Not able to add icon for device [%s], because of 
+an error (%s). Continuing. % (device, message))
 
 def _remove_device(self, device):
 self.remove_item(self._device_icons[device.get_id()])
-- 
1.5.5.1

___
Sugar mailing list
Sugar@lists.laptop.org
http://lists.laptop.org/listinfo/sugar