Commits

Byron Clark  committed 7bfc149

Check for dbus errors on the critical operations.

  • Participants
  • Parent commits cdd09f1

Comments (0)

Files changed (3)

-- actually check for errors from udisks calls
 - declare dependency on python-dbus
 - handle dbus restart
 - properly daemonize

File udiskie/mount.py

         if device.is_handleable() and not device.is_mounted():
             filesystem = str(device.id_type())
             options = []
-            device.mount(filesystem, options)
-            self.log.info('mounted device %s' % (device,))
+            try:
+                device.mount(filesystem, options)
+                self.log.info('mounted device %s' % (device,))
+            except dbus.exceptions.DBusException, dbus_err:
+                self.log.error('failed to mount device %s: %s' % (device,
+                                                                  dbus_err))
 
     def mount_present_devices(self):
         """Mount handleable devices that are already present."""

File udiskie/umount.py

 
     logger = logging.getLogger('udiskie.umount.unmount_device')
     if device.is_handleable() and device.is_mounted():
-        logger.debug('unmounting device %s' % (device,))
-        device.unmount()
-        logger.info('unmounted device %s' % (device,))
+        try:
+            device.unmount()
+            logger.info('unmounted device %s' % (device,))
+        except dbus.exceptions.DBusException, dbus_err:
+            logger.error('failed to unmount device %s: %s' % (device,
+                                                              dbus_err))
     else:
         logger.debug('skipping unhandled device %s' % (device,))