Thomas Gläßle avatar Thomas Gläßle committed f775b4e

Apply python3 compatibility patches

Comments (0)

Files changed (3)

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
 """
 __all__ = ['InvalidFilter', 'OptionFilter', 'Filters', 'FilterMatcher']
 
-from ConfigParser import SafeConfigParser
+try:
+    from ConfigParser import SafeConfigParser
+except ImportError:
+    from configparser import SafeConfigParser
+
 import logging
 import re
 
     '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
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.