# HG changeset patch # User Tomasz Mon # Date 1187264125 -7200 # Node ID 3834652ddd53a3b99818eba51f52832e8686a2d9 # Parent 1cd5fb04e05bf53285eca53bf9b8c6d14b2e0bd1# Parent b35d905d1a8344771504b2c94855b1e1af1cfd00 branch merge diff -r 1cd5fb04e05b -r 3834652ddd53 contrib/lap.py --- a/contrib/lap.py Thu Aug 16 13:34:48 2007 +0200 +++ b/contrib/lap.py Thu Aug 16 13:35:25 2007 +0200 @@ -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: