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
|
||||
# ask for params non-specified on command-line arguments
|
||||
module = self.weboob.modules_loader.get_or_load_module(name)
|
||||
asked_config = False
|
||||
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:
|
||||
masked = key == 'password'
|
||||
params[key] = self.ask(key, default=u'', masked=masked)
|
||||
params[key] = self.ask(' [%s] %s' % (key, value.description),
|
||||
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:
|
||||
self.weboob.backends_config.add_backend(name, name, params)
|
||||
|
|
@ -125,7 +136,7 @@ class WeboobCfg(ConsoleApplication):
|
|||
name, self.weboob.backends_config.confpath)
|
||||
except ConfigParser.DuplicateSectionError:
|
||||
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':
|
||||
while True:
|
||||
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)
|
||||
break
|
||||
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')
|
||||
def command_list(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue