Update to isort 5.10.1

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-07-20 10:42:30 +01:00 committed by Megan Wilhite
parent 2ff4835ff3
commit 4d49013247
1045 changed files with 1363 additions and 446 deletions

View file

@ -1147,7 +1147,7 @@ repos:
args: [--silent, -E, fix_asserts, -E, fix_docstrings]
- repo: https://github.com/timothycrosley/isort
rev: "1e78a9acf3110e1f9721feb591f89a451fc9876a"
rev: 5.10.1
hooks:
- id: isort
additional_dependencies: ['toml']

View file

@ -2,7 +2,6 @@ import itertools
import os
import re
import salt
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.statemachine import ViewList
@ -14,6 +13,8 @@ from sphinx.locale import _
from sphinx.roles import XRefRole
from sphinx.util.nodes import make_refnode, nested_parse_with_titles, set_source_info
import salt
class Event(PyObject):
"""

7
run.py
View file

@ -1,18 +1,19 @@
#!/usr/bin/env python3
# see issue: https://gitlab.com/saltstack/open/salt-pkg/-/issues/19
import _pyio
import contextlib
import multiprocessing
import os
import pathlib
import sys
import salt.scripts
import salt.utils.platform
import _pyio
import tiamatpip.cli
import tiamatpip.configure
import tiamatpip.utils
import salt.scripts
import salt.utils.platform
AVAIL = (
"minion",
"master",

View file

@ -6,8 +6,8 @@ Provide authentication using OpenStack Keystone
try:
from keystoneclient.v2_0 import client
from keystoneclient.exceptions import AuthorizationFailure, Unauthorized
from keystoneclient.v2_0 import client
except ImportError:
pass

View file

@ -6,9 +6,10 @@ Provide authentication using simple LDAP binds
import itertools
import logging
from jinja2 import Environment
import salt.utils.data
import salt.utils.stringutils
from jinja2 import Environment
from salt.exceptions import CommandExecutionError, SaltInvocationError
log = logging.getLogger(__name__)
@ -16,8 +17,8 @@ log = logging.getLogger(__name__)
try:
# pylint: disable=no-name-in-module
import ldap
import ldap.modlist
import ldap.filter
import ldap.modlist
HAS_LDAP = True
# pylint: enable=no-name-in-module

View file

@ -55,8 +55,8 @@ log = logging.getLogger(__name__)
try:
# Trying to import MySQLdb
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
import MySQLdb.cursors
from MySQLdb.connections import OperationalError
except ImportError:
try:
@ -65,8 +65,8 @@ except ImportError:
pymysql.install_as_MySQLdb()
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
import MySQLdb.cursors
from MySQLdb.err import OperationalError
except ImportError:
MySQLdb = None

View file

@ -14,8 +14,8 @@ import salt.utils.beacons
try:
# pylint: disable=no-name-in-module
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
# pylint: enable=no-name-in-module

View file

@ -60,8 +60,8 @@ from salt.exceptions import SaltCacheError
try:
# Trying to import MySQLdb
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
import MySQLdb.cursors
from MySQLdb.connections import OperationalError
except ImportError:
try:
@ -70,8 +70,8 @@ except ImportError:
pymysql.install_as_MySQLdb()
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
import MySQLdb.cursors
from MySQLdb.err import OperationalError
except ImportError:
MySQLdb = None

View file

@ -590,10 +590,9 @@ class LocalClient:
# even though it has already been imported.
# when cmd_batch is called via the NetAPI
# the module is unavailable.
import salt.utils.args
# Late import - not used anywhere else in this file
import salt.cli.batch
import salt.utils.args
arg = salt.utils.args.condition_input(arg, kwarg)
opts = {

View file

@ -83,9 +83,9 @@ except ImportError:
HAS_CLC = False
# Disable InsecureRequestWarning generated on python > 2.6
try:
from requests.packages.urllib3 import (
from requests.packages.urllib3 import ( # pylint: disable=no-name-in-module
disable_warnings,
) # pylint: disable=no-name-in-module
)
disable_warnings()
except Exception: # pylint: disable=broad-except

View file

@ -39,13 +39,12 @@ from salt.utils.versions import LooseVersion as _LooseVersion
# Import libcloud
try:
import libcloud
from libcloud.compute.base import NodeDriver, NodeState
from libcloud.compute.base import NodeAuthPassword
from libcloud.compute.types import Provider
from libcloud.compute.base import NodeAuthPassword, NodeDriver, NodeState
from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider
from libcloud.loadbalancer.base import Member
from libcloud.loadbalancer.types import Provider as Provider_lb
from libcloud.loadbalancer.providers import get_driver as get_driver_lb
from libcloud.loadbalancer.types import Provider as Provider_lb
# This work-around for Issue #32743 is no longer needed for libcloud >=
# 1.4.0. However, older versions of libcloud must still be supported with

View file

@ -66,14 +66,11 @@ from salt.utils.versions import LooseVersion as _LooseVersion
LIBCLOUD_IMPORT_ERROR = None
try:
import libcloud
from libcloud.compute.types import Provider
from libcloud.common.google import ResourceInUseError, ResourceNotFoundError
from libcloud.compute.providers import get_driver
from libcloud.loadbalancer.types import Provider as Provider_lb
from libcloud.compute.types import Provider
from libcloud.loadbalancer.providers import get_driver as get_driver_lb
from libcloud.common.google import (
ResourceInUseError,
ResourceNotFoundError,
)
from libcloud.loadbalancer.types import Provider as Provider_lb
HAS_LIBCLOUD = True
except ImportError:

View file

@ -61,13 +61,14 @@ from salt.exceptions import SaltCloudSystemExit
HAS_LIBS = False
try:
import azure
import azure.storage
import azure.servicemanagement
import azure.storage
from azure.common import (
AzureConflictHttpError,
AzureMissingResourceHttpError,
AzureException,
AzureMissingResourceHttpError,
)
import salt.utils.msazure
from salt.utils.msazure import object_to_dict

View file

@ -109,13 +109,7 @@ from salt.exceptions import (
try:
# pylint: disable=no-name-in-module
from oneandone.client import (
OneAndOneService,
Server,
Hdd,
BlockStorage,
SshKey,
)
from oneandone.client import BlockStorage, Hdd, OneAndOneService, Server, SshKey
# pylint: enable=no-name-in-module

View file

@ -77,6 +77,7 @@ from salt.exceptions import (
try:
import xmlrpc.client
from lxml import etree
HAS_XML_LIBS = True

View file

@ -240,10 +240,10 @@ from salt.exceptions import (
)
try:
import shade
import shade.openstackcloud
import shade.exc
import os_client_config
import shade
import shade.exc
import shade.openstackcloud
HAS_SHADE = (
salt.utils.versions._LooseVersion(shade.__version__)

View file

@ -114,17 +114,17 @@ try:
# pylint: disable=no-name-in-module
import profitbricks
from profitbricks.client import (
ProfitBricksService,
Server,
LAN,
NIC,
Volume,
Datacenter,
FirewallRule,
IPBlock,
Datacenter,
LoadBalancer,
LAN,
PBNotFoundError,
PBError,
PBNotFoundError,
ProfitBricksService,
Server,
Volume,
)
# pylint: enable=no-name-in-module

View file

@ -642,7 +642,7 @@ def create(vm_):
if "use_dns" in vm_ and "ip_address" not in vm_:
use_dns = vm_["use_dns"]
if use_dns:
from socket import gethostbyname, gaierror
from socket import gaierror, gethostbyname
try:
ip_address = gethostbyname(str(vm_["name"]))

View file

@ -29,8 +29,8 @@ log = logging.getLogger(__name__)
try:
# noinspection PyUnresolvedReferences
from impacket.smbconnection import SessionError as smbSessionError
from impacket.smb3 import SessionError as smb3SessionError
from impacket.smbconnection import SessionError as smbSessionError
HAS_IMPACKET = True
except ImportError:
@ -38,18 +38,17 @@ except ImportError:
try:
# noinspection PyUnresolvedReferences
from winrm.exceptions import WinRMTransportError
# noinspection PyUnresolvedReferences
from requests.exceptions import (
ConnectionError,
ConnectTimeout,
ReadTimeout,
SSLError,
ProxyError,
RetryError,
InvalidSchema,
ProxyError,
ReadTimeout,
RetryError,
SSLError,
)
from winrm.exceptions import WinRMTransportError
HAS_WINRM = True
except ImportError:

View file

@ -47,8 +47,8 @@ try:
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.cvm.v20170312 import cvm_client
from tencentcloud.cvm.v20170312 import models as cvm_models
from tencentcloud.vpc.v20170312 import vpc_client
from tencentcloud.vpc.v20170312 import models as vpc_models
from tencentcloud.vpc.v20170312 import vpc_client
# pylint: enable=no-name-in-module

View file

@ -23,15 +23,16 @@ from salt.exceptions import SaltCloudSystemExit
try:
import vboxapi # pylint: disable=unused-import
from salt.utils.virtualbox import (
vb_list_machines,
treat_machine_dict,
vb_clone_vm,
vb_machine_exists,
vb_destroy_machine,
vb_get_machine,
vb_stop_vm,
treat_machine_dict,
vb_list_machines,
vb_machine_exists,
vb_start_vm,
vb_stop_vm,
vb_wait_for_network_address,
)

View file

@ -139,9 +139,9 @@ except ImportError:
# Disable InsecureRequestWarning generated on python > 2.6
try:
from requests.packages.urllib3 import (
from requests.packages.urllib3 import ( # pylint: disable=no-name-in-module
disable_warnings,
) # pylint: disable=no-name-in-module
)
disable_warnings()
except ImportError:

View file

@ -16,9 +16,9 @@ from salt.exceptions import SaltCloudNotFound, SaltCloudSystemExit
# pylint: disable=W0611
try:
import libcloud
from libcloud.compute.types import Provider, NodeState
from libcloud.compute.providers import get_driver
from libcloud.compute.deployment import MultiStepDeployment, ScriptDeployment
from libcloud.compute.providers import get_driver
from libcloud.compute.types import NodeState, Provider
HAS_LIBCLOUD = True
LIBCLOUD_VERSION_INFO = tuple(

View file

@ -43,7 +43,7 @@ from salt.exceptions import (
)
try:
from M2Crypto import RSA, EVP, BIO
from M2Crypto import BIO, EVP, RSA
HAS_M2 = True
except ImportError:
@ -51,11 +51,12 @@ except ImportError:
if not HAS_M2:
try:
from Cryptodome.Cipher import AES, PKCS1_OAEP, PKCS1_v1_5 as PKCS1_v1_5_CIPHER
from Cryptodome import Random
from Cryptodome.Cipher import AES, PKCS1_OAEP
from Cryptodome.Cipher import PKCS1_v1_5 as PKCS1_v1_5_CIPHER
from Cryptodome.Hash import SHA
from Cryptodome.PublicKey import RSA
from Cryptodome.Signature import PKCS1_v1_5
from Cryptodome import Random
HAS_CRYPTO = True
except ImportError:
@ -63,18 +64,14 @@ if not HAS_M2:
if not HAS_M2 and not HAS_CRYPTO:
try:
from Crypto.Cipher import ( # nosec
AES,
PKCS1_OAEP,
PKCS1_v1_5 as PKCS1_v1_5_CIPHER,
)
# let this be imported, if possible
from Crypto import Random # nosec
from Crypto.Cipher import AES, PKCS1_OAEP # nosec
from Crypto.Cipher import PKCS1_v1_5 as PKCS1_v1_5_CIPHER # nosec
from Crypto.Hash import SHA # nosec
from Crypto.PublicKey import RSA # nosec
from Crypto.Signature import PKCS1_v1_5 # nosec
# let this be imported, if possible
from Crypto import Random # nosec
HAS_CRYPTO = True
except ImportError:
HAS_CRYPTO = False

View file

@ -40,7 +40,7 @@ import logging
import salt.utils.event
try:
from fluent import sender, event
from fluent import event, sender
except ImportError:
sender = None

View file

@ -92,22 +92,22 @@ import time
import salt.utils.event as event
try:
from twisted.internet.protocol import ( # pylint: disable=no-name-in-module
DatagramProtocol,
)
from twisted.internet import reactor, threads # pylint: disable=no-name-in-module
from pyparsing import (
Word,
alphas,
Suppress,
Combine,
nums,
string,
LineEnd,
Optional,
Regex,
LineEnd,
StringEnd,
Suppress,
Word,
alphas,
delimitedList,
nums,
string,
)
from twisted.internet import reactor, threads # pylint: disable=no-name-in-module
from twisted.internet.protocol import ( # pylint: disable=no-name-in-module
DatagramProtocol,
)
HAS_TWISTED_AND_PYPARSING = True

View file

@ -24,6 +24,7 @@ import uuid
from errno import EACCES, EPERM
import distro
import salt.exceptions
# Solve the Chicken and egg problem where grains need to run before any

View file

@ -40,7 +40,7 @@ import socket
from salt._logging import LOG_LEVELS
try:
from log4mongo.handlers import MongoHandler, MongoFormatter
from log4mongo.handlers import MongoFormatter, MongoHandler
HAS_MONGO = True
except ImportError:

View file

@ -54,10 +54,7 @@ log = logging.getLogger(__name__)
try:
import apt.cache
import apt.debfile
from aptsources.sourceslist import (
SourceEntry,
SourcesList,
)
from aptsources.sourceslist import SourceEntry, SourcesList
HAS_APT = True
except ImportError:

View file

@ -57,8 +57,8 @@ log = logging.getLogger(__name__)
try:
# pylint: disable=unused-import
import botocore
import boto3
import botocore
# pylint: enable=unused-import
logging.getLogger("boto3").setLevel(logging.CRITICAL)

View file

@ -50,8 +50,8 @@ log = logging.getLogger(__name__)
# pylint: disable=unused-import
try:
import botocore
import boto3
import botocore
import jmespath
logging.getLogger("boto3").setLevel(logging.CRITICAL)

View file

@ -93,10 +93,10 @@ try:
# pylint: disable=unused-import
import boto
import boto3
from botocore import __version__ as found_botocore_version
# pylint: enable=unused-import
from botocore.exceptions import ClientError
from botocore import __version__ as found_botocore_version
logging.getLogger("boto").setLevel(logging.CRITICAL)
logging.getLogger("boto3").setLevel(logging.CRITICAL)

View file

@ -63,9 +63,9 @@ DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
try:
import boto
import boto.ec2
import boto.ec2.instance
import boto.ec2.blockdevicemapping as blockdevicemapping
import boto.ec2.autoscale as autoscale
import boto.ec2.blockdevicemapping as blockdevicemapping
import boto.ec2.instance
logging.getLogger("boto").setLevel(logging.CRITICAL)
import boto3 # pylint: disable=unused-import

View file

@ -45,16 +45,17 @@ Connection module for Amazon CloudWatch
import logging
import yaml # pylint: disable=blacklisted-import
import salt.utils.json
import salt.utils.odict as odict
import salt.utils.versions
import yaml # pylint: disable=blacklisted-import
try:
import boto
import boto.ec2.cloudwatch
import boto.ec2.cloudwatch.listelement
import boto.ec2.cloudwatch.dimension
import boto.ec2.cloudwatch.listelement
logging.getLogger("boto").setLevel(logging.CRITICAL)
HAS_BOTO = True

View file

@ -55,12 +55,13 @@ try:
import boto.dynamodb2
# pylint: enable=unused-import
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.fields import (
AllIndex,
GlobalAllIndex,
GlobalIncludeIndex,
GlobalKeysOnlyIndex,
HashKey,
RangeKey,
)
from boto.dynamodb2.table import Table
from boto.exception import JSONResponseError

View file

@ -60,8 +60,8 @@ try:
# pylint: enable=unused-import
from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType
from boto.ec2.networkinterface import (
NetworkInterfaceSpecification,
NetworkInterfaceCollection,
NetworkInterfaceSpecification,
)
HAS_BOTO = True

View file

@ -54,10 +54,12 @@ try:
import boto
import boto.ec2 # pylint: enable=unused-import
from boto.ec2.elb import HealthCheck
from boto.ec2.elb.attributes import AccessLogAttribute
from boto.ec2.elb.attributes import ConnectionDrainingAttribute
from boto.ec2.elb.attributes import ConnectionSettingAttribute
from boto.ec2.elb.attributes import CrossZoneLoadBalancingAttribute
from boto.ec2.elb.attributes import (
AccessLogAttribute,
ConnectionDrainingAttribute,
ConnectionSettingAttribute,
CrossZoneLoadBalancingAttribute,
)
logging.getLogger("boto").setLevel(logging.CRITICAL)
HAS_BOTO = True

View file

@ -49,7 +49,6 @@ try:
import botocore
# pylint: enable=unused-import
# TODO Version check using salt.utils.versions
from botocore.exceptions import ClientError

View file

@ -49,8 +49,8 @@ import salt.utils.versions
# pylint: disable=unused-import
try:
import boto
import boto.iam
import boto3
import boto.iam
import botocore
logging.getLogger("boto").setLevel(logging.CRITICAL)

View file

@ -64,10 +64,10 @@ try:
# pylint: disable=unused-import
import boto
import boto3
from botocore import __version__ as found_botocore_version
# pylint: enable=unused-import
from botocore.exceptions import ClientError
from botocore import __version__ as found_botocore_version
logging.getLogger("boto3").setLevel(logging.CRITICAL)
HAS_BOTO = True

View file

@ -96,10 +96,10 @@ try:
# pylint: disable=unused-import
import boto
import boto3
from botocore import __version__ as found_botocore_version
# pylint: enable=unused-import
from botocore.exceptions import ClientError
from botocore import __version__ as found_botocore_version
logging.getLogger("boto").setLevel(logging.CRITICAL)
logging.getLogger("boto3").setLevel(logging.CRITICAL)

View file

@ -147,8 +147,8 @@ log = logging.getLogger(__name__)
try:
# pylint: disable=unused-import
import boto
import botocore
import boto.vpc
import botocore
# pylint: enable=unused-import
from boto.exception import BotoServerError

View file

@ -34,8 +34,8 @@ log = logging.getLogger(__file__)
try:
import capirca
import capirca.aclgen
import capirca.lib.policy
import capirca.lib.aclgenerator
import capirca.lib.policy
HAS_CAPIRCA = True
except ImportError:

View file

@ -96,14 +96,13 @@ __virtualname__ = "cassandra_cql"
HAS_DRIVER = False
try:
# pylint: disable=import-error,no-name-in-module
from cassandra.cluster import Cluster
from cassandra.cluster import NoHostAvailable
from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import Cluster, NoHostAvailable
from cassandra.connection import (
ConnectionException,
ConnectionShutdown,
OperationTimedOut,
)
from cassandra.auth import PlainTextAuthProvider
from cassandra.query import dict_factory
# pylint: enable=import-error,no-name-in-module

View file

@ -10,9 +10,10 @@ import os
import re
import tempfile
from requests.structures import CaseInsensitiveDict
import salt.utils.data
import salt.utils.platform
from requests.structures import CaseInsensitiveDict
from salt.exceptions import (
CommandExecutionError,
CommandNotFoundError,

View file

@ -15,6 +15,7 @@ https://docs.datadoghq.com/api/
import requests
from salt.exceptions import SaltInvocationError
HAS_DATADOG = True

View file

@ -32,8 +32,8 @@ log = logging.getLogger(__name__)
try:
import dns.query
import dns.update # pylint: disable=no-name-in-module
import dns.tsigkeyring # pylint: disable=no-name-in-module
import dns.update # pylint: disable=no-name-in-module
dns_support = True
except ImportError as e:

View file

@ -15,6 +15,7 @@ import time
import jinja2
import jinja2.exceptions
import salt.utils.dns
import salt.utils.files
import salt.utils.odict

View file

@ -33,6 +33,7 @@ REPREPRO_SIGN_PROMPT_RE = re.compile(r"Passphrase: ", re.M)
try:
import gnupg # pylint: disable=unused-import
import salt.modules.gpg
HAS_LIBS = True

View file

@ -8,7 +8,9 @@ import os
HAS_GENTOOLKIT = False
try:
from gentoolkit.eclean import search, clean, cli, exclude as excludemod
from gentoolkit.eclean import clean, cli
from gentoolkit.eclean import exclude as excludemod
from gentoolkit.eclean import search
HAS_GENTOOLKIT = True
except ImportError:

View file

@ -39,8 +39,8 @@ HAS_LIBS = False
try:
# pylint: disable=no-name-in-module
import github
import github.PaginatedList
import github.NamedUser
import github.PaginatedList
from github.GithubException import UnknownObjectException
# pylint: enable=no-name-in-module

View file

@ -20,13 +20,14 @@ import os
import re
from functools import wraps
import yaml
import salt.utils.args
import salt.utils.files
import salt.utils.json
import salt.utils.path
import salt.utils.platform
import salt.utils.stringutils
import yaml
try:
from lxml import etree

View file

@ -7,8 +7,8 @@ import logging
import re
try:
from salt.utils.versions import LooseVersion as _LooseVersion
from salt.exceptions import CommandExecutionError
from salt.utils.versions import LooseVersion as _LooseVersion
HAS_REQUIRED_LIBS = True
except ImportError:

View file

@ -6,12 +6,12 @@ import functools
import logging
try:
from salt.utils.versions import LooseVersion as _LooseVersion
from salt.exceptions import CommandExecutionError
import salt.modules.yumpkg
import salt.utils.data
import salt.utils.functools
import salt.utils.systemd
import salt.modules.yumpkg
from salt.exceptions import CommandExecutionError
from salt.utils.versions import LooseVersion as _LooseVersion
__IMPORT_ERROR = None
except ImportError as exc:

View file

@ -58,14 +58,14 @@ import salt.utils.http
HAS_KEYSTONE = False
try:
# pylint: disable=import-error
from keystoneclient.v2_0 import client
import keystoneclient.exceptions
from keystoneclient.v2_0 import client
HAS_KEYSTONE = True
from keystoneclient.v3 import client as client3
from keystoneclient import discover
from keystoneauth1 import session
from keystoneauth1.identity import generic
from keystoneclient import discover
from keystoneclient.v3 import client as client3
# pylint: enable=import-error
except ImportError:

View file

@ -72,8 +72,7 @@ try:
from kubernetes.client import V1beta1Deployment as AppsV1beta1Deployment
from kubernetes.client import V1beta1DeploymentSpec as AppsV1beta1DeploymentSpec
except ImportError:
from kubernetes.client import AppsV1beta1Deployment
from kubernetes.client import AppsV1beta1DeploymentSpec
from kubernetes.client import AppsV1beta1Deployment, AppsV1beta1DeploymentSpec
# pylint: enable=no-name-in-module
HAS_LIBS = True

View file

@ -43,8 +43,8 @@ REQUIRED_LIBCLOUD_VERSION = "2.0.0"
try:
# pylint: disable=unused-import
import libcloud
from libcloud.compute.providers import get_driver
from libcloud.compute.base import Node
from libcloud.compute.providers import get_driver
# pylint: enable=unused-import
if hasattr(libcloud, "__version__") and _LooseVersion(

View file

@ -42,8 +42,8 @@ REQUIRED_LIBCLOUD_VERSION = "1.5.0"
try:
# pylint: disable=unused-import
import libcloud
from libcloud.loadbalancer.base import Algorithm, Member
from libcloud.loadbalancer.providers import get_driver
from libcloud.loadbalancer.base import Member, Algorithm
# pylint: enable=unused-import
if hasattr(libcloud, "__version__") and _LooseVersion(

View file

@ -49,10 +49,10 @@ import salt.utils.stringutils
try:
# Trying to import MySQLdb
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
from MySQLdb.constants import FIELD_TYPE, FLAG, CLIENT
import MySQLdb.cursors
from MySQLdb import OperationalError
from MySQLdb.constants import CLIENT, FIELD_TYPE, FLAG
except ImportError:
try:
# MySQLdb import failed, try to import PyMySQL
@ -60,10 +60,10 @@ except ImportError:
pymysql.install_as_MySQLdb()
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
from MySQLdb.constants import FIELD_TYPE, FLAG, CLIENT
import MySQLdb.cursors
from MySQLdb import OperationalError
from MySQLdb.constants import CLIENT, FIELD_TYPE, FLAG
except ImportError:
MySQLdb = None

View file

@ -40,8 +40,8 @@ try:
# pylint: disable=W0611
import capirca
import capirca.aclgen
import capirca.lib.policy
import capirca.lib.aclgenerator
import capirca.lib.policy
HAS_CAPIRCA = True
# pylint: enable=W0611

View file

@ -189,8 +189,7 @@ from salt.exceptions import CommandExecutionError
from salt.utils.args import clean_kwargs
try:
from netmiko import ConnectHandler
from netmiko import BaseConnection
from netmiko import BaseConnection, ConnectHandler
HAS_NETMIKO = True
except ImportError:

View file

@ -51,18 +51,18 @@ import logging
import salt.utils.platform
try:
from nsnitro.nsnitro import NSNitro
from nsnitro.nsexceptions import NSNitroError
from nsnitro.nsnitro import NSNitro
from nsnitro.nsresources.nslbvserver import NSLBVServer
from nsnitro.nsresources.nslbvserverservicegroupbinding import (
NSLBVServerServiceGroupBinding,
)
from nsnitro.nsresources.nsserver import NSServer
from nsnitro.nsresources.nsservice import NSService
from nsnitro.nsresources.nsservicegroup import NSServiceGroup
from nsnitro.nsresources.nsservicegroupserverbinding import (
NSServiceGroupServerBinding,
)
from nsnitro.nsresources.nslbvserver import NSLBVServer
from nsnitro.nsresources.nslbvserverservicegroupbinding import (
NSLBVServerServiceGroupBinding,
)
from nsnitro.nsresources.nssslvserversslcertkeybinding import (
NSSSLVServerSSLCertKeyBinding,
)

View file

@ -23,6 +23,7 @@ Module for sending data to OpsGenie
import logging
import requests
import salt.exceptions
import salt.utils.json

View file

@ -19,6 +19,7 @@ For PagerDuty API details, see https://developer.pagerduty.com/documentation/res
"""
import requests
import salt.utils.json

View file

@ -56,8 +56,15 @@ from datetime import datetime
from salt.exceptions import CommandExecutionError
try:
from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix
from purity_fb import rest, NfsRule, ProtocolRule
from purity_fb import (
FileSystem,
FileSystemSnapshot,
NfsRule,
ProtocolRule,
PurityFb,
SnapshotSuffix,
rest,
)
HAS_PURITY_FB = True
except ImportError:

View file

@ -9,8 +9,8 @@ import salt.utils.platform
from salt.utils.decorators import depends
try:
from pywintypes import error as PyWinError
import win32ts
from pywintypes import error as PyWinError
_HAS_WIN32TS_DEPENDENCIES = True
except ImportError:

View file

@ -7,6 +7,7 @@ import os
import jinja2
import jinja2.exceptions
import salt.utils.files
import salt.utils.json
import salt.utils.stringutils

View file

@ -31,8 +31,8 @@ if salt.utils.path.which("initctl"):
# Don't re-invent the wheel, import the helper functions from the
# upstart module.
from salt.modules.upstart_service import (
_upstart_enable,
_upstart_disable,
_upstart_enable,
_upstart_is_enabled,
)
except Exception as exc: # pylint: disable=broad-except

View file

@ -31,6 +31,7 @@ HAS_LIBS = False
try:
import gnupg # pylint: disable=unused-import
import salt.modules.gpg
HAS_LIBS = True

View file

@ -13,11 +13,12 @@ import datetime
import logging
import os
import yaml
import salt.utils.event
import salt.utils.files
import salt.utils.odict
import salt.utils.yaml
import yaml
try:
import dateutil.parser as dateutil_parser

View file

@ -12,8 +12,8 @@ import logging
# Import salt modules
try:
import scp
import paramiko
import scp
HAS_SCP = True
except ImportError:

View file

@ -51,10 +51,10 @@ log = logging.getLogger(__name__)
HAS_LIBS = False
try:
import smtplib
import email.mime.text
import email.mime.application
import email.mime.multipart
import email.mime.text
import smtplib
HAS_LIBS = True
except ImportError:

View file

@ -28,8 +28,8 @@ import subprocess
HAS_LIBS = False
try:
import splunklib.client
from splunklib.client import AuthenticationError
from splunklib.binding import HTTPError
from splunklib.client import AuthenticationError
HAS_LIBS = True
except ImportError:

View file

@ -27,8 +27,8 @@ from salt.utils.odict import OrderedDict
HAS_LIBS = False
try:
import splunklib.client
import requests
import splunklib.client
HAS_LIBS = True
except ImportError:

View file

@ -10,6 +10,7 @@ import os
import jinja2
import jinja2.exceptions
import salt.utils.files
import salt.utils.stringutils
import salt.utils.templates

View file

@ -33,8 +33,8 @@ try:
from twilio.rest import TwilioException as TwilioRestException
else:
TWILIO_5 = True
from twilio.rest import TwilioRestClient
from twilio import TwilioRestException # pylint: disable=no-name-in-module
from twilio.rest import TwilioRestClient
HAS_LIBS = True
except ImportError:
pass

View file

@ -136,6 +136,7 @@ from xml.etree import ElementTree
from xml.sax import saxutils
import jinja2.exceptions
import salt.utils.data
import salt.utils.files
import salt.utils.json

View file

@ -233,15 +233,9 @@ except ImportError:
try:
# pylint: disable=no-name-in-module
from pyVmomi import (
vim,
vmodl,
pbm,
VmomiSupport,
)
from pyVmomi import VmomiSupport, pbm, vim, vmodl
# pylint: enable=no-name-in-module
# We check the supported vim versions to infer the pyVmomi version
if (
"vim25/6.0" in VmomiSupport.versionMap
@ -260,10 +254,13 @@ except ImportError:
# vSphere SDK Automation
# pylint: disable=unused-import
try:
from com.vmware.cis.tagging_client import Category, CategoryModel
from com.vmware.cis.tagging_client import Tag, TagModel, TagAssociation
from com.vmware.vcenter_client import Cluster
from com.vmware.vapi.std_client import DynamicID
from com.vmware.cis.tagging_client import (
Category,
CategoryModel,
Tag,
TagAssociation,
TagModel,
)
# Error Handling
from com.vmware.vapi.std.errors_client import (
@ -273,6 +270,8 @@ try:
Unauthenticated,
Unauthorized,
)
from com.vmware.vapi.std_client import DynamicID
from com.vmware.vcenter_client import Cluster
vsphere_errors = (
AlreadyExists,

View file

@ -20,8 +20,9 @@ from salt.exceptions import CommandExecutionError
try:
import winreg
import win32security
import ntsecuritycon
import win32security
HAS_WINDOWS_MODULES = True
except ImportError:

View file

@ -8,6 +8,7 @@ import salt.utils.platform
try:
import wmi
import salt.utils.winapi
HAS_LIBS = True

View file

@ -99,6 +99,7 @@ try:
import win32con
import win32file
import win32security
import salt.platform.win
HAS_WINDOWS_MODULES = True

View file

@ -15,9 +15,9 @@ import salt.utils.win_functions
import salt.utils.winapi
try:
import pywintypes
import win32api
import win32com.client
import pywintypes
HAS_DEPENDENCIES = True
except ImportError:

View file

@ -13,9 +13,10 @@ import logging
import os
import re
import yaml
import salt.utils.json
import salt.utils.platform
import yaml
from salt.exceptions import CommandExecutionError, SaltInvocationError
log = logging.getLogger(__name__)

View file

@ -27,6 +27,7 @@ from salt.exceptions import SaltInvocationError
try:
import wmi
import salt.utils.winapi
_HAS_MODULE_DEPENDENCIES = True

View file

@ -25,6 +25,7 @@ log = logging.getLogger(__name__)
try:
if salt.utils.platform.is_windows():
import wmi
import salt.utils.winapi
HAS_WMI = True

View file

@ -24,12 +24,13 @@ import salt.utils.winapi
from salt.exceptions import CommandExecutionError
try:
from ctypes import windll
import pywintypes
import win32api
import win32con
import win32net
import wmi
from ctypes import windll
HAS_WIN32NET_MODS = True
except ImportError:

View file

@ -42,7 +42,6 @@ log = logging.getLogger(__name__)
try:
import pywintypes
import wmi
import win32api
import win32con
import win32net
@ -50,6 +49,7 @@ try:
import win32profile
import win32security
import win32ts
import wmi
HAS_WIN32NET_MODS = True
except ImportError:

View file

@ -14,16 +14,15 @@ import logging
import sys
try:
import kazoo.client
from kazoo.retry import ForceRetryError
import kazoo.recipe.lock
import kazoo.recipe.barrier
import kazoo.recipe.party
from kazoo.exceptions import CancelledError
from kazoo.exceptions import NoNodeError
from socket import gethostname
import kazoo.client
import kazoo.recipe.barrier
import kazoo.recipe.lock
import kazoo.recipe.party
from kazoo.exceptions import CancelledError, NoNodeError
from kazoo.retry import ForceRetryError
# TODO: use the kazoo one, waiting for pull req:
# https://github.com/python-zk/kazoo/pull/206
class _Semaphore(kazoo.recipe.lock.Semaphore):

View file

@ -597,6 +597,7 @@ from multiprocessing import Pipe, Process
from urllib.parse import parse_qsl
import cherrypy # pylint: disable=import-error,3rd-party-module-not-gated
import salt
import salt.auth
import salt.exceptions
@ -627,8 +628,8 @@ except ImportError:
try:
# Imports related to websocket
from .tools import websockets
from . import event_processor
from .tools import websockets
HAS_WEBSOCKETS = True
except ImportError:

View file

@ -55,8 +55,8 @@ def bootstrap_app():
"""
Grab the opts dict of the master config by trying to import Salt
"""
from salt.netapi.rest_cherrypy import app
import salt.config
from salt.netapi.rest_cherrypy import app
__opts__ = salt.config.client_config(
os.environ.get("SALT_MASTER_CONFIG", "/etc/salt/master")

View file

@ -1140,8 +1140,8 @@ class Pillar:
# the git ext_pillar() func is run, but only for masterless.
if self.ext and "git" in self.ext and self.opts.get("__role") != "minion":
# Avoid circular import
import salt.utils.gitfs
import salt.pillar.git_pillar
import salt.utils.gitfs
git_pillar = salt.utils.gitfs.GitPillar(
self.opts,

View file

@ -61,8 +61,8 @@ from salt.utils.versions import StrictVersion as _StrictVersion
try:
import boto.ec2
import boto.utils
import boto.exception
import boto.utils
HAS_BOTO = True
except ImportError:

View file

@ -380,8 +380,8 @@ import os
import salt.utils.yaml
try:
from mako.lookup import TemplateLookup
from mako import exceptions
from mako.lookup import TemplateLookup
HAS_MAKO = True
except ImportError:

View file

@ -56,8 +56,8 @@ log = logging.getLogger(__name__)
try:
# Trying to import MySQLdb
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
import MySQLdb.cursors
except ImportError:
try:
# MySQLdb import failed, try to import PyMySQL
@ -65,8 +65,8 @@ except ImportError:
pymysql.install_as_MySQLdb()
import MySQLdb
import MySQLdb.cursors
import MySQLdb.converters
import MySQLdb.cursors
except ImportError:
MySQLdb = None

View file

@ -270,6 +270,7 @@ import re
import sys
import jinja2
import salt.utils.files
import salt.utils.yaml
@ -597,9 +598,10 @@ if __name__ == "__main__":
__opts__["pepa_validate"] = True
if args.query_api:
import requests
import getpass
import requests
username = args.username
password = args.password
if username is None:
@ -660,8 +662,8 @@ if __name__ == "__main__":
try:
# pylint: disable=import-error
import pygments
import pygments.lexers
import pygments.formatters
import pygments.lexers
# pylint: disable=no-member
print(

View file

@ -125,6 +125,7 @@ import logging
import os
import jinja2
import salt.utils.data
from salt.exceptions import SaltInvocationError

View file

@ -378,10 +378,11 @@ import logging
import os
import posixpath
from jinja2 import Environment, FileSystemLoader
import salt.utils.data
import salt.utils.jinja
import salt.utils.yaml
from jinja2 import Environment, FileSystemLoader
log = logging.getLogger(__name__)
strategies = ("overwrite", "merge-first", "merge-last", "remove")

View file

@ -149,8 +149,8 @@ import salt.utils.vmware
try:
# pylint: disable=no-name-in-module
from pyVmomi import vim
from pyVim.connect import Disconnect
from pyVmomi import vim
HAS_LIBS = True
# pylint: enable=no-name-in-module

View file

@ -190,8 +190,10 @@ import salt.utils.args
try:
from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException
from netmiko.ssh_exception import NetMikoAuthenticationException
from netmiko.ssh_exception import (
NetMikoAuthenticationException,
NetMikoTimeoutException,
)
HAS_NETMIKO = True
except ImportError:

View file

@ -69,8 +69,8 @@ import salt.utils.stringio
from salt.exceptions import SaltConfigurationError
try:
import botocore.exceptions
import boto3
import botocore.exceptions
logging.getLogger("boto3").setLevel(logging.CRITICAL)
except ImportError:

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