From 235f5672eb64ffcb0b5be5654e2ea8d957edcd0c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 21 Mar 2014 13:40:02 +0100 Subject: [PATCH] fail if path does not exist, cleanup config output --- pandora_client/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index ee11c5a..eb420fd 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -408,7 +408,7 @@ class Client(object): json.dump(self._config, f, indent=2) def config(self, args): - print "Current Config:\n User %s\n URL:%s\n" %(self._config['username'], self._config['url']) + print "Current Config:\n User: %s\n URL: %s\n" %(self._config['username'], self._config['url']) print "Leave empty to keep current value\n" username = raw_input('Username: ') if username: @@ -444,11 +444,12 @@ class Client(object): os.chmod(path, 0755) def add_volume(self, args): + usage = "Usage: %s add_volume name path" % sys.argv[0] if len(args) != 2: - print "Usage: %s add_volume name path" % sys.argv[0] + print usage sys.exit(1) name = args[0] - path = args[1] + path = os.path.abspath(args[1]) if not path.endswith('/'): path += '/' if os.path.isdir(path): @@ -458,8 +459,10 @@ class Client(object): print "added %s %s" % (name, path) self._config['volumes'][name] = path self.save_config() - - self._config['volumes'][name] = path + else: + print "'%s' does not exist" % path + print usage + sys.exit(1) def active_volumes(self): volumes = {}