better error messages

This commit is contained in:
j 2013-04-28 23:11:10 +02:00
parent 888599e7e2
commit bd57f5b86f
2 changed files with 8 additions and 2 deletions

View file

@ -25,7 +25,11 @@ if __name__ == '__main__':
(opts, args) = parser.parse_args() (opts, args) = parser.parse_args()
opts.config = os.path.expanduser(opts.config) 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() parser.print_help()
sys.exit() sys.exit()
@ -42,6 +46,8 @@ for more information visit https://wiki.0x2620.org/wiki/pandora_client''' % ', '
action = args[0] action = args[0]
offline = action in config or action == 'client' 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 action == 'config':
if not os.path.exists(opts.config): if not os.path.exists(opts.config):
with open(opts.config, 'w') as f: with open(opts.config, 'w') as f:

View file

@ -711,7 +711,7 @@ class Client(object):
def client(self, args): def client(self, args):
if not args: if not args:
print 'you must pass url to server(i.e. http://192.168.1.1:8789)' print 'usage: %s client <server_url>\n\ti.e. %s client http://192.168.1.1:8789' % (sys.argv[0], sys.argv[0])
sys.exit(1) sys.exit(1)
import client import client
url = args[0] url = args[0]