mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[fix] pylint errors on modules packaging language (#30748)
* cleaning pylint errors for module packaging/language/*
This commit is contained in:
parent
e767c7d694
commit
cddff32792
7 changed files with 39 additions and 38 deletions
|
@ -217,12 +217,12 @@ def main():
|
||||||
changed = False
|
changed = False
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
installed, missing, outdated = bower.list()
|
installed, missing, outdated = bower.list()
|
||||||
if len(missing):
|
if missing:
|
||||||
changed = True
|
changed = True
|
||||||
bower.install()
|
bower.install()
|
||||||
elif state == 'latest':
|
elif state == 'latest':
|
||||||
installed, missing, outdated = bower.list()
|
installed, missing, outdated = bower.list()
|
||||||
if len(missing) or len(outdated):
|
if missing or outdated:
|
||||||
changed = True
|
changed = True
|
||||||
bower.update()
|
bower.update()
|
||||||
else: # Absent
|
else: # Absent
|
||||||
|
|
|
@ -136,9 +136,10 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
def get_bundler_executable(module):
|
def get_bundler_executable(module):
|
||||||
if module.params.get('executable'):
|
if module.params.get('executable'):
|
||||||
return module.params.get('executable').split(' ')
|
result = module.params.get('executable').split(' ')
|
||||||
else:
|
else:
|
||||||
return [ module.get_bin_path('bundle', True) ]
|
result = [module.get_bin_path('bundle', True)]
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -139,10 +139,7 @@ def _is_package_installed(module, name, locallib, cpanm, version):
|
||||||
else:
|
else:
|
||||||
cmd = "%s;'" % cmd
|
cmd = "%s;'" % cmd
|
||||||
res, stdout, stderr = module.run_command(cmd, check_rc=False)
|
res, stdout, stderr = module.run_command(cmd, check_rc=False)
|
||||||
if res == 0:
|
return res == 0
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, installdeps, cpanm, use_sudo):
|
def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, installdeps, cpanm, use_sudo):
|
||||||
# this code should use "%s" like everything else and just return early but not fixing all of it now.
|
# this code should use "%s" like everything else and just return early but not fixing all of it now.
|
||||||
|
@ -175,9 +172,10 @@ def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, inst
|
||||||
|
|
||||||
def _get_cpanm_path(module):
|
def _get_cpanm_path(module):
|
||||||
if module.params['executable']:
|
if module.params['executable']:
|
||||||
return module.params['executable']
|
result = module.params['executable']
|
||||||
else:
|
else:
|
||||||
return module.get_bin_path('cpanm', True)
|
result = module.get_bin_path('cpanm', True)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -116,9 +116,10 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
def get_rubygems_path(module):
|
def get_rubygems_path(module):
|
||||||
if module.params['executable']:
|
if module.params['executable']:
|
||||||
return module.params['executable'].split(' ')
|
result = module.params['executable'].split(' ')
|
||||||
else:
|
else:
|
||||||
return [ module.get_bin_path('gem', True) ]
|
result = [module.get_bin_path('gem', True)]
|
||||||
|
return result
|
||||||
|
|
||||||
def get_rubygems_version(module):
|
def get_rubygems_version(module):
|
||||||
cmd = get_rubygems_path(module) + [ '--version' ]
|
cmd = get_rubygems_path(module) + [ '--version' ]
|
||||||
|
|
|
@ -189,7 +189,7 @@ def adjust_recursive_directory_permissions(pre_existing_dir, new_directory_list,
|
||||||
Walk the new directories list and make sure that permissions are as we would expect
|
Walk the new directories list and make sure that permissions are as we would expect
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if len(new_directory_list) > 0:
|
if new_directory_list:
|
||||||
working_dir = os.path.join(pre_existing_dir, new_directory_list.pop(0))
|
working_dir = os.path.join(pre_existing_dir, new_directory_list.pop(0))
|
||||||
directory_args['path'] = working_dir
|
directory_args['path'] = working_dir
|
||||||
changed = module.set_fs_attributes_if_different(directory_args, changed)
|
changed = module.set_fs_attributes_if_different(directory_args, changed)
|
||||||
|
@ -220,15 +220,14 @@ class Artifact(object):
|
||||||
def path(self, with_version=True):
|
def path(self, with_version=True):
|
||||||
base = posixpath.join(self.group_id.replace(".", "/"), self.artifact_id)
|
base = posixpath.join(self.group_id.replace(".", "/"), self.artifact_id)
|
||||||
if with_version and self.version:
|
if with_version and self.version:
|
||||||
return posixpath.join(base, self.version)
|
base = posixpath.join(base, self.version)
|
||||||
else:
|
return base
|
||||||
return base
|
|
||||||
|
|
||||||
def _generate_filename(self):
|
def _generate_filename(self):
|
||||||
|
filename = self.artifact_id + "-" + self.classifier + "." + self.extension
|
||||||
if not self.classifier:
|
if not self.classifier:
|
||||||
return self.artifact_id + "." + self.extension
|
filename = self.artifact_id + "." + self.extension
|
||||||
else:
|
return filename
|
||||||
return self.artifact_id + "-" + self.classifier + "." + self.extension
|
|
||||||
|
|
||||||
def get_filename(self, filename=None):
|
def get_filename(self, filename=None):
|
||||||
if not filename:
|
if not filename:
|
||||||
|
@ -238,12 +237,12 @@ class Artifact(object):
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
result = "%s:%s:%s" % (self.group_id, self.artifact_id, self.version)
|
||||||
if self.classifier:
|
if self.classifier:
|
||||||
return "%s:%s:%s:%s:%s" % (self.group_id, self.artifact_id, self.extension, self.classifier, self.version)
|
result = "%s:%s:%s:%s:%s" % (self.group_id, self.artifact_id, self.extension, self.classifier, self.version)
|
||||||
elif self.extension != "jar":
|
elif self.extension != "jar":
|
||||||
return "%s:%s:%s:%s" % (self.group_id, self.artifact_id, self.extension, self.version)
|
result = "%s:%s:%s:%s" % (self.group_id, self.artifact_id, self.extension, self.version)
|
||||||
else:
|
return result
|
||||||
return "%s:%s:%s" % (self.group_id, self.artifact_id, self.version)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(input):
|
def parse(input):
|
||||||
|
@ -293,8 +292,10 @@ class MavenDownloader:
|
||||||
timestamp = xml.xpath("/metadata/versioning/snapshot/timestamp/text()")[0]
|
timestamp = xml.xpath("/metadata/versioning/snapshot/timestamp/text()")[0]
|
||||||
buildNumber = xml.xpath("/metadata/versioning/snapshot/buildNumber/text()")[0]
|
buildNumber = xml.xpath("/metadata/versioning/snapshot/buildNumber/text()")[0]
|
||||||
for snapshotArtifact in xml.xpath("/metadata/versioning/snapshotVersions/snapshotVersion"):
|
for snapshotArtifact in xml.xpath("/metadata/versioning/snapshotVersions/snapshotVersion"):
|
||||||
artifact_classifier = snapshotArtifact.xpath("classifier/text()")[0] if len(snapshotArtifact.xpath("classifier/text()")) > 0 else ''
|
classifier = snapshotArtifact.xpath("classifier/text()")
|
||||||
artifact_extension = snapshotArtifact.xpath("extension/text()")[0] if len(snapshotArtifact.xpath("extension/text()")) > 0 else ''
|
artifact_classifier = classifier[0] if classifier else ''
|
||||||
|
extension = snapshotArtifact.xpath("extension/text()")
|
||||||
|
artifact_extension = extension[0] if extension else ''
|
||||||
if artifact_classifier == artifact.classifier and artifact_extension == artifact.extension:
|
if artifact_classifier == artifact.classifier and artifact_extension == artifact.extension:
|
||||||
return self._uri_for_artifact(artifact, snapshotArtifact.xpath("value/text()")[0])
|
return self._uri_for_artifact(artifact, snapshotArtifact.xpath("value/text()")[0])
|
||||||
return self._uri_for_artifact(artifact, artifact.version.replace("SNAPSHOT", timestamp + "-" + buildNumber))
|
return self._uri_for_artifact(artifact, artifact.version.replace("SNAPSHOT", timestamp + "-" + buildNumber))
|
||||||
|
@ -342,6 +343,7 @@ class MavenDownloader:
|
||||||
artifact.classifier, artifact.extension)
|
artifact.classifier, artifact.extension)
|
||||||
|
|
||||||
url = self.find_uri_for_artifact(artifact)
|
url = self.find_uri_for_artifact(artifact)
|
||||||
|
result = True
|
||||||
if not self.verify_md5(filename, url + ".md5"):
|
if not self.verify_md5(filename, url + ".md5"):
|
||||||
response = self._request(url, "Failed to download artifact " + str(artifact), lambda r: r)
|
response = self._request(url, "Failed to download artifact " + str(artifact), lambda r: r)
|
||||||
if response:
|
if response:
|
||||||
|
@ -349,11 +351,9 @@ class MavenDownloader:
|
||||||
# f.write(response.read())
|
# f.write(response.read())
|
||||||
self._write_chunks(response, f, report_hook=self.chunk_report)
|
self._write_chunks(response, f, report_hook=self.chunk_report)
|
||||||
f.close()
|
f.close()
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
return False
|
result = False
|
||||||
else:
|
return result
|
||||||
return True
|
|
||||||
|
|
||||||
def chunk_report(self, bytes_so_far, chunk_size, total_size):
|
def chunk_report(self, bytes_so_far, chunk_size, total_size):
|
||||||
percent = float(bytes_so_far) / total_size
|
percent = float(bytes_so_far) / total_size
|
||||||
|
@ -383,12 +383,12 @@ class MavenDownloader:
|
||||||
return bytes_so_far
|
return bytes_so_far
|
||||||
|
|
||||||
def verify_md5(self, file, remote_md5):
|
def verify_md5(self, file, remote_md5):
|
||||||
if not os.path.exists(file):
|
result = False
|
||||||
return False
|
if os.path.exists(file):
|
||||||
else:
|
|
||||||
local_md5 = self._local_md5(file)
|
local_md5 = self._local_md5(file)
|
||||||
remote = self._request(remote_md5, "Failed to download MD5", lambda r: r.read())
|
remote = self._request(remote_md5, "Failed to download MD5", lambda r: r.read())
|
||||||
return local_md5 == remote
|
result = local_md5 == remote
|
||||||
|
return result
|
||||||
|
|
||||||
def _local_md5(self, file):
|
def _local_md5(self, file):
|
||||||
md5 = hashlib.md5()
|
md5 = hashlib.md5()
|
||||||
|
|
|
@ -264,16 +264,16 @@ def main():
|
||||||
changed = False
|
changed = False
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
installed, missing = npm.list()
|
installed, missing = npm.list()
|
||||||
if len(missing):
|
if missing:
|
||||||
changed = True
|
changed = True
|
||||||
npm.install()
|
npm.install()
|
||||||
elif state == 'latest':
|
elif state == 'latest':
|
||||||
installed, missing = npm.list()
|
installed, missing = npm.list()
|
||||||
outdated = npm.list_outdated()
|
outdated = npm.list_outdated()
|
||||||
if len(missing):
|
if missing:
|
||||||
changed = True
|
changed = True
|
||||||
npm.install()
|
npm.install()
|
||||||
if len(outdated):
|
if outdated:
|
||||||
changed = True
|
changed = True
|
||||||
npm.update()
|
npm.update()
|
||||||
else: # absent
|
else: # absent
|
||||||
|
|
|
@ -85,9 +85,10 @@ def get_local_version(pear_output):
|
||||||
|
|
||||||
def _get_pear_path(module):
|
def _get_pear_path(module):
|
||||||
if module.params['executable'] and os.path.isfile(module.params['executable']):
|
if module.params['executable'] and os.path.isfile(module.params['executable']):
|
||||||
return module.params['executable']
|
result = module.params['executable']
|
||||||
else:
|
else:
|
||||||
return module.get_bin_path('pear', True, [module.params['executable']])
|
result = module.get_bin_path('pear', True, [module.params['executable']])
|
||||||
|
return result
|
||||||
|
|
||||||
def get_repository_version(pear_output):
|
def get_repository_version(pear_output):
|
||||||
"""Take pear remote-info output and get the latest version"""
|
"""Take pear remote-info output and get the latest version"""
|
||||||
|
|
Loading…
Reference in a new issue