Return-Path: From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/4] Remove test-media-player Date: Fri, 30 Sep 2011 16:10:43 +0300 Message-Id: <1317388243-26240-5-git-send-email-luiz.dentz@gmail.com> In-Reply-To: <1317388243-26240-1-git-send-email-luiz.dentz@gmail.com> References: <1317388243-26240-1-git-send-email-luiz.dentz@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: From: Luiz Augusto von Dentz --- test/test-media-player | 108 ------------------------------------------------ 1 files changed, 0 insertions(+), 108 deletions(-) delete mode 100755 test/test-media-player diff --git a/test/test-media-player b/test/test-media-player deleted file mode 100755 index 712cf31..0000000 --- a/test/test-media-player +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python - -import sys -import dbus -from optparse import OptionParser, make_option - -USAGE = "Usage: %prog [options] [args]" -COMMANDS = """ -Commands: - changetrack [ ...] - - changeplayback status elapsed-time - status: one of playing, stopped, paused, forward-seek, reverse-seek - or error. - elapsed-time: in milliseconds - - setproperty property value - setting: one of Equalizer, Repeat, Shuffle or Scan - value: value correspondent to the setting specified -""" - -class MyParser(OptionParser): - def format_epilog(self, formatter): - return self.epilog - -bus = dbus.SystemBus() - -manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager") - -option_list = [ - make_option("-i", "--device", action="store", - type="string", dest="dev_id"), - ] -parser = MyParser(option_list=option_list, usage=USAGE, epilog=COMMANDS) - -(options, args) = parser.parse_args() - -if len(args) < 2: - parser.print_help() - sys.exit(1) - -if options.dev_id: - adapter_path = manager.FindAdapter(options.dev_id) -else: - adapter_path = manager.DefaultAdapter() - -adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path), - "org.bluez.Adapter") - -device = adapter.FindDevice(args[1]) -control = dbus.Interface(bus.get_object("org.bluez", device), - "org.bluez.Control") -mp = dbus.Interface(bus.get_object("org.bluez", device), - "org.bluez.MediaPlayer") - -def handle_change_track(mp, args): - if len(args) % 2 != 0: - print("Don't know how to handle odd number of parameters") - print(USAGE) - sys.exit(1) - - d = dict() - for i in range(2, len(args), 2): - key = args[i] - if key == "Title" or key == "Artist" or key == "Album" \ - or key == "Genre": - d[key] = dbus.String(args[i + 1].decode(sys.stdin.encoding)) - elif key == "NumberOfTracks" or key == "TrackNumber" \ - or key == "TrackDuration": - d[key] = dbus.UInt32(int(args[i + 1])) - else: - print("Unknown metadata: %s" % key) - sys.exit(1) - - d = dbus.Dictionary(d, signature='sv') - mp.ChangeTrack(d) - -def handle_change_playback(mp, args): - if len(args) != 4: - print(USAGE) - sys.exit(1) - - status = dbus.String(args[2]) - elapsed = dbus.UInt32(long(args[3])) - - mp.ChangePlayback(status, elapsed) - -def handle_set_property(mp, args): - if len(args) != 4: - print(USAGE) - sys.exit(1) - - prop = dbus.String(args[2]) - value = dbus.String(args[3]) - - mp.SetProperty(prop, value) - - -handlers = { 'changetrack': handle_change_track, - 'changeplayback': handle_change_playback, - 'setproperty': handle_set_property } - -if not args[0] in handlers: - print("Unknown command -- %s" % argv[1]) - print(USAGE) - sys.exit(1) - -handlers[args[0]](mp, args) -- 1.7.6.2