Skip to content

Commit

Permalink
Fix type related problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Sandakov committed Apr 10, 2024
1 parent 8bca63b commit 28950eb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
13 changes: 8 additions & 5 deletions centos2almaconverter/actions/common_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions centos2almaconverter/actions/mariadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions centos2almaconverter/actions/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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()

Expand Down

0 comments on commit 28950eb

Please sign in to comment.