diff --git a/centos2almaconverter/actions/common_checks.py b/centos2almaconverter/actions/common_checks.py index e094010..e30241e 100644 --- a/centos2almaconverter/actions/common_checks.py +++ b/centos2almaconverter/actions/common_checks.py @@ -9,6 +9,9 @@ from pleskdistup.common import action, dist, files, log, version +# Todo. Action is not relevant now, because we checking the same thing of framework side +# Additionaly platrofm module has no linux_distribution method in modern version of python +# so we should migrate to our common.distro class AssertDistroIsCentos79(action.CheckAction): def __init__(self): self.name = "checking if distro is CentOS7" @@ -30,7 +33,7 @@ def __init__(self): self.description = "You are running a distributive other than AlmaLinux 8. The finalization stage can only be started on AlmaLinux 8." def _do_check(self) -> bool: - return dist.get_distro() == dist.Distro.ALMALINUX8 + return dist.get_distro() == dist.AlmaLinux("8") class AssertNoMoreThenOneKernelNamedNIC(action.CheckAction): @@ -71,13 +74,13 @@ def _get_kernel_version_in_use(self) -> version.KernelVersion: return version.KernelVersion(curr_kernel) def _get_last_installed_kernel_version(self) -> version.KernelVersion: - versions = subprocess.check_output(["/usr/bin/rpm", "-q", "-a", "kernel"], universal_newlines=True).splitlines() + rpm_output = subprocess.check_output(["/usr/bin/rpm", "-q", "-a", "kernel"], universal_newlines=True).splitlines() # There is 'kernel-' prefix, that doesn't matter for us now, so just skip it - versions = [ver.split("-", 1)[-1] for ver in versions] + rpm_output = [ver.split("-", 1)[-1] for ver in rpm_output] - log.debug("Installed kernel versions: {}".format(', '.join(versions))) + log.debug("Installed kernel versions: {}".format(', '.join(rpm_output))) - versions = [version.KernelVersion(ver) for ver in versions] + versions = [version.KernelVersion(ver) for ver in rpm_output] return max(versions) def _is_realtime_installed(self) -> bool: diff --git a/centos2almaconverter/actions/mariadb.py b/centos2almaconverter/actions/mariadb.py index 03ade10..cc3d969 100644 --- a/centos2almaconverter/actions/mariadb.py +++ b/centos2almaconverter/actions/mariadb.py @@ -29,7 +29,7 @@ def _do_check(self) -> bool: for repofile in repofiles: for repo in rpm.extract_repodata(repofile): repo_id, _, repo_baseurl, _, _, _ = repo - if ".mariadb.org" not in repo_baseurl: + if not repo_baseurl or ".mariadb.org" not in repo_baseurl: continue # Since repository will be deprecated for any distro at once it looks fine to check only for 7 on x86_64 @@ -148,7 +148,7 @@ def __init__(self): self.name = "install mysql connector" def _is_required(self) -> bool: - return mariadb.is_mysql_installed + return mariadb.is_mysql_installed() def _prepare_action(self) -> action.ActionResult: return action.ActionResult() diff --git a/centos2almaconverter/actions/packages.py b/centos2almaconverter/actions/packages.py index c3d5501..66356cf 100644 --- a/centos2almaconverter/actions/packages.py +++ b/centos2almaconverter/actions/packages.py @@ -119,7 +119,7 @@ def _is_required(self): return len(rpm.filter_installed_packages(self.conflict_pkgs_map.keys())) > 0 def _prepare_action(self) -> action.ActionResult: - packages_to_remove = rpm.filter_installed_packages(self.conflict_pkgs_map.keys()) + packages_to_remove = rpm.filter_installed_packages(list(self.conflict_pkgs_map.keys())) rpm.remove_packages(packages_to_remove) @@ -230,7 +230,7 @@ def __init__(self): def _is_required(self) -> bool: for file in files.find_files_case_insensitive("/etc/yum.repos.d", ["plesk*migrator*.repo"]): for _1, _2, url, _3, _4, _5 in rpm.extract_repodata(file): - if "PMM_0.1.10/thirdparty-rpm" in url: + if url and "PMM_0.1.10/thirdparty-rpm" in url: return True return False @@ -240,7 +240,7 @@ def _prepare_action(self) -> action.ActionResult: files.backup_file(file) rpm.remove_repositories(file, [ - lambda _1, _2, baseurl, _3: "PMM_0.1.10/thirdparty-rpm" in baseurl, + lambda _1, _2, baseurl, _3, _4: (baseurl is not None and "PMM_0.1.10/thirdparty-rpm" in baseurl), ]) return action.ActionResult()