Merge "Explicit execute arguments"
This commit is contained in:
commit
930d456b18
@ -64,34 +64,28 @@ VALID_ROOT_DEVICE_HINTS = {
|
||||
ROOT_DEVICE_HINTS_GRAMMAR = specs_matcher.make_grammar()
|
||||
|
||||
|
||||
def execute(*cmd, **kwargs):
|
||||
def execute(*cmd, use_standard_locale=False, log_stdout=True, **kwargs):
|
||||
"""Convenience wrapper around oslo's execute() method.
|
||||
|
||||
Executes and logs results from a system command. See docs for
|
||||
oslo_concurrency.processutils.execute for usage.
|
||||
|
||||
:param cmd: positional arguments to pass to processutils.execute()
|
||||
:param use_standard_locale: keyword-only argument. True | False.
|
||||
Defaults to False. If set to True,
|
||||
:param use_standard_locale: Defaults to False. If set to True,
|
||||
execute command with standard locale
|
||||
added to environment variables.
|
||||
:param log_stdout: keyword-only argument. True | False. Defaults
|
||||
to True. If set to True, logs the output.
|
||||
:param log_stdout: Defaults to True. If set to True, logs the output.
|
||||
:param kwargs: keyword arguments to pass to processutils.execute()
|
||||
:returns: (stdout, stderr) from process execution
|
||||
:raises: UnknownArgumentError on receiving unknown arguments
|
||||
:raises: ProcessExecutionError
|
||||
:raises: OSError
|
||||
"""
|
||||
|
||||
use_standard_locale = kwargs.pop('use_standard_locale', False)
|
||||
if use_standard_locale:
|
||||
env = kwargs.pop('env_variables', os.environ.copy())
|
||||
env['LC_ALL'] = 'C'
|
||||
kwargs['env_variables'] = env
|
||||
|
||||
log_stdout = kwargs.pop('log_stdout', True)
|
||||
|
||||
# If root_helper config is not specified, no commands are run as root.
|
||||
run_as_root = kwargs.get('run_as_root', False)
|
||||
if run_as_root:
|
||||
|
Loading…
Reference in New Issue
Block a user