Skip to content

Commit

Permalink
Merge pull request #62 from plesk/dont-remove-actionjson-on-fail
Browse files Browse the repository at this point in the history
Don't remove actionjson on fail
  • Loading branch information
SandakovMM authored Aug 2, 2024
2 parents c62a13f + 1cc1084 commit cdfd1ff
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pleskdistup/actions/common_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,5 +652,5 @@ def _do_check(self) -> bool:
if len(kernel_devel_packages) <= 1:
return True

self.description = self.description.format("\n\t- ".join([pkg.replace(" ", "-") for pkg in kernel_devel_packages]))
self.description = self.description.format("\n\t- ".join([pkg[0] + "-" + pkg[1] for pkg, _ in kernel_devel_packages]))
return False
4 changes: 3 additions & 1 deletion pleskdistup/common/src/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ def __enter__(self):
return self

def __exit__(self, *kwargs):
if os.path.exists(self.path_to_actions_data):
# Do not remove the actions data if an error occurs because
# customer will likely want to retry after correcting the error on their end
if self.error is not None and os.path.exists(self.path_to_actions_data):
os.remove(self.path_to_actions_data)

def _get_flow(self) -> typing.Dict[str, typing.List[ActiveAction]]:
Expand Down
12 changes: 8 additions & 4 deletions pleskdistup/common/src/dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ def do_distupgrade() -> None:
env={"PATH": os.environ["PATH"], "DEBIAN_FRONTEND": "noninteractive"})


def get_installed_packages_list(regex: str) -> typing.List[str]:
res = subprocess.check_output(["/usr/bin/dpkg-query", "-W", "-f", "${binary:Package} ${Version}\n", regex],
universal_newlines=True)
return res.splitlines()
def get_installed_packages_list(regex: str) -> typing.List[typing.Tuple[str, str]]:
pkgs_info = subprocess.check_output(["/usr/bin/dpkg-query", "-W", "-f", "${binary:Package} ${Version}\n", regex],
universal_newlines=True)
result = []
for pkg in pkgs_info.splitlines():
name, version = pkg.split(" ", 1)
result.append((name, version))
return result
2 changes: 1 addition & 1 deletion pleskdistup/common/src/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def autoremove_outdated_packages() -> None:
raise NotImplementedError(f"Unsupported distro {started_on}")


def get_installed_packages_list(regex: str) -> typing.List[str]:
def get_installed_packages_list(regex: str) -> typing.List[typing.Tuple[str, str]]:
started_on = dist.get_distro()
if started_on.deb_based:
return dpkg.get_installed_packages_list(regex)
Expand Down
10 changes: 7 additions & 3 deletions pleskdistup/common/src/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def install_packages(pkgs: typing.List[str], repository: typing.Optional[str] =
util.logged_check_call(command)


def get_installed_packages_list(regex: str) -> typing.List[str]:
res = subprocess.check_output(["/usr/bin/rpm", "-qa", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", regex], universal_newlines=True)
return res.splitlines()
def get_installed_packages_list(regex: str) -> typing.List[typing.Tuple[str, str]]:
pkgs_info = subprocess.check_output(["/usr/bin/rpm", "-qa", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", regex], universal_newlines=True)
result = []
for line in pkgs_info.splitlines():
name, version = line.split(" ", 1)
result.append((name, version))
return result


def remove_packages(pkgs: typing.List[str]) -> None:
Expand Down

0 comments on commit cdfd1ff

Please sign in to comment.