reorganization order of commands and rename 'configured' to 'listconfigured'
This commit is contained in:
parent
26c9598b28
commit
8c9bf2a38d
1 changed files with 34 additions and 32 deletions
|
|
@ -100,17 +100,27 @@ class WeboobCfg(ConsoleApplication):
|
||||||
except ConfigParser.DuplicateSectionError:
|
except ConfigParser.DuplicateSectionError:
|
||||||
print u'Instance "%s" already exists for backend "%s".' % (new_name, name)
|
print u'Instance "%s" already exists for backend "%s".' % (new_name, name)
|
||||||
|
|
||||||
@ConsoleApplication.command('Show applications')
|
@ConsoleApplication.command('Show configured backends')
|
||||||
def command_applications(self, *caps):
|
def command_listconfigured(self):
|
||||||
applications = set()
|
self.set_default_formatter('table')
|
||||||
import weboob.applications
|
for instance_name, name, params in sorted(self.weboob.backends_config.iter_backends()):
|
||||||
for path in weboob.applications.__path__:
|
row = OrderedDict([('Instance name', instance_name),
|
||||||
regexp = re.compile('^%s/([\w\d_]+)$' % path)
|
('Backend name', name),
|
||||||
for root, dirs, files in os.walk(path):
|
('Configuration', ', '.join('%s=%s' % (key, value) for key, value in params.iteritems())),
|
||||||
m = regexp.match(root)
|
])
|
||||||
if m and '__init__.py' in files:
|
self.format(row)
|
||||||
applications.add(m.group(1))
|
|
||||||
print ' '.join(sorted(applications)).encode('utf-8')
|
@ConsoleApplication.command('Remove a configured backend')
|
||||||
|
def command_remove(self, instance_name):
|
||||||
|
try:
|
||||||
|
self.weboob.backends_config.remove_backend(instance_name)
|
||||||
|
except ConfigParser.NoSectionError:
|
||||||
|
logging.error('Backend instance "%s" does not exist' % instance_name)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
@ConsoleApplication.command('Edit configuration file')
|
||||||
|
def command_edit(self):
|
||||||
|
subprocess.call([os.environ.get('EDITOR', 'vi'), self.weboob.backends_config.confpath])
|
||||||
|
|
||||||
@ConsoleApplication.command('Show available backends')
|
@ConsoleApplication.command('Show available backends')
|
||||||
def command_backends(self, *caps):
|
def command_backends(self, *caps):
|
||||||
|
|
@ -125,20 +135,6 @@ class WeboobCfg(ConsoleApplication):
|
||||||
])
|
])
|
||||||
self.format(row)
|
self.format(row)
|
||||||
|
|
||||||
@ConsoleApplication.command('Show configured backends')
|
|
||||||
def command_configured(self):
|
|
||||||
self.set_default_formatter('table')
|
|
||||||
for instance_name, name, params in sorted(self.weboob.backends_config.iter_backends()):
|
|
||||||
row = OrderedDict([('Instance name', instance_name),
|
|
||||||
('Backend name', name),
|
|
||||||
('Configuration', ', '.join('%s=%s' % (key, value) for key, value in params.iteritems())),
|
|
||||||
])
|
|
||||||
self.format(row)
|
|
||||||
|
|
||||||
@ConsoleApplication.command('Edit configuration file')
|
|
||||||
def command_edit(self):
|
|
||||||
subprocess.call([os.environ.get('EDITOR', 'vi'), self.weboob.backends_config.confpath])
|
|
||||||
|
|
||||||
@ConsoleApplication.command('Display information about a backend')
|
@ConsoleApplication.command('Display information about a backend')
|
||||||
def command_info(self, name):
|
def command_info(self, name):
|
||||||
try:
|
try:
|
||||||
|
|
@ -168,10 +164,16 @@ class WeboobCfg(ConsoleApplication):
|
||||||
print '| | %s: %s' % (key, value)
|
print '| | %s: %s' % (key, value)
|
||||||
print "'-----------------'"
|
print "'-----------------'"
|
||||||
|
|
||||||
@ConsoleApplication.command('Remove a configured backend')
|
@ConsoleApplication.command('Show applications')
|
||||||
def command_remove(self, instance_name):
|
def command_applications(self, *caps):
|
||||||
try:
|
applications = set()
|
||||||
self.weboob.backends_config.remove_backend(instance_name)
|
import weboob.applications
|
||||||
except ConfigParser.NoSectionError:
|
for path in weboob.applications.__path__:
|
||||||
logging.error('Backend instance "%s" does not exist' % instance_name)
|
regexp = re.compile('^%s/([\w\d_]+)$' % path)
|
||||||
return 1
|
for root, dirs, files in os.walk(path):
|
||||||
|
m = regexp.match(root)
|
||||||
|
if m and '__init__.py' in files:
|
||||||
|
applications.add(m.group(1))
|
||||||
|
print ' '.join(sorted(applications)).encode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue