Commits

Massimiliano Torromeo  committed cc623f5

Ignored pynotify notification failures to allow headless mounts

  • Participants
  • Parent commits 98311e2

Comments (0)

Files changed (2)

File udiskie/mount.py

 
 import dbus
 import gobject
+import gio
 import pynotify
 
 import udiskie.device
                         return
 
                     mount_paths = ', '.join(device.mount_paths())
-                pynotify.Notification('Device mounted',
-                                      '%s mounted on %s' % (device.device_file(),
-                                                            mount_paths),
-                                      'drive-removable-media').show()
+                    try:
+                        pynotify.Notification('Device mounted',
+                                              '%s mounted on %s' % (device.device_file(),
+                                                                    mount_paths),
+                                              'drive-removable-media').show()
+                    except gio.Error:
+                        pass
             finally:
                 self._store_device_state(device)
 

File udiskie/umount.py

 import os
 
 import dbus
+import gio
 import pynotify
 
 import udiskie.device
                                                               dbus_err))
             return
 
-        pynotify.Notification('Device unmounted',
-                              '%s unmounted' % (device.device_file(),),
-                              'drive-removable-media').show()
+        try:
+            pynotify.Notification('Device unmounted',
+                                  '%s unmounted' % (device.device_file(),),
+                                  'drive-removable-media').show()
+        except gio.Error:
+            pass
     else:
         logger.debug('skipping unhandled device %s' % (device,))