mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[fix] sanity check errors on pylint
This commit is contained in:
parent
5f90169d73
commit
b8e21bca46
1 changed files with 17 additions and 15 deletions
|
@ -298,10 +298,10 @@ else:
|
||||||
|
|
||||||
def package_split(pkgspec):
|
def package_split(pkgspec):
|
||||||
parts = pkgspec.split('=', 1)
|
parts = pkgspec.split('=', 1)
|
||||||
|
version = None
|
||||||
if len(parts) > 1:
|
if len(parts) > 1:
|
||||||
return parts[0], parts[1]
|
version = parts[1]
|
||||||
else:
|
return parts[0], version
|
||||||
return parts[0], None
|
|
||||||
|
|
||||||
|
|
||||||
def package_versions(pkgname, pkg, pkg_cache):
|
def package_versions(pkgname, pkg, pkg_cache):
|
||||||
|
@ -443,7 +443,7 @@ def expand_pkgspec_from_fnmatches(m, pkgspec, cache):
|
||||||
|
|
||||||
matches = fnmatch.filter(pkg_name_cache, pkgname_pattern)
|
matches = fnmatch.filter(pkg_name_cache, pkgname_pattern)
|
||||||
|
|
||||||
if len(matches) == 0:
|
if not matches:
|
||||||
m.fail_json(msg="No package(s) matching '%s' available" % str(pkgname_pattern))
|
m.fail_json(msg="No package(s) matching '%s' available" % str(pkgname_pattern))
|
||||||
else:
|
else:
|
||||||
new_pkgspec.extend(matches)
|
new_pkgspec.extend(matches)
|
||||||
|
@ -503,7 +503,7 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
||||||
pkg_list.append("'%s'" % package)
|
pkg_list.append("'%s'" % package)
|
||||||
packages = ' '.join(pkg_list)
|
packages = ' '.join(pkg_list)
|
||||||
|
|
||||||
if len(packages) != 0:
|
if packages:
|
||||||
if force:
|
if force:
|
||||||
force_yes = '--force-yes'
|
force_yes = '--force-yes'
|
||||||
else:
|
else:
|
||||||
|
@ -546,10 +546,12 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
||||||
diff = parse_diff(out)
|
diff = parse_diff(out)
|
||||||
else:
|
else:
|
||||||
diff = {}
|
diff = {}
|
||||||
|
status = True
|
||||||
|
data = dict(changed=True, stdout=out, stderr=err, diff=diff)
|
||||||
if rc:
|
if rc:
|
||||||
return (False, dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc))
|
status = False
|
||||||
else:
|
data = dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc)
|
||||||
return (True, dict(changed=True, stdout=out, stderr=err, diff=diff))
|
return (status, data)
|
||||||
else:
|
else:
|
||||||
return (True, dict(changed=False))
|
return (True, dict(changed=False))
|
||||||
|
|
||||||
|
@ -603,7 +605,7 @@ def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated
|
||||||
|
|
||||||
# install the deps through apt
|
# install the deps through apt
|
||||||
retvals = {}
|
retvals = {}
|
||||||
if len(deps_to_install) > 0:
|
if deps_to_install:
|
||||||
(success, retvals) = install(m=m, pkgspec=deps_to_install, cache=cache,
|
(success, retvals) = install(m=m, pkgspec=deps_to_install, cache=cache,
|
||||||
install_recommends=install_recommends,
|
install_recommends=install_recommends,
|
||||||
dpkg_options=expand_dpkg_options(dpkg_options))
|
dpkg_options=expand_dpkg_options(dpkg_options))
|
||||||
|
@ -611,7 +613,7 @@ def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated
|
||||||
m.fail_json(**retvals)
|
m.fail_json(**retvals)
|
||||||
changed = retvals.get('changed', False)
|
changed = retvals.get('changed', False)
|
||||||
|
|
||||||
if len(pkgs_to_install) > 0:
|
if pkgs_to_install:
|
||||||
options = ' '.join(["--%s"% x for x in dpkg_options.split(",")])
|
options = ' '.join(["--%s"% x for x in dpkg_options.split(",")])
|
||||||
if m.check_mode:
|
if m.check_mode:
|
||||||
options += " --simulate"
|
options += " --simulate"
|
||||||
|
@ -654,7 +656,7 @@ def remove(m, pkgspec, cache, purge=False, force=False,
|
||||||
pkg_list.append("'%s'" % package)
|
pkg_list.append("'%s'" % package)
|
||||||
packages = ' '.join(pkg_list)
|
packages = ' '.join(pkg_list)
|
||||||
|
|
||||||
if len(packages) == 0:
|
if not packages:
|
||||||
m.exit_json(changed=False)
|
m.exit_json(changed=False)
|
||||||
else:
|
else:
|
||||||
if force:
|
if force:
|
||||||
|
@ -811,12 +813,12 @@ def get_cache_mtime():
|
||||||
Stat the apt cache file and if no cache file is found return 0
|
Stat the apt cache file and if no cache file is found return 0
|
||||||
:returns: ``int``
|
:returns: ``int``
|
||||||
"""
|
"""
|
||||||
|
cache_time = 0
|
||||||
if os.path.exists(APT_UPDATE_SUCCESS_STAMP_PATH):
|
if os.path.exists(APT_UPDATE_SUCCESS_STAMP_PATH):
|
||||||
return os.stat(APT_UPDATE_SUCCESS_STAMP_PATH).st_mtime
|
cache_time = os.stat(APT_UPDATE_SUCCESS_STAMP_PATH).st_mtime
|
||||||
elif os.path.exists(APT_LISTS_PATH):
|
elif os.path.exists(APT_LISTS_PATH):
|
||||||
return os.stat(APT_LISTS_PATH).st_mtime
|
cache_time = os.stat(APT_LISTS_PATH).st_mtime
|
||||||
else:
|
return cache_time
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def get_updated_cache_time():
|
def get_updated_cache_time():
|
||||||
|
|
Loading…
Reference in a new issue