correctly ask configuration to user
This commit is contained in:
parent
d05b828bd4
commit
02cbf9a202
1 changed files with 18 additions and 7 deletions
|
|
@ -113,10 +113,21 @@ class WeboobCfg(ConsoleApplication):
|
||||||
params[key] = value
|
params[key] = value
|
||||||
# ask for params non-specified on command-line arguments
|
# ask for params non-specified on command-line arguments
|
||||||
module = self.weboob.modules_loader.get_or_load_module(name)
|
module = self.weboob.modules_loader.get_or_load_module(name)
|
||||||
|
asked_config = False
|
||||||
for key, value in module.get_config().iteritems():
|
for key, value in module.get_config().iteritems():
|
||||||
|
if not asked_config:
|
||||||
|
asked_config = True
|
||||||
|
print u'Configuration of backend'
|
||||||
|
print u'------------------------'
|
||||||
if key not in params:
|
if key not in params:
|
||||||
masked = key == 'password'
|
params[key] = self.ask(' [%s] %s' % (key, value.description),
|
||||||
params[key] = self.ask(key, default=u'', masked=masked)
|
default=value.default,
|
||||||
|
masked=value.is_masked,
|
||||||
|
regexp=value.regexp)
|
||||||
|
else:
|
||||||
|
print u' [%s] %s: %s' % (key, value.description, '(masked)' if value.is_masked else params[key])
|
||||||
|
if asked_config:
|
||||||
|
print u'------------------------'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.weboob.backends_config.add_backend(name, name, params)
|
self.weboob.backends_config.add_backend(name, name, params)
|
||||||
|
|
@ -125,7 +136,7 @@ class WeboobCfg(ConsoleApplication):
|
||||||
name, self.weboob.backends_config.confpath)
|
name, self.weboob.backends_config.confpath)
|
||||||
except ConfigParser.DuplicateSectionError:
|
except ConfigParser.DuplicateSectionError:
|
||||||
print u'Backend "%s" is already configured in file "%s"' % (name, self.weboob.backends_config.confpath)
|
print u'Backend "%s" is already configured in file "%s"' % (name, self.weboob.backends_config.confpath)
|
||||||
response = raw_input(u'Add new instance of "%s" backend ? [yN] ' % name)
|
response = raw_input(u'Add new instance of "%s" backend? [yN] ' % name)
|
||||||
if response.lower() == 'y':
|
if response.lower() == 'y':
|
||||||
while True:
|
while True:
|
||||||
new_name = raw_input(u'Please give new instance name (could be "%s_1"): ' % name)
|
new_name = raw_input(u'Please give new instance name (could be "%s_1"): ' % name)
|
||||||
|
|
@ -138,7 +149,7 @@ class WeboobCfg(ConsoleApplication):
|
||||||
name, self.weboob.backends_config.confpath)
|
name, self.weboob.backends_config.confpath)
|
||||||
break
|
break
|
||||||
except ConfigParser.DuplicateSectionError:
|
except ConfigParser.DuplicateSectionError:
|
||||||
print u'Instance "%s" is already configured for backend "%s".' % (new_name, name)
|
print u'Instance "%s" already exists for backend "%s".' % (new_name, name)
|
||||||
|
|
||||||
@ConsoleApplication.command('List backends')
|
@ConsoleApplication.command('List backends')
|
||||||
def command_list(self):
|
def command_list(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue