From bd57f5b86f0d13a1f9c3a678967527a488793c15 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 28 Apr 2013 23:11:10 +0200 Subject: [PATCH] better error messages --- bin/pandora_client | 8 +++++++- pandora_client/__init__.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/pandora_client b/bin/pandora_client index 39e9bf3..56a52f6 100755 --- a/bin/pandora_client +++ b/bin/pandora_client @@ -25,7 +25,11 @@ if __name__ == '__main__': (opts, args) = parser.parse_args() opts.config = os.path.expanduser(opts.config) - if None in (opts.config, ) or (args and args[0] != 'config' and not os.path.exists(opts.config)): + if (args and args[0] not in ('config', 'client') and not os.path.exists(opts.config)): + print 'no configuration found, run "%s config" or specify one with -c' % sys.argv[0] + sys.exit(1) + + if None in (opts.config, ): parser.print_help() sys.exit() @@ -42,6 +46,8 @@ for more information visit https://wiki.0x2620.org/wiki/pandora_client''' % ', ' action = args[0] offline = action in config or action == 'client' + if action == 'client': + opts.config = {'url': '', 'cache': '~/.ox/client.sqlite', 'media-cache': '~/.ox/media'} if action == 'config': if not os.path.exists(opts.config): with open(opts.config, 'w') as f: diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 02d5337..8058b46 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -711,7 +711,7 @@ class Client(object): def client(self, args): if not args: - print 'you must pass url to server(i.e. http://192.168.1.1:8789)' + print 'usage: %s client \n\ti.e. %s client http://192.168.1.1:8789' % (sys.argv[0], sys.argv[0]) sys.exit(1) import client url = args[0]