summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 8f42c6304..fe09d3a6b 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -456,7 +456,7 @@ class API(DictProxy):
def isdone(self, name):
return name in self.__done
- def bootstrap(self, **overrides):
+ def bootstrap(self, parser=None, **overrides):
"""
Initialize environment variables and logging.
"""
@@ -516,6 +516,10 @@ class API(DictProxy):
log.error('Cannot open log file %r: %s', self.env.log, e)
return
+ if not parser:
+ parser = self.build_global_parser()
+ object.__setattr__(self, 'parser', parser)
+
def build_global_parser(self, parser=None, context=None):
"""
Add global options to an optparse.OptionParser instance.
@@ -592,8 +596,7 @@ class API(DictProxy):
overrides['webui_prod'] = options.prod
if context is not None:
overrides['context'] = context
- self.bootstrap(**overrides)
- object.__setattr__(self, 'parser', parser)
+ self.bootstrap(parser, **overrides)
return (options, args)
def load_plugins(self):