Remove `processutils` dependency on `log`
Currently, the processutils module depends on openstack.common.log. This patch proposes to remove this dependency and use the standard library logging module instead. The downside of this patch is that it removes the dependency on the log module but adds a new dependency on the strutils module because of the `mask_password` call. Change-Id: I245750f9f397a231891514f6ed1ea9626513cbbb
This commit is contained in:
parent
5c274c0fa6
commit
5a337a6e36
|
@ -18,7 +18,7 @@ System-level utilities and helper functions.
|
|||
"""
|
||||
|
||||
import errno
|
||||
import logging as stdlib_logging
|
||||
import logging
|
||||
import multiprocessing
|
||||
import os
|
||||
import random
|
||||
|
@ -30,7 +30,7 @@ from eventlet import greenthread
|
|||
import six
|
||||
|
||||
from openstack.common.gettextutils import _
|
||||
from openstack.common import log as logging
|
||||
from openstack.common import strutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -115,8 +115,7 @@ def execute(*cmd, **kwargs):
|
|||
execute this command. Defaults to false.
|
||||
:type shell: boolean
|
||||
:param loglevel: log level for execute commands.
|
||||
:type loglevel: int. (Should be stdlib_logging.DEBUG or
|
||||
stdlib_logging.INFO)
|
||||
:type loglevel: int. (Should be logging.DEBUG or logging.INFO)
|
||||
:returns: (stdout, stderr) from process execution
|
||||
:raises: :class:`UnknownArgumentError` on
|
||||
receiving unknown arguments
|
||||
|
@ -132,7 +131,7 @@ def execute(*cmd, **kwargs):
|
|||
run_as_root = kwargs.pop('run_as_root', False)
|
||||
root_helper = kwargs.pop('root_helper', '')
|
||||
shell = kwargs.pop('shell', False)
|
||||
loglevel = kwargs.pop('loglevel', stdlib_logging.DEBUG)
|
||||
loglevel = kwargs.pop('loglevel', logging.DEBUG)
|
||||
|
||||
if isinstance(check_exit_code, bool):
|
||||
ignore_exit_code = not check_exit_code
|
||||
|
@ -157,7 +156,7 @@ def execute(*cmd, **kwargs):
|
|||
attempts -= 1
|
||||
try:
|
||||
LOG.log(loglevel, 'Running cmd (subprocess): %s',
|
||||
logging.mask_password(' '.join(cmd)))
|
||||
strutils.mask_password(' '.join(cmd)))
|
||||
_PIPE = subprocess.PIPE # pylint: disable=E1101
|
||||
|
||||
if os.name == 'nt':
|
||||
|
|
Loading…
Reference in New Issue