mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Fix pylint errors and warnings
This commit is contained in:
parent
fdf66e25f1
commit
88716a29d2
@ -13,6 +13,7 @@ from __future__ import absolute_import
|
||||
# Import python libs
|
||||
import logging
|
||||
import glob
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
# Import 3rd-party libs
|
||||
@ -248,7 +249,7 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -13,6 +13,8 @@ from __future__ import absolute_import
|
||||
# Import python libs
|
||||
import logging
|
||||
import os
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
@ -499,7 +501,7 @@ def status(name, sig=None, jail=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -13,6 +13,8 @@ to the correct service manager
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.systemd
|
||||
@ -260,7 +262,7 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
@ -274,8 +276,6 @@ def status(name, sig=None):
|
||||
return results[name]
|
||||
|
||||
|
||||
|
||||
|
||||
def enable(name, **kwargs):
|
||||
'''
|
||||
Enable the named service to start at boot
|
||||
|
@ -17,6 +17,7 @@ from distutils.version import LooseVersion # pylint: disable=no-name-in-module
|
||||
import logging
|
||||
import os
|
||||
import plistlib
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
@ -230,7 +231,7 @@ def status(name, runas=None):
|
||||
salt '*' service.status <service name>
|
||||
'''
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -13,6 +13,8 @@ from __future__ import absolute_import
|
||||
# Import python libs
|
||||
import os
|
||||
import glob
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
__func_alias__ = {
|
||||
'reload_': 'reload'
|
||||
@ -127,7 +129,7 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -12,6 +12,8 @@ The service module for OpenBSD
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import re
|
||||
import fnmatch
|
||||
import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
@ -117,7 +119,7 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -7,6 +7,8 @@ from __future__ import absolute_import
|
||||
import salt.utils
|
||||
|
||||
import logging
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -140,7 +142,7 @@ def status(name, sig=None):
|
||||
'''
|
||||
|
||||
proxy_fn = 'rest_sample.service_status'
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -36,7 +36,7 @@ if salt.utils.which('initctl'):
|
||||
try:
|
||||
# Don't re-invent the wheel, import the helper functions from the
|
||||
# upstart module.
|
||||
from salt.modules.upstart \
|
||||
from salt.modules.upstart
|
||||
import _upstart_enable, _upstart_disable, _upstart_is_enabled
|
||||
except Exception as exc:
|
||||
log.error('Unable to import helper functions from '
|
||||
@ -496,7 +496,7 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -6,6 +6,8 @@ from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
__func_alias__ = {
|
||||
'reload_': 'reload'
|
||||
@ -158,7 +160,7 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return __salt__['status.pid'](sig)
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -12,6 +12,8 @@ that use SMF also. (e.g. SmartOS)
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
__func_alias__ = {
|
||||
'reload_': 'reload'
|
||||
@ -247,7 +249,7 @@ def status(name, sig=None):
|
||||
|
||||
salt '*' service.status <service name>
|
||||
'''
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
@ -256,7 +258,7 @@ def status(name, sig=None):
|
||||
for service in services:
|
||||
cmd = '/usr/bin/svcs -H -o STATE {0}'.format(service)
|
||||
line = __salt__['cmd.run'](cmd, python_shell=False)
|
||||
results[service] = line == 'online':
|
||||
results[service] = line == 'online'
|
||||
if contains_globbing:
|
||||
return results
|
||||
return results[name]
|
||||
|
@ -7,6 +7,8 @@ Provide the service module for the proxy-minion SSH sample
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
import salt.utils
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -126,7 +128,7 @@ def status(name, sig=None):
|
||||
'''
|
||||
|
||||
proxy_fn = 'ssh_sample.service_status'
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -17,6 +17,7 @@ import errno
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
import fnmatch
|
||||
import re
|
||||
import shlex
|
||||
|
||||
@ -897,7 +898,7 @@ def status(name, sig=None): # pylint: disable=unused-argument
|
||||
|
||||
salt '*' service.status <service name> [service signature]
|
||||
'''
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
|
@ -450,7 +450,7 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(get_all(), name)
|
||||
else:
|
||||
@ -462,12 +462,13 @@ def status(name, sig=None):
|
||||
# decide result base on cmd output, thus ignore retcode,
|
||||
# which makes cmd output not at error lvl even when cmd fail.
|
||||
results[service] = 'start/running' in __salt__['cmd.run'](cmd, python_shell=False,
|
||||
ignore_retcode=True)
|
||||
ignore_retcode=True)
|
||||
else:
|
||||
# decide result base on retcode, thus ignore output (set quite)
|
||||
# because there is no way to avoid logging at error lvl when
|
||||
# service is not running - retcode != 0 (which is totally relevant).
|
||||
results[service] = not bool(__salt__['cmd.retcode'](cmd, python_shell=False,
|
||||
ignore_retcode=True)
|
||||
if contains_globbing:
|
||||
return results
|
||||
return results[name]
|
||||
|
@ -519,7 +519,7 @@ def execute_salt_restart_task():
|
||||
return __salt__['task.run'](name='restart-salt-minion')
|
||||
|
||||
|
||||
def status(name, sig = None):
|
||||
def status(name, sig=None):
|
||||
'''
|
||||
Return the status for a service.
|
||||
If the name contains globbing, a dict mapping service name to True/False
|
||||
@ -545,7 +545,7 @@ def status(name, sig = None):
|
||||
|
||||
results = {}
|
||||
all_services = get_all()
|
||||
contains_globbing = bool(re.search('\*|\?|\[.+\]', name))
|
||||
contains_globbing = bool(re.search(r'\*|\?|\[.+\]', name))
|
||||
if contains_globbing:
|
||||
services = fnmatch.filter(all_services, name)
|
||||
else:
|
||||
@ -556,6 +556,7 @@ def status(name, sig = None):
|
||||
return results
|
||||
return results[name]
|
||||
|
||||
|
||||
def getsid(name):
|
||||
'''
|
||||
Return the SID for this windows service
|
||||
|
Loading…
Reference in New Issue
Block a user