Update pre-commit hook versions

This commit is contained in:
Pedro Algarvio 2024-02-27 10:24:22 +00:00
parent 0d6d4cfb36
commit 3dea2eb541
1226 changed files with 2974 additions and 3131 deletions

View file

@ -6,7 +6,7 @@ exclude: ^(doc/_static/.*|doc/_themes/.*)$
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: check-merge-conflict # Check for files that contain merge conflict strings. - id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: trailing-whitespace # Trims trailing whitespace. - id: trailing-whitespace # Trims trailing whitespace.
@ -1622,7 +1622,7 @@ repos:
# ----- Code Formatting -------------------------------------------------------------------------------------------> # ----- Code Formatting ------------------------------------------------------------------------------------------->
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.37.2 rev: v3.15.1
hooks: hooks:
- id: pyupgrade - id: pyupgrade
name: Drop six usage and Py2 support name: Drop six usage and Py2 support
@ -1643,7 +1643,7 @@ repos:
- repo: https://github.com/saltstack/salt-rewrite - repo: https://github.com/saltstack/salt-rewrite
# Automatically rewrite code with known rules # Automatically rewrite code with known rules
rev: 2.4.4 rev: 2.5.2
hooks: hooks:
- id: salt-rewrite - id: salt-rewrite
alias: rewrite-docstrings alias: rewrite-docstrings
@ -1662,7 +1662,7 @@ repos:
args: [--silent, -E, fix_asserts, -E, fix_docstrings] args: [--silent, -E, fix_asserts, -E, fix_docstrings]
- repo: https://github.com/timothycrosley/isort - repo: https://github.com/timothycrosley/isort
rev: 5.12.0 rev: 5.13.2
hooks: hooks:
- id: isort - id: isort
additional_dependencies: ['toml'] additional_dependencies: ['toml']
@ -1675,31 +1675,32 @@ repos:
)$ )$
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.6.0 rev: 24.2.0
hooks: hooks:
- id: black - id: black
# This tells pre-commit not to pass files to black. # This tells pre-commit not to pass files to black.
# This should be kept in sync with pyproject.toml # This should be kept in sync with pyproject.toml
exclude: > exclude: >
(?x)^( (?x)^(
salt/client/ssh/ssh_py_shim\.py|
templates/.*| templates/.*|
salt/ext/.*| salt/ext/.*|
)$ )$
- repo: https://github.com/asottile/blacken-docs - repo: https://github.com/asottile/blacken-docs
rev: v1.12.1 rev: 1.16.0
hooks: hooks:
- id: blacken-docs - id: blacken-docs
args: [--skip-errors] args: [--skip-errors]
files: ^doc/.*\.rst files: ^doc/.*\.rst
additional_dependencies: additional_dependencies:
- black==22.6.0 - black==24.2.0
# <---- Code Formatting -------------------------------------------------------------------------------------------- # <---- Code Formatting --------------------------------------------------------------------------------------------
# ----- Security --------------------------------------------------------------------------------------------------> # ----- Security -------------------------------------------------------------------------------------------------->
- repo: https://github.com/PyCQA/bandit - repo: https://github.com/PyCQA/bandit
rev: "1.7.4" rev: "1.7.7"
hooks: hooks:
- id: bandit - id: bandit
alias: bandit-salt alias: bandit-salt
@ -1713,7 +1714,7 @@ repos:
)$ )$
additional_dependencies: ['importlib_metadata<5'] additional_dependencies: ['importlib_metadata<5']
- repo: https://github.com/PyCQA/bandit - repo: https://github.com/PyCQA/bandit
rev: "1.7.4" rev: "1.7.7"
hooks: hooks:
- id: bandit - id: bandit
alias: bandit-tests alias: bandit-tests
@ -1726,7 +1727,7 @@ repos:
# ----- Pre-Commit ------------------------------------------------------------------------------------------------> # ----- Pre-Commit ------------------------------------------------------------------------------------------------>
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0 rev: v1.8.0
hooks: hooks:
- id: mypy - id: mypy
alias: mypy-tools alias: mypy-tools
@ -1746,7 +1747,7 @@ repos:
- python-tools-scripts==0.20.0 - python-tools-scripts==0.20.0
- repo: https://github.com/saltstack/mirrors-nox - repo: https://github.com/saltstack/mirrors-nox
rev: v2021.6.12 rev: v2022.11.21
hooks: hooks:
- id: nox - id: nox
alias: lint-salt alias: lint-salt
@ -1766,7 +1767,7 @@ repos:
- pip>=20.2.4,<21.2 - pip>=20.2.4,<21.2
- repo: https://github.com/saltstack/mirrors-nox - repo: https://github.com/saltstack/mirrors-nox
rev: v2021.6.12 rev: v2022.11.21
hooks: hooks:
- id: nox - id: nox
alias: lint-tests alias: lint-tests

View file

@ -59,8 +59,7 @@ the ``execute`` function with the following signature:
.. code-block:: python .. code-block:: python
def execute(opts, data, func, args, kwargs): def execute(opts, data, func, args, kwargs): ...
...
Where the args are: Where the args are:

View file

@ -329,6 +329,7 @@ the case when the dependency is unavailable.
""" """
Cheese execution (or returner/beacon/etc.) module Cheese execution (or returner/beacon/etc.) module
""" """
try: try:
import enzymes import enzymes

View file

@ -364,8 +364,7 @@ the actual testing, such as functions containing assertions, must start with
.. code-block:: python .. code-block:: python
def test_user_present(self): def test_user_present(self): ...
...
When functions in test files are not prepended with ``test_``, the function When functions in test files are not prepended with ``test_``, the function
acts as a normal, helper function and is not run as a test by the test suite. acts as a normal, helper function and is not run as a test by the test suite.

View file

@ -581,7 +581,6 @@ and status; "package" installation, and a ping.
def uptodate(name): def uptodate(name):
""" """
Call the REST endpoint to see if the packages on the "server" are up to date. Call the REST endpoint to see if the packages on the "server" are up to date.
""" """
@ -592,7 +591,6 @@ and status; "package" installation, and a ping.
def package_remove(name): def package_remove(name):
""" """
Remove a "package" on the REST server Remove a "package" on the REST server
""" """

View file

@ -551,15 +551,13 @@ General Deprecations
.. code-block:: python .. code-block:: python
def fcn(msg="", env="base", refresh=True, saltenv="base", **kwargs): def fcn(msg="", env="base", refresh=True, saltenv="base", **kwargs): ...
...
has been changed to has been changed to
.. code-block:: python .. code-block:: python
def fcn(msg="", refresh=True, saltenv="base", **kwargs): def fcn(msg="", refresh=True, saltenv="base", **kwargs): ...
...
- If ``env`` (or ``__env__``) is supplied as a keyword argument to a function - If ``env`` (or ``__env__``) is supplied as a keyword argument to a function
that also accepts arbitrary keyword arguments, then a new warning informs the that also accepts arbitrary keyword arguments, then a new warning informs the
@ -568,8 +566,7 @@ General Deprecations
.. code-block:: python .. code-block:: python
def fcn(msg="", refresh=True, saltenv="base", **kwargs): def fcn(msg="", refresh=True, saltenv="base", **kwargs): ...
...
.. code-block:: python .. code-block:: python
@ -582,8 +579,7 @@ General Deprecations
.. code-block:: python .. code-block:: python
def fcn(msg="", refresh=True, saltenv="base"): def fcn(msg="", refresh=True, saltenv="base"): ...
...
.. code-block:: python .. code-block:: python
@ -597,8 +593,7 @@ General Deprecations
.. code-block:: python .. code-block:: python
def fcn(msg="", refresh=True, saltenv="base"): def fcn(msg="", refresh=True, saltenv="base"): ...
...
.. code-block:: python .. code-block:: python

View file

@ -4,6 +4,7 @@ noxfile
Nox configuration script Nox configuration script
""" """
# pylint: disable=resource-leakage,3rd-party-module-not-gated # pylint: disable=resource-leakage,3rd-party-module-not-gated
import contextlib import contextlib
@ -1712,7 +1713,7 @@ class Recompress:
d_targz = tempd.joinpath(targz.name) d_targz = tempd.joinpath(targz.name)
with tarfile.open(d_tar, "w|") as wfile: with tarfile.open(d_tar, "w|") as wfile:
with tarfile.open(targz, "r:gz") as rfile: with tarfile.open(targz, "r:gz") as rfile:
rfile.extractall(d_src) rfile.extractall(d_src) # nosec
extracted_dir = next(pathlib.Path(d_src).iterdir()) extracted_dir = next(pathlib.Path(d_src).iterdir())
for name in sorted(extracted_dir.rglob("*")): for name in sorted(extracted_dir.rglob("*")):
wfile.add( wfile.add(

View file

@ -7,13 +7,6 @@ import os
import sys import sys
import warnings import warnings
if sys.version_info < (3,): # pragma: no cover
sys.stderr.write(
"\n\nAfter the Sodium release, 3001, Salt no longer supports Python 2. Exiting.\n\n"
)
sys.stderr.flush()
USE_VENDORED_TORNADO = True USE_VENDORED_TORNADO = True

View file

@ -1,6 +1,7 @@
""" """
Salt compatibility code Salt compatibility code
""" """
# pylint: disable=unused-import # pylint: disable=unused-import
import sys import sys

View file

@ -9,6 +9,7 @@
The ``salt._logging`` package should be imported as soon as possible since salt tweaks The ``salt._logging`` package should be imported as soon as possible since salt tweaks
the python's logging system. the python's logging system.
""" """
from salt._logging.impl import ( from salt._logging.impl import (
DFLT_LOG_DATEFMT, DFLT_LOG_DATEFMT,
DFLT_LOG_DATEFMT_LOGFILE, DFLT_LOG_DATEFMT_LOGFILE,

View file

@ -46,7 +46,6 @@ indicated above, though the model DOES NOT have to be named
'SaltExternalAuthModel'. 'SaltExternalAuthModel'.
""" """
import logging import logging
import os import os
import sys import sys

View file

@ -94,7 +94,6 @@ When using ``htdigest`` the ``^realm`` must be set:
""" """
import logging import logging
import os import os

View file

@ -4,7 +4,6 @@ Provide authentication using OpenStack Keystone
:depends: - keystoneclient Python module :depends: - keystoneclient Python module
""" """
try: try:
from keystoneclient.exceptions import AuthorizationFailure, Unauthorized from keystoneclient.exceptions import AuthorizationFailure, Unauthorized
from keystoneclient.v2_0 import client from keystoneclient.v2_0 import client

View file

@ -3,6 +3,7 @@ Provide authentication using simple LDAP binds
:depends: - ldap Python module :depends: - ldap Python module
""" """
import itertools import itertools
import logging import logging

View file

@ -47,7 +47,6 @@ Enable MySQL authentication.
:depends: - MySQL-python Python module :depends: - MySQL-python Python module
""" """
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -22,7 +22,6 @@ structure of a user as above.
""" """
import logging import logging
import salt.utils.http import salt.utils.http

View file

@ -36,7 +36,6 @@ the API key will be updated on all the YubiCloud servers.
""" """
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -3,6 +3,7 @@ Beacon to emit adb device state changes for Android devices
.. versionadded:: 2016.3.0 .. versionadded:: 2016.3.0
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -5,6 +5,7 @@ Beacon to fire event when we notice a AIX user is locked due to many failed logi
:depends: none :depends: none
""" """
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,6 +1,7 @@
""" """
Beacon to announce via Bonjour (zeroconf) Beacon to announce via Bonjour (zeroconf)
""" """
import atexit import atexit
import logging import logging
import select import select

View file

@ -7,6 +7,7 @@ Beacon to monitor certificate expiration dates from files on the filesystem.
:maturity: new :maturity: new
:depends: OpenSSL :depends: OpenSSL
""" """
import logging import logging
from datetime import datetime from datetime import datetime

View file

@ -5,6 +5,7 @@ Beacon to monitor disk usage.
:depends: python-psutil :depends: python-psutil
""" """
import logging import logging
import re import re

View file

@ -3,6 +3,7 @@ Beacon to emit when a display is available to a linux machine
.. versionadded:: 2016.3.0 .. versionadded:: 2016.3.0
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -4,6 +4,7 @@ Fire an event when over a specified threshold.
.. versionadded:: 2016.11.0 .. versionadded:: 2016.11.0
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -1,6 +1,7 @@
""" """
A simple beacon to watch journald for specific entries A simple beacon to watch journald for specific entries
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -1,6 +1,7 @@
""" """
Beacon to emit system load averages Beacon to emit system load averages
""" """
import logging import logging
import os import os

View file

@ -4,6 +4,7 @@ Beacon to fire events at specific log messages.
.. versionadded:: 2017.7.0 .. versionadded:: 2017.7.0
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -5,6 +5,7 @@ Beacon to monitor memory usage.
:depends: python-psutil :depends: python-psutil
""" """
import logging import logging
import re import re

View file

@ -3,6 +3,7 @@ Beacon to monitor statistics from ethernet adapters
.. versionadded:: 2015.5.0 .. versionadded:: 2015.5.0
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -3,6 +3,7 @@ Watch for pkgs that have upgrades, then fire an event.
.. versionadded:: 2016.3.0 .. versionadded:: 2016.3.0
""" """
import logging import logging
__virtualname__ = "pkg" __virtualname__ = "pkg"

View file

@ -7,6 +7,7 @@ Example beacon to use with salt-proxy
proxy_example: proxy_example:
endpoint: beacon endpoint: beacon
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -1,6 +1,7 @@
""" """
Send events covering process status Send events covering process status
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -24,6 +24,7 @@ See example config below.
- test.ping - test.ping
- interval: 3600 # seconds - interval: 3600 # seconds
""" """
import salt.utils.beacons import salt.utils.beacons

View file

@ -4,6 +4,7 @@
.. versionadded:: 2015.8.3 .. versionadded:: 2015.8.3
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -8,6 +8,7 @@ Monitor temperature, humidity and pressure using the SenseHat of a Raspberry Pi
:maturity: new :maturity: new
:depends: sense_hat Python module :depends: sense_hat Python module
""" """
import logging import logging
import re import re

View file

@ -1,6 +1,7 @@
""" """
Send events covering service status Send events covering service status
""" """
import logging import logging
import os import os
import time import time

View file

@ -1,6 +1,7 @@
""" """
Watch the shell commands being executed actively. This beacon requires strace. Watch the shell commands being executed actively. This beacon requires strace.
""" """
import logging import logging
import time import time

View file

@ -17,6 +17,7 @@ Beacon that fires events on image import/delete.
- interval: 60 - interval: 60
- startup_import_event: True - startup_import_event: True
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -17,6 +17,7 @@ Beacon that fires events on vm state changes
- interval: 60 - interval: 60
- startup_create_event: True - startup_create_event: True
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -87,6 +87,7 @@ markers for specific list items:
to check the minion log for errors after configuring this beacon. to check the minion log for errors after configuring this beacon.
""" """
import datetime import datetime
import logging import logging
@ -165,8 +166,8 @@ def beacon(config):
except TypeError: except TypeError:
ret[func][item] = data[int(item)] ret[func][item] = data[int(item)]
except KeyError as exc: except KeyError as exc:
ret[ ret[func] = (
func "Status beacon is incorrectly configured: {}".format(exc)
] = "Status beacon is incorrectly configured: {}".format(exc) )
return [{"tag": ctime, "data": ret}] return [{"tag": ctime, "data": ret}]

View file

@ -5,6 +5,7 @@ Beacon to monitor swap usage.
:depends: python-psutil :depends: python-psutil
""" """
import logging import logging
import re import re

View file

@ -4,6 +4,7 @@ Beacon to emit Telegram messages
Requires the python-telegram-bot library Requires the python-telegram-bot library
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -1,6 +1,7 @@
""" """
Beacon to emit Twilio text messages Beacon to emit Twilio text messages
""" """
import logging import logging
import salt.utils.beacons import salt.utils.beacons

View file

@ -4,7 +4,6 @@ Loader mechanism for caching data, with data expiration, etc.
.. versionadded:: 2016.11.0 .. versionadded:: 2016.11.0
""" """
import logging import logging
import time import time

View file

@ -151,7 +151,6 @@ Cluster Configuration Example:
cache.redis.separator: '@' cache.redis.separator: '@'
""" """
import itertools import itertools
import logging import logging
import time import time

View file

@ -4,7 +4,6 @@ Encapsulate the different transports available to Salt.
This includes client side transport, for the ReqServer and the Publisher This includes client side transport, for the ReqServer and the Publisher
""" """
import logging import logging
import os import os
import time import time

View file

@ -6,7 +6,6 @@
""" """
import logging import logging
import salt.client.netapi import salt.client.netapi

View file

@ -235,7 +235,7 @@ class BaseCaller:
retcode = salt.defaults.exitcodes.EX_GENERIC retcode = salt.defaults.exitcodes.EX_GENERIC
ret["retcode"] = retcode ret["retcode"] = retcode
except (CommandExecutionError) as exc: except CommandExecutionError as exc:
msg = "Error running '{0}': {1}\n" msg = "Error running '{0}': {1}\n"
active_level = LOG_LEVELS.get(self.opts["log_level"].lower(), logging.ERROR) active_level = LOG_LEVELS.get(self.opts["log_level"].lower(), logging.ERROR)
if active_level <= logging.DEBUG: if active_level <= logging.DEBUG:

View file

@ -2,7 +2,6 @@
Make me some salt! Make me some salt!
""" """
import logging import logging
import os import os
import warnings import warnings

View file

@ -7,7 +7,6 @@
.. versionadded:: 2015.8.0 .. versionadded:: 2015.8.0
""" """
import salt.spm import salt.spm
import salt.utils.parsers as parsers import salt.utils.parsers as parsers
from salt.utils.verify import verify_env from salt.utils.verify import verify_env

View file

@ -387,10 +387,10 @@ class SyncClientMixin(ClientStateMixin):
try: try:
data["return"] = func(*args, **kwargs) data["return"] = func(*args, **kwargs)
except TypeError as exc: except TypeError as exc:
data[ data["return"] = (
"return" "\nPassed invalid arguments: {}\n\nUsage:\n{}".format(
] = "\nPassed invalid arguments: {}\n\nUsage:\n{}".format( exc, func.__doc__
exc, func.__doc__ )
) )
try: try:
data["success"] = self.context.get("retcode", 0) == 0 data["success"] = self.context.get("retcode", 0) == 0

View file

@ -745,9 +745,9 @@ class SSH(MultiprocessingStateMixin):
data["id"] = id_ data["id"] = id_
if "fun" not in data: if "fun" not in data:
data["fun"] = fun data["fun"] = fun
data[ data["jid"] = (
"jid" jid # make the jid in the payload the same as the jid in the tag
] = jid # make the jid in the payload the same as the jid in the tag )
self.event.fire_event( self.event.fire_event(
data, salt.utils.event.tagify([jid, "ret", host], "job") data, salt.utils.event.tagify([jid, "ret", host], "job")
) )
@ -862,9 +862,9 @@ class SSH(MultiprocessingStateMixin):
data["id"] = id_ data["id"] = id_
if "fun" not in data: if "fun" not in data:
data["fun"] = fun data["fun"] = fun
data[ data["jid"] = (
"jid" jid # make the jid in the payload the same as the jid in the tag
] = jid # make the jid in the payload the same as the jid in the tag )
self.event.fire_event( self.event.fire_event(
data, salt.utils.event.tagify([jid, "ret", host], "job") data, salt.utils.event.tagify([jid, "ret", host], "job")
) )

View file

@ -169,7 +169,7 @@ def unpack_thin(thin_path):
""" """
tfile = tarfile.TarFile.gzopen(thin_path) tfile = tarfile.TarFile.gzopen(thin_path)
old_umask = os.umask(0o077) # pylint: disable=blacklisted-function old_umask = os.umask(0o077) # pylint: disable=blacklisted-function
tfile.extractall(path=OPTIONS.saltdir) tfile.extractall(path=OPTIONS.saltdir) # nosec
tfile.close() tfile.close()
os.umask(old_umask) # pylint: disable=blacklisted-function os.umask(old_umask) # pylint: disable=blacklisted-function
try: try:
@ -196,7 +196,7 @@ def unpack_ext(ext_path):
) )
tfile = tarfile.TarFile.gzopen(ext_path) tfile = tarfile.TarFile.gzopen(ext_path)
old_umask = os.umask(0o077) # pylint: disable=blacklisted-function old_umask = os.umask(0o077) # pylint: disable=blacklisted-function
tfile.extractall(path=modcache) tfile.extractall(path=modcache) # nosec
tfile.close() tfile.close()
os.umask(old_umask) # pylint: disable=blacklisted-function os.umask(old_umask) # pylint: disable=blacklisted-function
os.unlink(ext_path) os.unlink(ext_path)

View file

@ -5,7 +5,6 @@ to be easily rewritten to execute in a way that makes them do the same tasks
as ZeroMQ salt, but via ssh. as ZeroMQ salt, but via ssh.
""" """
import copy import copy
import salt.client.ssh import salt.client.ssh

View file

@ -2,7 +2,6 @@
Return/control aspects of the grains data Return/control aspects of the grains data
""" """
import math import math
import salt.utils.data import salt.utils.data

View file

@ -4,7 +4,6 @@ Wrapper function for mine operations for salt-ssh
.. versionadded:: 2015.5.0 .. versionadded:: 2015.5.0
""" """
import copy import copy
import salt.client.ssh import salt.client.ssh

View file

@ -2,6 +2,7 @@
The top level interface used to translate configuration data back to the The top level interface used to translate configuration data back to the
correct cloud modules correct cloud modules
""" """
import copy import copy
import glob import glob
import logging import logging

View file

@ -1,6 +1,7 @@
""" """
Primary interfaces for the salt-cloud system Primary interfaces for the salt-cloud system
""" """
# Need to get data from 4 sources! # Need to get data from 4 sources!
# CLI options # CLI options
# salt cloud config - CONFIG_DIR + '/cloud' # salt cloud config - CONFIG_DIR + '/cloud'

View file

@ -575,7 +575,7 @@ def create_node(kwargs):
"HostName", "HostName",
"Password", "Password",
"SystemDisk.Category", "SystemDisk.Category",
"VSwitchId" "VSwitchId",
# 'DataDisk.n.Size', 'DataDisk.n.Category', 'DataDisk.n.SnapshotId' # 'DataDisk.n.Size', 'DataDisk.n.Category', 'DataDisk.n.SnapshotId'
] ]

View file

@ -20,6 +20,7 @@ Use of this module requires the ``apikey``, ``secretkey``, ``host`` and
driver: cloudstack driver: cloudstack
""" """
# pylint: disable=function-redefined # pylint: disable=function-redefined
import logging import logging

View file

@ -1197,6 +1197,7 @@ def get_imageid(vm_):
"Filter.0.Name": "name", "Filter.0.Name": "name",
"Filter.0.Value.0": image, "Filter.0.Value.0": image,
} }
# Query AWS, sort by 'creationDate' and get the last imageId # Query AWS, sort by 'creationDate' and get the last imageId
def _t(x): def _t(x):
return datetime.datetime.strptime(x["creationDate"], "%Y-%m-%dT%H:%M:%S.%fZ") return datetime.datetime.strptime(x["creationDate"], "%Y-%m-%dT%H:%M:%S.%fZ")

View file

@ -43,6 +43,7 @@ Example Provider Configuration
:maintainer: Russell Tolle <russ.tolle@gmail.com> :maintainer: Russell Tolle <russ.tolle@gmail.com>
:depends: libcloud >= 1.0.0 :depends: libcloud >= 1.0.0
""" """
# pylint: disable=function-redefined # pylint: disable=function-redefined
import logging import logging
@ -1698,7 +1699,6 @@ def delete_disk(kwargs=None, call=None):
def create_disk(kwargs=None, call=None): def create_disk(kwargs=None, call=None):
""" """
Create a new persistent disk. Must specify `disk_name` and `location`, Create a new persistent disk. Must specify `disk_name` and `location`,
and optionally can specify 'disk_type' as pd-standard or pd-ssd, which and optionally can specify 'disk_type' as pd-standard or pd-ssd, which

View file

@ -16,6 +16,7 @@ Use of this module requires the ``key`` parameter to be set.
driver: hetzner driver: hetzner
""" """
# pylint: disable=invalid-name,function-redefined # pylint: disable=invalid-name,function-redefined

View file

@ -532,7 +532,6 @@ def take_action(
method="GET", method="GET",
location=DEFAULT_LOCATION, location=DEFAULT_LOCATION,
): ):
""" """
take action call used by start,stop, reboot take action call used by start,stop, reboot
:param name: name given to the machine :param name: name given to the machine

View file

@ -258,7 +258,7 @@ def get_domain_ips(domain, ip_source):
log.info("Exception polling address %s", error) log.info("Exception polling address %s", error)
return ips return ips
for (name, val) in addresses.items(): for name, val in addresses.items():
if val["addrs"]: if val["addrs"]:
for addr in val["addrs"]: for addr in val["addrs"]:
tp = to_ip_addr_type(addr["type"]) tp = to_ip_addr_type(addr["type"])

View file

@ -42,6 +42,7 @@ Example ``/etc/salt/cloud.providers`` or
certificate_path: /etc/salt/azure.pem certificate_path: /etc/salt/azure.pem
management_host: management.core.windows.net management_host: management.core.windows.net
""" """
# pylint: disable=function-redefined # pylint: disable=function-redefined
import copy import copy

View file

@ -76,7 +76,7 @@ from salt.exceptions import (
) )
try: try:
import xmlrpc.client import xmlrpc.client # nosec
from lxml import etree from lxml import etree

View file

@ -358,7 +358,7 @@ def _verify(vm_):
log.debug("Testing SMB protocol for %s", vm_["name"]) log.debug("Testing SMB protocol for %s", vm_["name"])
if __utils__["smb.get_conn"](**kwargs) is False: if __utils__["smb.get_conn"](**kwargs) is False:
return False return False
except (smbSessionError) as exc: except smbSessionError as exc:
log.error("Exception: %s", exc) log.error("Exception: %s", exc)
return False return False

View file

@ -1454,15 +1454,21 @@ def _format_instance_info_select(vm, selection):
if "storage" in selection: if "storage" in selection:
storage_full_info = { storage_full_info = {
"committed": int(vm["summary.storage.committed"]) "committed": (
if "summary.storage.committed" in vm int(vm["summary.storage.committed"])
else "N/A", if "summary.storage.committed" in vm
"uncommitted": int(vm["summary.storage.uncommitted"]) else "N/A"
if "summary.storage.uncommitted" in vm ),
else "N/A", "uncommitted": (
"unshared": int(vm["summary.storage.unshared"]) int(vm["summary.storage.uncommitted"])
if "summary.storage.unshared" in vm if "summary.storage.uncommitted" in vm
else "N/A", else "N/A"
),
"unshared": (
int(vm["summary.storage.unshared"])
if "summary.storage.unshared" in vm
else "N/A"
),
} }
vm_select_info["storage"] = storage_full_info vm_select_info["storage"] = storage_full_info
@ -1553,15 +1559,21 @@ def _format_instance_info(vm):
] = device.backing.fileName ] = device.backing.fileName
storage_full_info = { storage_full_info = {
"committed": int(vm["summary.storage.committed"]) "committed": (
if "summary.storage.committed" in vm int(vm["summary.storage.committed"])
else "N/A", if "summary.storage.committed" in vm
"uncommitted": int(vm["summary.storage.uncommitted"]) else "N/A"
if "summary.storage.uncommitted" in vm ),
else "N/A", "uncommitted": (
"unshared": int(vm["summary.storage.unshared"]) int(vm["summary.storage.uncommitted"])
if "summary.storage.unshared" in vm if "summary.storage.uncommitted" in vm
else "N/A", else "N/A"
),
"unshared": (
int(vm["summary.storage.unshared"])
if "summary.storage.unshared" in vm
else "N/A"
),
} }
file_full_info = {} file_full_info = {}
@ -1593,14 +1605,18 @@ def _format_instance_info(vm):
) )
vm_full_info = { vm_full_info = {
"id": str(vm["name"]), "id": str(vm["name"]),
"image": "{} (Detected)".format(vm["config.guestFullName"]) "image": (
if "config.guestFullName" in vm "{} (Detected)".format(vm["config.guestFullName"])
else "N/A", if "config.guestFullName" in vm
else "N/A"
),
"size": "cpu: {}\nram: {}".format(cpu, ram), "size": "cpu: {}\nram: {}".format(cpu, ram),
"size_dict": {"cpu": cpu, "memory": ram}, "size_dict": {"cpu": cpu, "memory": ram},
"state": str(vm["summary.runtime.powerState"]) "state": (
if "summary.runtime.powerState" in vm str(vm["summary.runtime.powerState"])
else "N/A", if "summary.runtime.powerState" in vm
else "N/A"
),
"private_ips": ip_addresses, "private_ips": ip_addresses,
"public_ips": [], "public_ips": [],
"devices": device_full_info, "devices": device_full_info,
@ -1610,12 +1626,14 @@ def _format_instance_info(vm):
"hostname": str(vm["object"].guest.hostName), "hostname": str(vm["object"].guest.hostName),
"mac_addresses": device_mac_addresses, "mac_addresses": device_mac_addresses,
"networks": network_full_info, "networks": network_full_info,
"path": str(vm["config.files.vmPathName"]) "path": (
if "config.files.vmPathName" in vm str(vm["config.files.vmPathName"])
else "N/A", if "config.files.vmPathName" in vm
"tools_status": str(vm["guest.toolsStatus"]) else "N/A"
if "guest.toolsStatus" in vm ),
else "N/A", "tools_status": (
str(vm["guest.toolsStatus"]) if "guest.toolsStatus" in vm else "N/A"
),
} }
return vm_full_info return vm_full_info
@ -2004,14 +2022,18 @@ def list_nodes(kwargs=None, call=None):
) )
vm_info = { vm_info = {
"id": vm["name"], "id": vm["name"],
"image": "{} (Detected)".format(vm["config.guestFullName"]) "image": (
if "config.guestFullName" in vm "{} (Detected)".format(vm["config.guestFullName"])
else "N/A", if "config.guestFullName" in vm
else "N/A"
),
"size": "cpu: {}\nram: {}".format(cpu, ram), "size": "cpu: {}\nram: {}".format(cpu, ram),
"size_dict": {"cpu": cpu, "memory": ram}, "size_dict": {"cpu": cpu, "memory": ram},
"state": str(vm["summary.runtime.powerState"]) "state": (
if "summary.runtime.powerState" in vm str(vm["summary.runtime.powerState"])
else "N/A", if "summary.runtime.powerState" in vm
else "N/A"
),
"private_ips": [vm["guest.ipAddress"]] if "guest.ipAddress" in vm else [], "private_ips": [vm["guest.ipAddress"]] if "guest.ipAddress" in vm else [],
"public_ips": [], "public_ips": [],
} }
@ -2242,15 +2264,21 @@ def avail_images(call=None):
if "config.template" in vm and vm["config.template"]: if "config.template" in vm and vm["config.template"]:
templates[vm["name"]] = { templates[vm["name"]] = {
"name": vm["name"], "name": vm["name"],
"guest_fullname": vm["config.guestFullName"] "guest_fullname": (
if "config.guestFullName" in vm vm["config.guestFullName"]
else "N/A", if "config.guestFullName" in vm
"cpus": vm["config.hardware.numCPU"] else "N/A"
if "config.hardware.numCPU" in vm ),
else "N/A", "cpus": (
"ram": vm["config.hardware.memoryMB"] vm["config.hardware.numCPU"]
if "config.hardware.memoryMB" in vm if "config.hardware.numCPU" in vm
else "N/A", else "N/A"
),
"ram": (
vm["config.hardware.memoryMB"]
if "config.hardware.memoryMB" in vm
else "N/A"
),
} }
return templates return templates

View file

@ -1,6 +1,7 @@
""" """
All salt configuration loading and defaults should be in this module All salt configuration loading and defaults should be in this module
""" """
import codecs import codecs
import glob import glob
import logging import logging

View file

@ -8,7 +8,6 @@
Common salt configuration schemas Common salt configuration schemas
""" """
from salt.utils.schema import ArrayItem, OneOfItem, Schema, StringItem from salt.utils.schema import ArrayItem, OneOfItem, Schema, StringItem

View file

@ -8,7 +8,6 @@
ESX Cluster configuration schemas ESX Cluster configuration schemas
""" """
from salt.utils.schema import ( from salt.utils.schema import (
AnyOfItem, AnyOfItem,
ArrayItem, ArrayItem,

View file

@ -8,7 +8,6 @@
ESX Datacenter configuration schemas ESX Datacenter configuration schemas
""" """
from salt.utils.schema import ArrayItem, IntegerItem, Schema, StringItem from salt.utils.schema import ArrayItem, IntegerItem, Schema, StringItem

View file

@ -8,7 +8,6 @@
ESXi host configuration schemas ESXi host configuration schemas
""" """
from salt.utils.schema import ( from salt.utils.schema import (
ArrayItem, ArrayItem,
BooleanItem, BooleanItem,

View file

@ -7,7 +7,6 @@
ESX Virtual Machine configuration schemas ESX Virtual Machine configuration schemas
""" """
from salt.utils.schema import ( from salt.utils.schema import (
AnyOfItem, AnyOfItem,
ArrayItem, ArrayItem,

View file

@ -7,7 +7,6 @@
Minion configuration schema Minion configuration schema
""" """
from salt.config.schemas.common import IncludeConfig, MinionDefaultInclude from salt.config.schemas.common import IncludeConfig, MinionDefaultInclude
from salt.utils.schema import IPv4Item, Schema from salt.utils.schema import IPv4Item, Schema

View file

@ -8,7 +8,6 @@
Salt SSH related configuration schemas Salt SSH related configuration schemas
""" """
from salt.config.schemas.minion import MinionConfiguration from salt.config.schemas.minion import MinionConfiguration
from salt.utils.schema import ( from salt.utils.schema import (
AnyOfItem, AnyOfItem,

View file

@ -132,7 +132,7 @@ def clean_pub_auth(opts):
if not os.path.exists(auth_cache): if not os.path.exists(auth_cache):
return return
else: else:
for (dirpath, dirnames, filenames) in salt.utils.path.os_walk(auth_cache): for dirpath, dirnames, filenames in salt.utils.path.os_walk(auth_cache):
for auth_file in filenames: for auth_file in filenames:
auth_file_path = os.path.join(dirpath, auth_file) auth_file_path = os.path.join(dirpath, auth_file)
if not os.path.isfile(auth_file_path): if not os.path.isfile(auth_file_path):
@ -724,7 +724,7 @@ class RemoteFuncs:
if not os.path.isdir(cdir): if not os.path.isdir(cdir):
try: try:
os.makedirs(cdir) os.makedirs(cdir)
except os.error: except OSError:
pass pass
if os.path.isfile(cpath) and load["loc"] != 0: if os.path.isfile(cpath) and load["loc"] != 0:
mode = "ab" mode = "ab"

View file

@ -2,6 +2,7 @@
Initialize the engines system. This plugin system allows for Initialize the engines system. This plugin system allows for
complex services to be encapsulated within the salt plugin environment complex services to be encapsulated within the salt plugin environment
""" """
import logging import logging
import salt import salt

View file

@ -2,6 +2,7 @@
Send events from Docker events Send events from Docker events
:Depends: Docker API >= 1.22 :Depends: Docker API >= 1.22
""" """
import logging import logging
import traceback import traceback

View file

@ -800,9 +800,9 @@ class SlackClient:
channel = self.sc.server.channels.find(msg["channel"]) channel = self.sc.server.channels.find(msg["channel"])
jid = self.run_command_async(msg) jid = self.run_command_async(msg)
log.debug("Submitted a job and got jid: %s", jid) log.debug("Submitted a job and got jid: %s", jid)
outstanding[ outstanding[jid] = (
jid msg # record so we can return messages to the caller
] = msg # record so we can return messages to the caller )
channel.send_message( channel.send_message(
"@{}'s job is submitted as salt jid {}".format( "@{}'s job is submitted as salt jid {}".format(
msg["user_name"], jid msg["user_name"], jid
@ -855,7 +855,6 @@ class SlackClient:
del outstanding[jid] del outstanding[jid]
def run_command_async(self, msg): def run_command_async(self, msg):
""" """
:type message_generator: generator of dict :type message_generator: generator of dict
:param message_generator: Generates messages from slack that should be run :param message_generator: Generates messages from slack that should be run

View file

@ -913,9 +913,9 @@ class SlackClient:
if control and (len(msg) > 1) and msg.get("cmdline"): if control and (len(msg) > 1) and msg.get("cmdline"):
jid = self.run_command_async(msg) jid = self.run_command_async(msg)
log.debug("Submitted a job and got jid: %s", jid) log.debug("Submitted a job and got jid: %s", jid)
outstanding[ outstanding[jid] = (
jid msg # record so we can return messages to the caller
] = msg # record so we can return messages to the caller )
text_msg = "@{}'s job is submitted as salt jid {}".format( text_msg = "@{}'s job is submitted as salt jid {}".format(
msg["user_name"], jid msg["user_name"], jid
) )
@ -969,7 +969,6 @@ class SlackClient:
del outstanding[jid] del outstanding[jid]
def run_command_async(self, msg): def run_command_async(self, msg):
""" """
:type msg: dict :type msg: dict
:param msg: The message dictionary that contains the command and all information. :param msg: The message dictionary that contains the command and all information.

View file

@ -1,6 +1,7 @@
""" """
Feature flags Feature flags
""" """
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,6 +1,7 @@
""" """
Classes that manage file clients Classes that manage file clients
""" """
import contextlib import contextlib
import errno import errno
import ftplib # nosec import ftplib # nosec

View file

@ -2,7 +2,6 @@
File server pluggable modules and generic backend functions File server pluggable modules and generic backend functions
""" """
import errno import errno
import fnmatch import fnmatch
import logging import logging

View file

@ -45,7 +45,6 @@ permissions.
Do not include the leading ? for sas_token if generated from the web Do not include the leading ? for sas_token if generated from the web
""" """
import base64 import base64
import logging import logging
import os import os

View file

@ -47,7 +47,6 @@ Walkthrough <tutorial-gitfs>`.
.. _GitPython: https://github.com/gitpython-developers/GitPython .. _GitPython: https://github.com/gitpython-developers/GitPython
""" """
import logging import logging
import salt.utils.gitfs import salt.utils.gitfs

View file

@ -860,7 +860,7 @@ def _file_lists(load, form):
if not os.path.isdir(list_cachedir): if not os.path.isdir(list_cachedir):
try: try:
os.makedirs(list_cachedir) os.makedirs(list_cachedir)
except os.error: except OSError:
log.critical("Unable to make cachedir %s", list_cachedir) log.critical("Unable to make cachedir %s", list_cachedir)
return [] return []
list_cache = os.path.join(list_cachedir, "{}.p".format(load["saltenv"])) list_cache = os.path.join(list_cachedir, "{}.p".format(load["saltenv"]))

View file

@ -150,7 +150,7 @@ def update():
salt.fileserver.reap_fileserver_cache_dir( salt.fileserver.reap_fileserver_cache_dir(
os.path.join(__opts__["cachedir"], "minionfs/hash"), find_file os.path.join(__opts__["cachedir"], "minionfs/hash"), find_file
) )
except os.error: except OSError:
# Hash file won't exist if no files have yet been served up # Hash file won't exist if no files have yet been served up
pass pass
@ -204,7 +204,7 @@ def file_hash(load, fnd):
ret["hsum"] = hsum ret["hsum"] = hsum
return ret return ret
# Can't use Python select() because we need Windows support # Can't use Python select() because we need Windows support
except os.error: except OSError:
log.debug("Fileserver encountered lock when reading cache file. Retrying.") log.debug("Fileserver encountered lock when reading cache file. Retrying.")
file_hash(load, fnd) file_hash(load, fnd)
return ret return ret

View file

@ -291,10 +291,7 @@ def file_hash(load, fnd):
# check if mtime changed # check if mtime changed
ret["hsum"] = hsum ret["hsum"] = hsum
return ret return ret
except ( except OSError: # Can't use Python select() because we need Windows support
os.error,
OSError,
): # Can't use Python select() because we need Windows support
log.debug("Fileserver encountered lock when reading cache file. Retrying.") log.debug("Fileserver encountered lock when reading cache file. Retrying.")
# Delete the file since its incomplete (either corrupted or incomplete) # Delete the file since its incomplete (either corrupted or incomplete)
try: try:

View file

@ -87,7 +87,6 @@ structure::
s3.s3_sync_on_update: False s3.s3_sync_on_update: False
""" """
import datetime import datetime
import logging import logging
import os import os

View file

@ -30,7 +30,6 @@ This backend assumes a standard svn layout with directories for ``branches``,
:conf_master:`documentation <svnfs_remotes>` for more information. :conf_master:`documentation <svnfs_remotes>` for more information.
""" """
import copy import copy
import errno import errno
import fnmatch import fnmatch
@ -721,7 +720,7 @@ def _file_lists(load, form):
if not os.path.isdir(list_cachedir): if not os.path.isdir(list_cachedir):
try: try:
os.makedirs(list_cachedir) os.makedirs(list_cachedir)
except os.error: except OSError:
log.critical("Unable to make cachedir %s", list_cachedir) log.critical("Unable to make cachedir %s", list_cachedir)
return [] return []
list_cache = os.path.join(list_cachedir, "{}.p".format(load["saltenv"])) list_cache = os.path.join(list_cachedir, "{}.p".format(load["saltenv"]))

View file

@ -3,7 +3,6 @@ Generate baseline proxy minion grains for cimc hosts.
""" """
import logging import logging
import salt.proxy.cimc import salt.proxy.cimc

View file

@ -2389,10 +2389,10 @@ def _legacy_linux_distribution_data(grains, os_release, lsb_has_error):
"Please report this, as it is likely a bug." "Please report this, as it is likely a bug."
) )
else: else:
grains[ grains["osrelease"] = (
"osrelease" "{majorversion}.{minorversion}-{buildnumber}".format(
] = "{majorversion}.{minorversion}-{buildnumber}".format( **synoinfo
**synoinfo )
) )
log.trace( log.trace(
@ -2880,14 +2880,16 @@ def fqdns():
opt = {"fqdns": []} opt = {"fqdns": []}
if __opts__.get( if __opts__.get(
"enable_fqdns_grains", "enable_fqdns_grains",
False (
if salt.utils.platform.is_windows() False
or salt.utils.platform.is_proxy() if salt.utils.platform.is_windows()
or salt.utils.platform.is_sunos() or salt.utils.platform.is_proxy()
or salt.utils.platform.is_aix() or salt.utils.platform.is_sunos()
or salt.utils.platform.is_junos() or salt.utils.platform.is_aix()
or salt.utils.platform.is_darwin() or salt.utils.platform.is_junos()
else True, or salt.utils.platform.is_darwin()
else True
),
): ):
opt = __salt__["network.fqdns"]() opt = __salt__["network.fqdns"]()
return opt return opt
@ -3318,7 +3320,7 @@ def _hw_data(osdata):
# of information. With that said, consolidate the output from various # of information. With that said, consolidate the output from various
# commands and attempt various lookups. # commands and attempt various lookups.
data = "" data = ""
for (cmd, args) in ( for cmd, args in (
("/usr/sbin/prtdiag", "-v"), ("/usr/sbin/prtdiag", "-v"),
("/usr/sbin/prtconf", "-vp"), ("/usr/sbin/prtconf", "-vp"),
("/usr/sbin/virtinfo", "-a"), ("/usr/sbin/virtinfo", "-a"),

View file

@ -13,7 +13,6 @@ Generate baseline proxy minion grains for ESXi hosts.
""" """
import logging import logging
import salt.utils.proxy import salt.utils.proxy

View file

@ -5,7 +5,6 @@ via salt-proxy-minion. Thus, some grains make sense to get them
from the minion (PYTHONPATH), but others don't (ip_interfaces) from the minion (PYTHONPATH), but others don't (ip_interfaces)
""" """
import logging import logging
import salt.utils.platform import salt.utils.platform

View file

@ -2,7 +2,6 @@
Set grains describing the minion process. Set grains describing the minion process.
""" """
import os import os
import salt.utils.platform import salt.utils.platform

View file

@ -15,7 +15,6 @@ Dependencies
.. versionadded:: 2016.11.0 .. versionadded:: 2016.11.0
""" """
import logging import logging
import salt.utils.dns import salt.utils.dns

View file

@ -3,7 +3,6 @@ Generate baseline proxy minion grains for panos hosts.
""" """
import logging import logging
import salt.proxy.panos import salt.proxy.panos

View file

@ -3,6 +3,7 @@ Grain that indicates the system is pending a reboot
See functions in salt.utils.win_system to see what conditions would indicate See functions in salt.utils.win_system to see what conditions would indicate
a reboot is pending a reboot is pending
""" """
import logging import logging
import salt.utils.platform import salt.utils.platform

Some files were not shown because too many files have changed in this diff Show more