Ran pre-commit on the changed files

This commit is contained in:
Dmitry Kuzmenko 2020-08-28 14:47:43 +03:00 committed by Daniel Wozniak
parent 2b67bbd469
commit 1aeee46cfc
2 changed files with 4 additions and 20 deletions

View file

@ -1,21 +1,13 @@
# -*- coding: utf-8 -*-
"""
Scan a netmask or ipaddr for open ssh ports
"""
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import copy
import logging
import socket
# Import salt libs
import salt.utils.network
from salt._compat import ipaddress
from salt.ext import six
# Import 3rd-party libs
from salt.ext.six.moves import map # pylint: disable=import-error,redefined-builtin
log = logging.getLogger(__name__)
@ -30,7 +22,7 @@ def targets(tgt, tgt_type="glob", **kwargs):
return rmatcher.targets()
class RosterMatcher(object):
class RosterMatcher:
"""
Matcher for the roster data structure
"""
@ -49,7 +41,7 @@ class RosterMatcher(object):
ports = __opts__["ssh_scan_ports"]
if not isinstance(ports, list):
# Comma-separate list of integers
ports = list(map(int, six.text_type(ports).split(",")))
ports = list(map(int, str(ports).split(",")))
if self.tgt_type == "list":
tgts = self.tgt
else:
@ -63,7 +55,7 @@ class RosterMatcher(object):
except ValueError:
pass
for addr in addrs:
addr = six.text_type(addr)
addr = str(addr)
ret[addr] = copy.deepcopy(__opts__.get("roster_defaults", {}))
log.trace("Scanning host: %s", addr)
for port in ports:
@ -75,6 +67,6 @@ class RosterMatcher(object):
sock.shutdown(socket.SHUT_RDWR)
sock.close()
ret[addr].update({"host": addr, "port": port})
except socket.error:
except OSError:
pass
return ret

View file

@ -1,19 +1,11 @@
# -*- coding: utf-8 -*-
"""
Test the scan roster.
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import socket
# Import Salt Libs
import salt.roster.scan as scan_
from tests.support import mixins
# Import Salt Testing Libs
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase