Mercurial > audlegacy
changeset 3352:b35d905d1a83 trunk
Make contrib/lap.py support pre-DBus Audacious via an audtool-wrapping fallback.
author | ssokolow@monolith.multiverse |
---|---|
date | Wed, 15 Aug 2007 22:35:11 -0400 |
parents | 7a4fcf84a34f |
children | 3834652ddd53 |
files | contrib/lap.py |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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: