fail if path does not exist, cleanup config output

This commit is contained in:
j 2014-03-21 13:40:02 +01:00
parent eb448a31d8
commit 235f5672eb

View file

@ -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 = {}