summaryrefslogtreecommitdiffstats
path: root/pykolab/setup/components.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-20 17:48:41 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-20 17:48:41 +0100
commit796413f66f681d6735245f99fcb2c7c082f749de (patch)
treea22f509d85982a3a95b7f734ea04929b8726b7e5 /pykolab/setup/components.py
parent812920a2077860091bd003956fdf4296d187b329 (diff)
downloadpykolab-796413f66f681d6735245f99fcb2c7c082f749de.tar.gz
Implement a version of setup-kolab.py around 389 Directory Server
Diffstat (limited to 'pykolab/setup/components.py')
-rw-r--r--pykolab/setup/components.py45
1 files changed, 42 insertions, 3 deletions
diff --git a/pykolab/setup/components.py b/pykolab/setup/components.py
index d17a357..bef460e 100644
--- a/pykolab/setup/components.py
+++ b/pykolab/setup/components.py
@@ -50,9 +50,9 @@ def __init__():
for dirname in dirnames:
register_group(components_path, dirname)
- register('help', list_setup, description=_("Display this help."))
+ register('help', list_components, description=_("Display this help."))
-def list_setup(*args, **kw):
+def list_components(*args, **kw):
"""
List components
"""
@@ -91,7 +91,41 @@ def list_setup(*args, **kw):
else:
print "%-4s%-21s" % ('',__component.replace('_','-'))
+def _list_components(*args, **kw):
+ """
+ List components and return API compatible, parseable lists and
+ dictionaries.
+ """
+
+ __components = {}
+
+ for component in components.keys():
+ if isinstance(component, tuple):
+ component_group, component = component
+ __components[component_group] = {
+ component: components[(component_group,component)]
+ }
+ else:
+ __components[component] = components[component]
+
+ _components = __components.keys()
+ _components.sort()
+
+ return _components
+
def execute(component_name, *args, **kw):
+ if component_name == '':
+ log.debug(
+ _("No component selected, continuing for all components"),
+ level=8
+ )
+
+ for component in _list_components():
+ if not component == 'help':
+ execute(component)
+
+ return
+
if not components.has_key(component_name):
log.error(_("No such component."))
sys.exit(1)
@@ -118,7 +152,12 @@ def execute(component_name, *args, **kw):
pass
conf.finalize_conf()
- _component_name = conf.cli_args.pop(0)
+
+ if len(conf.cli_args) >= 1:
+ _component_name = conf.cli_args.pop(0)
+ else:
+ _component_name = component_name
+
components[component_name]['function'](conf.cli_args, kw)
def register_group(dirname, module):