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

View file

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

View file

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

View file

@ -364,8 +364,7 @@ the actual testing, such as functions containing assertions, must start with
.. 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
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):
"""
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):
"""
Remove a "package" on the REST server
"""

View file

@ -551,15 +551,13 @@ General Deprecations
.. 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
.. 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
that also accepts arbitrary keyword arguments, then a new warning informs the
@ -568,8 +566,7 @@ General Deprecations
.. code-block:: python
def fcn(msg="", refresh=True, saltenv="base", **kwargs):
...
def fcn(msg="", refresh=True, saltenv="base", **kwargs): ...
.. code-block:: python
@ -582,8 +579,7 @@ General Deprecations
.. code-block:: python
def fcn(msg="", refresh=True, saltenv="base"):
...
def fcn(msg="", refresh=True, saltenv="base"): ...
.. code-block:: python
@ -597,8 +593,7 @@ General Deprecations
.. code-block:: python
def fcn(msg="", refresh=True, saltenv="base"):
...
def fcn(msg="", refresh=True, saltenv="base"): ...
.. code-block:: python

View file

@ -4,6 +4,7 @@ noxfile
Nox configuration script
"""
# pylint: disable=resource-leakage,3rd-party-module-not-gated
import contextlib
@ -1712,7 +1713,7 @@ class Recompress:
d_targz = tempd.joinpath(targz.name)
with tarfile.open(d_tar, "w|") as wfile:
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())
for name in sorted(extracted_dir.rglob("*")):
wfile.add(

View file

@ -7,13 +7,6 @@ import os
import sys
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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,6 +3,7 @@ Beacon to emit adb device state changes for Android devices
.. versionadded:: 2016.3.0
"""
import logging
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
"""
import logging
log = logging.getLogger(__name__)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,6 +17,7 @@ Beacon that fires events on vm state changes
- interval: 60
- startup_create_event: True
"""
import logging
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.
"""
import datetime
import logging
@ -165,8 +166,8 @@ def beacon(config):
except TypeError:
ret[func][item] = data[int(item)]
except KeyError as exc:
ret[
func
] = "Status beacon is incorrectly configured: {}".format(exc)
ret[func] = (
"Status beacon is incorrectly configured: {}".format(exc)
)
return [{"tag": ctime, "data": ret}]

View file

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

View file

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

View file

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

View file

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

View file

@ -151,7 +151,6 @@ Cluster Configuration Example:
cache.redis.separator: '@'
"""
import itertools
import logging
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
"""
import logging
import os
import time

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -745,9 +745,9 @@ class SSH(MultiprocessingStateMixin):
data["id"] = id_
if "fun" not in data:
data["fun"] = fun
data[
"jid"
] = jid # make the jid in the payload the same as the jid in the tag
data["jid"] = (
jid # make the jid in the payload the same as the jid in the tag
)
self.event.fire_event(
data, salt.utils.event.tagify([jid, "ret", host], "job")
)
@ -862,9 +862,9 @@ class SSH(MultiprocessingStateMixin):
data["id"] = id_
if "fun" not in data:
data["fun"] = fun
data[
"jid"
] = jid # make the jid in the payload the same as the jid in the tag
data["jid"] = (
jid # make the jid in the payload the same as the jid in the tag
)
self.event.fire_event(
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)
old_umask = os.umask(0o077) # pylint: disable=blacklisted-function
tfile.extractall(path=OPTIONS.saltdir)
tfile.extractall(path=OPTIONS.saltdir) # nosec
tfile.close()
os.umask(old_umask) # pylint: disable=blacklisted-function
try:
@ -196,7 +196,7 @@ def unpack_ext(ext_path):
)
tfile = tarfile.TarFile.gzopen(ext_path)
old_umask = os.umask(0o077) # pylint: disable=blacklisted-function
tfile.extractall(path=modcache)
tfile.extractall(path=modcache) # nosec
tfile.close()
os.umask(old_umask) # pylint: disable=blacklisted-function
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.
"""
import copy
import salt.client.ssh

View file

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

View file

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

View file

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

View file

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

View file

@ -575,7 +575,7 @@ def create_node(kwargs):
"HostName",
"Password",
"SystemDisk.Category",
"VSwitchId"
"VSwitchId",
# '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
"""
# pylint: disable=function-redefined
import logging

View file

@ -1197,6 +1197,7 @@ def get_imageid(vm_):
"Filter.0.Name": "name",
"Filter.0.Value.0": image,
}
# Query AWS, sort by 'creationDate' and get the last imageId
def _t(x):
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>
:depends: libcloud >= 1.0.0
"""
# pylint: disable=function-redefined
import logging
@ -1698,7 +1699,6 @@ def delete_disk(kwargs=None, call=None):
def create_disk(kwargs=None, call=None):
"""
Create a new persistent disk. Must specify `disk_name` and `location`,
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
"""
# pylint: disable=invalid-name,function-redefined

View file

@ -532,7 +532,6 @@ def take_action(
method="GET",
location=DEFAULT_LOCATION,
):
"""
take action call used by start,stop, reboot
: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)
return ips
for (name, val) in addresses.items():
for name, val in addresses.items():
if val["addrs"]:
for addr in val["addrs"]:
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
management_host: management.core.windows.net
"""
# pylint: disable=function-redefined
import copy

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -132,7 +132,7 @@ def clean_pub_auth(opts):
if not os.path.exists(auth_cache):
return
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:
auth_file_path = os.path.join(dirpath, auth_file)
if not os.path.isfile(auth_file_path):
@ -724,7 +724,7 @@ class RemoteFuncs:
if not os.path.isdir(cdir):
try:
os.makedirs(cdir)
except os.error:
except OSError:
pass
if os.path.isfile(cpath) and load["loc"] != 0:
mode = "ab"

View file

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

View file

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

View file

@ -800,9 +800,9 @@ class SlackClient:
channel = self.sc.server.channels.find(msg["channel"])
jid = self.run_command_async(msg)
log.debug("Submitted a job and got jid: %s", jid)
outstanding[
jid
] = msg # record so we can return messages to the caller
outstanding[jid] = (
msg # record so we can return messages to the caller
)
channel.send_message(
"@{}'s job is submitted as salt jid {}".format(
msg["user_name"], jid
@ -855,7 +855,6 @@ class SlackClient:
del outstanding[jid]
def run_command_async(self, msg):
"""
:type message_generator: generator of dict
: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"):
jid = self.run_command_async(msg)
log.debug("Submitted a job and got jid: %s", jid)
outstanding[
jid
] = msg # record so we can return messages to the caller
outstanding[jid] = (
msg # record so we can return messages to the caller
)
text_msg = "@{}'s job is submitted as salt jid {}".format(
msg["user_name"], jid
)
@ -969,7 +969,6 @@ class SlackClient:
del outstanding[jid]
def run_command_async(self, msg):
"""
:type msg: dict
:param msg: The message dictionary that contains the command and all information.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -860,7 +860,7 @@ def _file_lists(load, form):
if not os.path.isdir(list_cachedir):
try:
os.makedirs(list_cachedir)
except os.error:
except OSError:
log.critical("Unable to make cachedir %s", list_cachedir)
return []
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(
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
pass
@ -204,7 +204,7 @@ def file_hash(load, fnd):
ret["hsum"] = hsum
return ret
# 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.")
file_hash(load, fnd)
return ret

View file

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

View file

@ -87,7 +87,6 @@ structure::
s3.s3_sync_on_update: False
"""
import datetime
import logging
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.
"""
import copy
import errno
import fnmatch
@ -721,7 +720,7 @@ def _file_lists(load, form):
if not os.path.isdir(list_cachedir):
try:
os.makedirs(list_cachedir)
except os.error:
except OSError:
log.critical("Unable to make cachedir %s", list_cachedir)
return []
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 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."
)
else:
grains[
"osrelease"
] = "{majorversion}.{minorversion}-{buildnumber}".format(
**synoinfo
grains["osrelease"] = (
"{majorversion}.{minorversion}-{buildnumber}".format(
**synoinfo
)
)
log.trace(
@ -2880,14 +2880,16 @@ def fqdns():
opt = {"fqdns": []}
if __opts__.get(
"enable_fqdns_grains",
False
if salt.utils.platform.is_windows()
or salt.utils.platform.is_proxy()
or salt.utils.platform.is_sunos()
or salt.utils.platform.is_aix()
or salt.utils.platform.is_junos()
or salt.utils.platform.is_darwin()
else True,
(
False
if salt.utils.platform.is_windows()
or salt.utils.platform.is_proxy()
or salt.utils.platform.is_sunos()
or salt.utils.platform.is_aix()
or salt.utils.platform.is_junos()
or salt.utils.platform.is_darwin()
else True
),
):
opt = __salt__["network.fqdns"]()
return opt
@ -3318,7 +3320,7 @@ def _hw_data(osdata):
# of information. With that said, consolidate the output from various
# commands and attempt various lookups.
data = ""
for (cmd, args) in (
for cmd, args in (
("/usr/sbin/prtdiag", "-v"),
("/usr/sbin/prtconf", "-vp"),
("/usr/sbin/virtinfo", "-a"),

View file

@ -13,7 +13,6 @@ Generate baseline proxy minion grains for ESXi hosts.
"""
import logging
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)
"""
import logging
import salt.utils.platform

View file

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

View file

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

View file

@ -3,7 +3,6 @@ Generate baseline proxy minion grains for panos hosts.
"""
import logging
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
a reboot is pending
"""
import logging
import salt.utils.platform

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