Luke Plant avatar Luke Plant committed 2188661

Python 3 compat fixes

Comments (0)

Files changed (2)


 from playerdo.utils import process_stdout, process_retval
+# Convoluted expressions fpr Python 2/3 compat
+STATE_STOP = "State: STOP".encode('ascii')
+STATE_PAUSE = "State: PAUSE".encode('ascii')
 class Moc(Player):
     process_name = "mocp"
     def is_stopped(self):
         info = process_stdout(["mocp", "-i"])
-        return "State: STOP" in info
+        return STATE_STOP in info
     def is_paused(self):
         info = process_stdout(["mocp", "-i"])
-        return "State: PAUSE" in info
+        return STATE_PAUSE in info
     def play(self):
         process_retval(["mocp", "--play"])


     friendly_name = "quodlibet"
     def is_running(self):
-        processes = process_stdout(["ps", "-A", "-o", "cmd"]).split("\n")
+        processes = process_stdout(["ps", "-A", "-o", "cmd"]).decode('ascii').split("\n")
         return len([p for p in processes
                 if (p.startswith("python")
                     and ("quodlibet" in p))]) > 0
     def is_paused(self):
-        return process_stdout(["quodlibet", "--status"]).strip().split(' ')[0:1] == ["paused"]
+        return process_stdout(["quodlibet", "--status"]).decode('ascii').strip().split(' ')[0:1] == ["paused"]
     def is_stopped(self):
         # Has no concept of 'stopped'
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
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.