# HG changeset patch # User ssokolow@monolith.multiverse # Date 1187231711 14400 # Node ID b35d905d1a8344771504b2c94855b1e1af1cfd00 # Parent 7a4fcf84a34f4f7d6d2d4311977abf6568bdfcbd Make contrib/lap.py support pre-DBus Audacious via an audtool-wrapping fallback. diff -r 7a4fcf84a34f -r b35d905d1a83 contrib/lap.py --- a/contrib/lap.py Mon Aug 13 23:24:50 2007 +0300 +++ b/contrib/lap.py Wed Aug 15 22:35:11 2007 -0400 @@ -41,6 +41,10 @@ import fnmatch, optparse, os, subprocess from dbus import Bus, DBusException +# Support audtool as a fallback but don't depend on it +try: import subprocess +except ImportError: pass + # Use readline if available but don't depend on it try: import readline except ImportError: pass @@ -70,10 +74,17 @@ def addTrack(path, play=False): try: + file_url = 'file://' + path mp = bus.get_object('org.freedesktop.MediaPlayer', '/TrackList') - mp.AddTrack('file://' + path, play) + mp.AddTrack(file_url, play) except DBusException: - print "ERROR: Unable to contact media player." + try: + if subprocess.call(['audtool','playlist-addurl',file_url]): + print "ERROR: audtool fallback returned an error for: %s" % file_url + else: + os.system('audtool playlist-jump `audtool playlist-length`; audtool playback-play') + except OSError: + print "ERROR: Unable to call audtool as a fallback for: %s" % file_url def parseChoice(inString): try: