Commits

Luke Plant committed 541aae9

Implemented 'test' command and backend implementations.

Comments (0)

Files changed (3)

playerdo/backends/base.py

         """
         raise NotImplementedError
 
+    def check_dependencies(self):
+        """
+        Returns a list of failed dependencies for using this backend, or an
+        empty list if everything is OK.  Most players do not need this.
+        """
+        return []
+
     def do_command(self, command):
         try:
             m = getattr(self, command)

playerdo/backends/shellfm.py

                                                ".shell-fm",
                                                "nowplaying"))
 
+    def check_dependencies(self):
+        if process_retval(["which", "shc"]) != 0:
+            return ["The command line program 'shc', compiled from the shc.hs script that comes with shell-fm, needs to be present on your PATH."]
+        return []
+
+
     # Can't implement 'play', because once you are stopped, shell-fm/shc needs
     # you to specify a station if you want it to play.
 
 
 
 def do_test(players):
-    # Check dependencies of all players
-    pass
+    """
+    Checks that all backends have required dependencies, printing any failures
+    """
+    for P in players:
+        p = P()
+        failures = p.check_dependencies()
+        if len(failures) > 0:
+            sys.stdout.write("Player '%s' has missing dependencies:\n" % p.friendly_name)
+            for l in failures:
+                sys.stdout.write("  " + l + "\n")
 
 
 def do_command(command, players):