pandora_client/bin/pandora_client
2010-12-28 19:44:48 +05:30

36 lines
1 KiB
Python
Executable file

#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# GPL 2008
import os
import sys
from optparse import OptionParser
root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
if os.path.exists(os.path.join(root, 'pandora_client')):
sys.path.insert(0, root)
import pandora_client
if __name__ == '__main__':
usage = "usage: %prog [options] action"
parser = OptionParser(usage=usage)
parser.add_option('-c', '--config', dest='config', help='config.json containing config', default='~/.ox/client.json', type='string')
(opts, args) = parser.parse_args()
opts.config = os.path.expanduser(opts.config)
if None in (opts.config, ) or not os.path.exists(opts.config):
parser.print_help()
sys.exit()
actions = ('scan', 'extract', 'sync', 'clean')
if not args or args[0] not in actions:
parser.error('you must specify a valid action. \n\t\tknown actions are: %s' % ', '.join(actions))
action = args[0]
c = pandora_client.Client(opts.config)
getattr(c, action)()