From 07974753e605ed76742a8c0b64c83140ad0bae11 Mon Sep 17 00:00:00 2001 From: "adrian.sampson" Date: Wed, 4 Feb 2009 09:55:42 +0000 Subject: [PATCH] added bpd command to bts.py --HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%4099 --- beets/player/bpd.py | 8 ++++---- bts.py | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/beets/player/bpd.py b/beets/player/bpd.py index 016da1b35..c482826d3 100755 --- a/beets/player/bpd.py +++ b/beets/player/bpd.py @@ -99,7 +99,7 @@ class Server(object): value = int(value) except: return ErrorResponse(ERROR_ARG, name, 'non-integer argument') - if (minval is not None and value < minval) or + if (minval is not None and value < minval) or \ (maxval is not None and value > maxval): return ErrorResponse(ERROR_ARG, name, 'value out of range') else: @@ -409,10 +409,10 @@ class BGServer(Server): library. """ - def __init__(self, host, port=DEFAULT_PORT, libpath='library.blb'): + def __init__(self, library, host='127.0.0.1', port=DEFAULT_PORT): import gstplayer super(BGServer, self).__init__(host, port) - self.library = Library(libpath) + self.library = library self.player = gstplayer.GstPlayer() def run(self): @@ -435,4 +435,4 @@ class BGServer(Server): if __name__ == '__main__': - BGServer('0.0.0.0', 6600, 'library.blb').run() \ No newline at end of file + BGServer(Library('library.blb')).run() diff --git a/bts.py b/bts.py index 39a574ae3..639fa1b02 100755 --- a/bts.py +++ b/bts.py @@ -51,6 +51,13 @@ def read(lib, criteria): item.store() lib.save() +def bpd(lib, opts): + host = opts.pop(0) if opts else '127.0.0.1' + port = int(opts.pop(0)) if opts else 6600 + + import beets.player.bpd + beets.player.bpd.BGServer(lib, host, port).run() + if __name__ == "__main__": # parse options usage = """usage: %prog [options] command @@ -78,11 +85,16 @@ command is one of: add, remove, update, write, list, help""" (imp, ['import', 'im', 'imp']), (remove, ['remove', 'rm']), (delete, ['delete', 'del']), + (read, ['read', 'r']), #(write, ['write', 'wr', 'w']), + (ls, ['list', 'ls']), + (option, ['set']), (help, ['help', 'h']), + + (bpd, ['bpd']), ] for test_command in avail_commands: if cmd in test_command[1]: