Skip to content

Commit

Permalink
comments addressed: logging, naming, locale..
Browse files Browse the repository at this point in the history
  • Loading branch information
Umit Kablan committed Oct 4, 2024
1 parent fc557e1 commit 9a8967c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pleskdistup/common/src/dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pleskdistup/common/src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9a8967c

Please sign in to comment.