Commit 84191b93 authored by Xavier Thompson's avatar Xavier Thompson

slapformat: WIP: Rename raise_on_error into throw

parent ccd58b6a
...@@ -482,7 +482,7 @@ class User(object): ...@@ -482,7 +482,7 @@ class User(object):
parameters.append(self.name) parameters.append(self.name)
if self.userExists(self.name): if self.userExists(self.name):
# if the user is already created and used we should not fail # if the user is already created and used we should not fail
call(['usermod'] + parameters, raise_on_error=False) call(['usermod'] + parameters, throw=False)
else: else:
parameters.append('-r') parameters.append('-r')
call(['useradd'] + parameters) call(['useradd'] + parameters)
...@@ -512,7 +512,7 @@ class User(object): ...@@ -512,7 +512,7 @@ class User(object):
# Utilities # Utilities
def call(args, raise_on_error=True): def call(args, throw=True):
popen = subprocess.Popen( popen = subprocess.Popen(
args, args,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
...@@ -520,7 +520,7 @@ def call(args, raise_on_error=True): ...@@ -520,7 +520,7 @@ def call(args, raise_on_error=True):
universal_newlines=True, universal_newlines=True,
) )
result = popen.communicate()[0] result = popen.communicate()[0]
if raise_on_error and popen.returncode != 0: if throw and popen.returncode != 0:
raise ValueError( raise ValueError(
"Issue while invoking %r, result was:\n%s" % (args, result) "Issue while invoking %r, result was:\n%s" % (args, result)
) )
...@@ -591,17 +591,17 @@ class WrappedSystem(object): ...@@ -591,17 +591,17 @@ class WrappedSystem(object):
) )
if conf.dry_run: if conf.dry_run:
conf.abort = conf.dryError conf.abort = conf.dryError
def dry_call(args, raise_on_error=True): def dry_call(args, throw=True):
conf.logger.debug(' '.join(args)) conf.logger.debug(' '.join(args))
it = iter(args) it = iter(args)
if all(w in it for w in ('ip', 'addr', 'show')): # subsequence test if all(w in it for w in ('ip', 'addr', 'show')): # subsequence test
return self.call(args, raise_on_error=False) return self.call(args, throw=False)
return 0, '' return 0, ''
call = dry_call call = dry_call
else: else:
def tracing_call(args, raise_on_error=True): def tracing_call(args, throw=True):
conf.logger.debug(' '.join(args)) conf.logger.debug(' '.join(args))
return self.call(args, raise_on_error) return self.call(args, throw)
call = tracing_call call = tracing_call
def __exit__(self, *exc): def __exit__(self, *exc):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment