From 9a8967cddb62ac3c6dd7567e0776bf352a5d2aaf Mon Sep 17 00:00:00 2001 From: Umit Kablan Date: Fri, 4 Oct 2024 16:05:16 +0300 Subject: [PATCH] comments addressed: logging, naming, locale.. --- pleskdistup/common/src/dpkg.py | 12 ++++++++---- pleskdistup/common/src/util.py | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pleskdistup/common/src/dpkg.py b/pleskdistup/common/src/dpkg.py index 4084570..cb74c61 100644 --- a/pleskdistup/common/src/dpkg.py +++ b/pleskdistup/common/src/dpkg.py @@ -128,8 +128,8 @@ def safely_install_packages( def apt_get_retry_temp_fails( apt_get_cmd: typing.List[str], - tmpfail_retry_intervals: typing.Optional[typing.List[int]], - collect_stdout: bool = False + tmpfail_retry_intervals: typing.Optional[typing.List[int]] = None, + collect_stdout: bool = False, ) -> str: cant_get_lock = False stdout = [] @@ -156,13 +156,17 @@ def process_stderr(line: str) -> None: log.info(f"Executing: {' '.join(apt_get_cmd)}") exit_code = util.exec_get_output_streamed( apt_get_cmd, process_stdout, process_stderr, - env={"PATH": os.environ["PATH"], "DEBIAN_FRONTEND": "noninteractive"}, + env={ + "PATH": os.environ["PATH"], + "DEBIAN_FRONTEND": "noninteractive", + "LC_ALL": "C", + }, ) if exit_code == 0: break if i >= len(tmpfail_retry_intervals) or not cant_get_lock: raise subprocess.CalledProcessError(returncode=exit_code, cmd=apt_get_cmd) - log.info(f"dist-upgrade failed because lock is already held, will retry in {tmpfail_retry_intervals[i]} seconds..") + log.info(f"{apt_get_cmd[0]} failed because lock is already held, will retry in {tmpfail_retry_intervals[i]} seconds..") time.sleep(tmpfail_retry_intervals[i]) i += 1 cant_get_lock = False diff --git a/pleskdistup/common/src/util.py b/pleskdistup/common/src/util.py index 6df9a1c..c0c7c0c 100644 --- a/pleskdistup/common/src/util.py +++ b/pleskdistup/common/src/util.py @@ -12,6 +12,7 @@ def logged_check_call(cmd: typing.Union[typing.Sequence[str], str], **kwargs) -> stdout = [] def proc_stdout(line: str) -> None: + log.info(line, to_stream=False) stdout.append(line) def proc_stderr(line: str) -> None: