Commits

Thomas Gläßle committed f775b4e

Apply python3 compatibility patches

  • Participants
  • Parent commits 21ad3b5

Comments (0)

Files changed (3)

File udiskie/daemon.py

 import logging
 import dbus
 
+import sys
+
 from udiskie.device import Device, get_all_handleable
 
 
                 return
             self._store_device_state(udevice)
             self.trigger('device_added', udevice)
-        except dbus.exceptions.DBusException, err:
+        except dbus.exceptions.DBusException:
+            err = sys.exc_info()[1]
             self.log.error('%s(%s): %s' % ('device_added', device_name, err))
 
     def _device_removed(self, device_name):
         try:
             self.trigger('device_removed', device_name)
             self._remove_device_state(device_name)
-        except dbus.exceptions.DBusException, err:
+        except dbus.exceptions.DBusException:
+            err = sys.exc_info()[1]
             self.log.error('%s(%s): %s' % ('device_removed', device_name, err))
 
     def _device_changed(self, device_name):
             old_state = self._get_device_state(udevice)
             new_state = self._store_device_state(udevice)
             self.trigger('device_changed', udevice, old_state, new_state)
-        except dbus.exceptions.DBusException, err:
+        except dbus.exceptions.DBusException:
+            err = sys.exc_info()[1]
             self.log.error('%s(%s): %s' % ('device_changed', device_name, err))
 
     # internal state keeping

File udiskie/match.py

 """
 __all__ = ['InvalidFilter', 'OptionFilter', 'Filters', 'FilterMatcher']
 
-from ConfigParser import SafeConfigParser
+try:
+    from ConfigParser import SafeConfigParser
+except ImportError:
+    from configparser import SafeConfigParser
+
 import logging
 import re
 

File udiskie/mount.py

     'lock_luks_slave',
     'Mounter']
 
+import sys
 import logging
 import dbus
 
     try:
         device.mount(fstype, options)
         log.info('mounted device %s' % (device,))
-    except dbus.exceptions.DBusException, dbus_err:
-        log.error('failed to mount device %s: %s' % (
-                                            device, dbus_err))
+    except dbus.exceptions.DBusException:
+        err = sys.exc_info()[1]
+        log.error('failed to mount device %s: %s' % (device, err))
         return None
 
     mount_paths = ', '.join(device.mount_paths)
     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))
+    except dbus.exceptions.DBusException:
+        err = sys.exc_info()[1]
+        logger.error('failed to unmount device %s: %s' % (device, err))
         return None
     return True
 
                 device.luks_cleartext_holder)
         holder_path = holder_dev.device_file
         log.info('unlocked device %s on %s' % (device, holder_path))
-    except dbus.exceptions.DBusException, dbus_err:
-        log.error('failed to unlock device %s:\n%s'
-                                    % (device, dbus_err))
+    except dbus.exceptions.DBusException:
+        err = sys.exc_info()[1]
+        log.error('failed to unlock device %s:\n%s' % (device, err))
         return None
     return True
 
     try:
         device.lock([])
         logger.info('locked device %s' % (device,))
-    except dbus.exceptions.DBusException, dbus_err:
-        logger.error('failed to lock device %s: %s' % (device, dbus_err))
+    except dbus.exceptions.DBusException:
+        err = sys.exc_info()[1]
+        logger.error('failed to lock device %s: %s' % (device, err))
         return None
     return True