Commits

Luke Plant committed 97d1ffe

Fixed some Python 3 incompatibilities

Comments (0)

Files changed (2)

playerdo/backends/base.py

         Shows OSD (on screen display).
         """
         raise NotImplementedError
+
+    def __lt__(self, other):
+        # This is needed to stop errors on Python 3
+        return self.sort_order < other.sort_order
 
 KEYBINDINGS_PREFIX = "/desktop/gnome/keybindings"
 
+def force_unicode(s):
+    if type(s) is not unicode:
+        return s.decode('UTF-8')
+    else:
+        return s
 
 def install_gnome():
     """
     if p.returncode != 0:
         raise Exception("Could not use gconftool to manipulate settings")
     retval = []
+    stdout = force_unicode(stdout)
     for x in stdout.split("\n"):
         x = x.strip()
         if x.startswith(KEYBINDINGS_PREFIX):
     stdout, stderr = p.communicate(None)
     if p.returncode != 0:
         raise Exception("Could not use gconftool to manipulate settings")
-    return stdout
+    return force_unicode(stdout)
 
 
 def set_gconf_val(key, val):
 def launch_keybinding_editor():
     p = Popen(["which", "gnome-keybinding-properties"], stdout=PIPE)
     stdout, stderr = p.communicate(None)
-    val = stdout.strip()
+    val = force_unicode(stdout).strip()
     if val == "":
         raise Exception("Can't find program gnome-keybinding-properties to configure keys")
     call(["nohup %s &" % val], shell=True, stdout=open("/dev/null"), stderr=open("/dev/null"))