More work on xmlrpc stuff, started migrated more code to use errors2 instead of errors

This commit is contained in:
Jason Gerard DeRose
2009-01-22 18:48:21 -07:00
committed by Rob Crittenden
parent 833088955c
commit 244346dbcb
8 changed files with 55 additions and 22 deletions

View File

@@ -97,17 +97,28 @@ class Command(plugable.Plugin):
XML-RPC and the executed an the nearest IPA server.
"""
params = self.args_options_2_params(*args, **options)
self.info(
'%s(%s)', self.name, ', '.join(self.__repr_iter(params))
)
params = self.normalize(**params)
params = self.convert(**params)
params.update(self.get_default(**params))
self.validate(**params)
(args, options) = self.params_2_args_options(**params)
# FIXME: don't log passords!
self.info(make_repr(self.name, *args, **options))
result = self.run(*args, **options)
self.debug('%s result: %r', self.name, result)
self.debug('result from %s(): %r', self.name, result)
return result
def __repr_iter(self, params):
for arg in self.args():
value = params.get(arg.name, None)
yield '%r' % (arg.safe_value(value),)
for option in self.options():
if option.name not in params:
continue
value = params[option.name]
yield '%s=%r' % (option.name, option.safe_value(value))
def args_options_2_params(self, *args, **options):
"""
Merge (args, options) into params.
@@ -245,10 +256,7 @@ class Command(plugable.Plugin):
"""
for param in self.params():
value = kw.get(param.name, None)
if value is not None:
param.validate(value)
elif param.required:
raise errors.RequirementError(param.name)
param.validate(value)
def run(self, *args, **options):
"""