mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
E501 fixes (#22879)
This commit is contained in:
@@ -620,7 +620,8 @@ def _load_params():
|
||||
except KeyError:
|
||||
# This helper does not have access to fail_json so we have to print
|
||||
# json output on our own.
|
||||
print('\n{"msg": "Error: Module unable to locate ANSIBLE_MODULE_ARGS in json data from stdin. Unable to figure out what parameters were passed", "failed": true}')
|
||||
print('\n{"msg": "Error: Module unable to locate ANSIBLE_MODULE_ARGS in json data from stdin. Unable to figure out what parameters were passed", '
|
||||
'"failed": true}')
|
||||
sys.exit(1)
|
||||
|
||||
def env_fallback(*args, **kwargs):
|
||||
@@ -691,7 +692,9 @@ class AnsibleModule(object):
|
||||
self._deprecations = []
|
||||
|
||||
self.aliases = {}
|
||||
self._legal_inputs = ['_ansible_check_mode', '_ansible_no_log', '_ansible_debug', '_ansible_diff', '_ansible_verbosity', '_ansible_selinux_special_fs', '_ansible_module_name', '_ansible_version', '_ansible_syslog_facility', '_ansible_socket']
|
||||
self._legal_inputs = ['_ansible_check_mode', '_ansible_no_log', '_ansible_debug', '_ansible_diff', '_ansible_verbosity',
|
||||
'_ansible_selinux_special_fs', '_ansible_module_name', '_ansible_version', '_ansible_syslog_facility',
|
||||
'_ansible_socket']
|
||||
|
||||
if add_file_common_args:
|
||||
for k, v in FILE_COMMON_ARGUMENTS.items():
|
||||
@@ -2147,7 +2150,8 @@ class AnsibleModule(object):
|
||||
# would end in something like:
|
||||
# file = _os.path.join(dir, pre + name + suf)
|
||||
# TypeError: can't concat bytes to str
|
||||
self.fail_json(msg='Failed creating temp file for atomic move. This usually happens when using Python3 less than Python3.5. Please use Python2.x or Python3.5 or greater.', exception=traceback.format_exc())
|
||||
self.fail_json(msg='Failed creating temp file for atomic move. This usually happens when using Python3 less than Python3.5. '
|
||||
'Please use Python2.x or Python3.5 or greater.', exception=traceback.format_exc())
|
||||
|
||||
b_tmp_dest_name = to_bytes(tmp_dest_name, errors='surrogate_or_strict')
|
||||
|
||||
@@ -2232,7 +2236,8 @@ class AnsibleModule(object):
|
||||
|
||||
return data
|
||||
|
||||
def run_command(self, args, check_rc=False, close_fds=True, executable=None, data=None, binary_data=False, path_prefix=None, cwd=None, use_unsafe_shell=False, prompt_regex=None, environ_update=None, umask=None, encoding='utf-8', errors='surrogate_or_strict'):
|
||||
def run_command(self, args, check_rc=False, close_fds=True, executable=None, data=None, binary_data=False, path_prefix=None, cwd=None,
|
||||
use_unsafe_shell=False, prompt_regex=None, environ_update=None, umask=None, encoding='utf-8', errors='surrogate_or_strict'):
|
||||
'''
|
||||
Execute a command, returns rc, stdout, and stderr.
|
||||
|
||||
|
||||
@@ -95,7 +95,8 @@ def boto3_conn(module, conn_type=None, resource=None, region=None, endpoint=None
|
||||
try:
|
||||
return _boto3_conn(conn_type=conn_type, resource=resource, region=region, endpoint=endpoint, **params)
|
||||
except ValueError:
|
||||
module.fail_json(msg='There is an issue in the code of the module. You must specify either both, resource or client to the conn_type parameter in the boto3_conn function call')
|
||||
module.fail_json(msg='There is an issue in the code of the module. You must specify either both, resource or client to the conn_type '
|
||||
'parameter in the boto3_conn function call')
|
||||
|
||||
def _boto3_conn(conn_type=None, resource=None, region=None, endpoint=None, **params):
|
||||
profile = params.pop('profile_name', None)
|
||||
@@ -257,7 +258,8 @@ def connect_to_aws(aws_module, region, **params):
|
||||
conn = aws_module.connect_to_region(region, **params)
|
||||
if not conn:
|
||||
if region not in [aws_module_region.name for aws_module_region in aws_module.regions()]:
|
||||
raise AnsibleAWSError("Region %s does not seem to be available for aws module %s. If the region definitely exists, you may need to upgrade boto or extend with endpoints_path" % (region, aws_module.__name__))
|
||||
raise AnsibleAWSError("Region %s does not seem to be available for aws module %s. If the region definitely exists, you may need to upgrade "
|
||||
"boto or extend with endpoints_path" % (region, aws_module.__name__))
|
||||
else:
|
||||
raise AnsibleAWSError("Unknown problem connecting to region %s for aws module %s." % (region, aws_module.__name__))
|
||||
if params.get('profile_name'):
|
||||
|
||||
@@ -677,8 +677,8 @@ class Distribution(object):
|
||||
SLC = 'RedHat', Ascendos = 'RedHat', CloudLinux = 'RedHat', PSBM = 'RedHat',
|
||||
OracleLinux = 'RedHat', OVS = 'RedHat', OEL = 'RedHat', Amazon = 'RedHat',
|
||||
XenServer = 'RedHat', Ubuntu = 'Debian', Debian = 'Debian', Raspbian = 'Debian', Slackware = 'Slackware', SLES = 'Suse',
|
||||
SLED = 'Suse', openSUSE = 'Suse', openSUSE_Tumbleweed = 'Suse', SuSE = 'Suse', SLES_SAP = 'Suse', SUSE_LINUX = 'Suse', Gentoo = 'Gentoo', Funtoo = 'Gentoo',
|
||||
Archlinux = 'Archlinux', Manjaro = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake', Altlinux = 'Altlinux', SMGL = 'SMGL',
|
||||
SLED = 'Suse', openSUSE = 'Suse', openSUSE_Tumbleweed = 'Suse', SuSE = 'Suse', SLES_SAP = 'Suse', SUSE_LINUX = 'Suse', Gentoo = 'Gentoo',
|
||||
Funtoo = 'Gentoo', Archlinux = 'Archlinux', Manjaro = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake', Altlinux = 'Altlinux', SMGL = 'SMGL',
|
||||
Solaris = 'Solaris', Nexenta = 'Solaris', OmniOS = 'Solaris', OpenIndiana = 'Solaris',
|
||||
SmartOS = 'Solaris', AIX = 'AIX', Alpine = 'Alpine', MacOSX = 'Darwin',
|
||||
FreeBSD = 'FreeBSD', HPUX = 'HP-UX', openSUSE_Leap = 'Suse', Neon = 'Debian'
|
||||
@@ -1658,7 +1658,15 @@ class SunOSHardware(Hardware):
|
||||
for line in fstab.splitlines():
|
||||
fields = line.split('\t')
|
||||
size_total, size_available = self._get_mount_size_facts(fields[1])
|
||||
self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3], 'time': fields[4], 'size_total': size_total, 'size_available': size_available})
|
||||
self.facts['mounts'].append({
|
||||
'mount': fields[1],
|
||||
'device': fields[0],
|
||||
'fstype' : fields[2],
|
||||
'options': fields[3],
|
||||
'time': fields[4],
|
||||
'size_total': size_total,
|
||||
'size_available': size_available
|
||||
})
|
||||
|
||||
def get_dmi_facts(self):
|
||||
uname_path = self.module.get_bin_path("prtdiag")
|
||||
@@ -1785,7 +1793,14 @@ class OpenBSDHardware(Hardware):
|
||||
if fields[1] == 'none' or fields[3] == 'xx':
|
||||
continue
|
||||
size_total, size_available = self._get_mount_size_facts(fields[1])
|
||||
self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3], 'size_total': size_total, 'size_available': size_available})
|
||||
self.facts['mounts'].append({
|
||||
'mount': fields[1],
|
||||
'device': fields[0],
|
||||
'fstype' : fields[2],
|
||||
'options': fields[3],
|
||||
'size_total': size_total,
|
||||
'size_available': size_available
|
||||
})
|
||||
|
||||
|
||||
def get_memory_facts(self):
|
||||
@@ -1926,7 +1941,14 @@ class FreeBSDHardware(Hardware):
|
||||
continue
|
||||
fields = re.sub(r'\s+',' ',line).split()
|
||||
size_total, size_available = self._get_mount_size_facts(fields[1])
|
||||
self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3], 'size_total': size_total, 'size_available': size_available})
|
||||
self.facts['mounts'].append({
|
||||
'mount': fields[1],
|
||||
'device': fields[0],
|
||||
'fstype': fields[2],
|
||||
'options': fields[3],
|
||||
'size_total': size_total,
|
||||
'size_available': size_available
|
||||
})
|
||||
|
||||
def get_device_facts(self):
|
||||
sysdir = '/dev'
|
||||
@@ -2057,7 +2079,14 @@ class NetBSDHardware(Hardware):
|
||||
continue
|
||||
fields = re.sub(r'\s+',' ',line).split()
|
||||
size_total, size_available = self._get_mount_size_facts(fields[1])
|
||||
self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3], 'size_total': size_total, 'size_available': size_available})
|
||||
self.facts['mounts'].append({
|
||||
'mount': fields[1],
|
||||
'device': fields[0],
|
||||
'fstype' : fields[2],
|
||||
'options': fields[3],
|
||||
'size_total': size_total,
|
||||
'size_available': size_available
|
||||
})
|
||||
|
||||
def get_dmi_facts(self):
|
||||
# We don't use dmidecode(1) here because:
|
||||
@@ -2316,7 +2345,8 @@ class HPUX(Hardware):
|
||||
#For systems where memory details aren't sent to syslog or the log has rotated, use parsed
|
||||
#adb output. Unfortunately /dev/kmem doesn't have world-read, so this only works as root.
|
||||
if os.access("/dev/kmem", os.R_OK):
|
||||
rc, out, err = self.module.run_command("echo 'phys_mem_pages/D' | adb -k /stand/vmunix /dev/kmem | tail -1 | awk '{print $2}'", use_unsafe_shell=True)
|
||||
rc, out, err = self.module.run_command("echo 'phys_mem_pages/D' | adb -k /stand/vmunix /dev/kmem | tail -1 | awk '{print $2}'",
|
||||
use_unsafe_shell=True)
|
||||
if not err:
|
||||
data = out
|
||||
self.facts['memtotal_mb'] = int(data) / 256
|
||||
|
||||
@@ -35,7 +35,8 @@ try:
|
||||
except ImportError:
|
||||
mysqldb_found = False
|
||||
|
||||
def mysql_connect(module, login_user=None, login_password=None, config_file='', ssl_cert=None, ssl_key=None, ssl_ca=None, db=None, cursor_class=None, connect_timeout=30):
|
||||
def mysql_connect(module, login_user=None, login_password=None, config_file='', ssl_cert=None, ssl_key=None, ssl_ca=None, db=None, cursor_class=None,
|
||||
connect_timeout=30):
|
||||
config = {}
|
||||
|
||||
if ssl_ca is not None or ssl_key is not None or ssl_cert is not None:
|
||||
|
||||
Reference in New Issue
Block a user