diff --git a/pmb/helpers/apk.py b/pmb/helpers/apk.py index 37d18764..5741e548 100644 --- a/pmb/helpers/apk.py +++ b/pmb/helpers/apk.py @@ -102,7 +102,7 @@ def apk_with_progress(args, command, chroot=False, suffix="native"): while p_apk.poll() is None: line = p_cat.stdout.readline().decode('utf-8') progress = _compute_progress(line) - pmb.helpers.cli.progress_print(progress) - pmb.helpers.cli.progress_flush() + pmb.helpers.cli.progress_print(args, progress) + pmb.helpers.cli.progress_flush(args) pmb.helpers.run_core.check_return_code(args, p_apk.returncode, log_msg) diff --git a/pmb/helpers/cli.py b/pmb/helpers/cli.py index 6edd74eb..db7749da 100644 --- a/pmb/helpers/cli.py +++ b/pmb/helpers/cli.py @@ -105,7 +105,7 @@ def confirm(args, question="Continue?", default=False, no_assumptions=False): return answer == "y" -def progress_print(progress): +def progress_print(args, progress): """ Print a snapshot of a progress bar to STDOUT. Call progress_flush to end printing progress and clear the line. No output is printed in @@ -122,16 +122,16 @@ def progress_print(progress): filled = "\u2588" * chars empty = " " * (width - chars) percent = int(progress * 100) - if pmb.config.is_interactive: + if pmb.config.is_interactive and not args.details_to_stdout: sys.stdout.write(f"\u001b7{percent:>3}% {filled}{empty}") sys.stdout.flush() sys.stdout.write("\u001b8\u001b[0K") -def progress_flush(): +def progress_flush(args): """ Finish printing a progress bar. This will erase the line. Does nothing in non-interactive mode. """ - if pmb.config.is_interactive: + if pmb.config.is_interactive and not args.details_to_stdout: sys.stdout.flush() diff --git a/pmb/helpers/repo.py b/pmb/helpers/repo.py index de9a9c33..280b13a4 100644 --- a/pmb/helpers/repo.py +++ b/pmb/helpers/repo.py @@ -180,7 +180,7 @@ def update(args, arch=None, force=False, existing_only=False): # Download and move to right location for (i, (url, target)) in enumerate(outdated.items()): - pmb.helpers.cli.progress_print(i / len(outdated)) + pmb.helpers.cli.progress_print(args, i / len(outdated)) temp = pmb.helpers.http.download(args, url, "APKINDEX", False, logging.DEBUG, True) if not temp: @@ -190,7 +190,7 @@ def update(args, arch=None, force=False, existing_only=False): if not os.path.exists(target_folder): pmb.helpers.run.root(args, ["mkdir", "-p", target_folder]) pmb.helpers.run.root(args, ["cp", temp, target]) - pmb.helpers.cli.progress_flush() + pmb.helpers.cli.progress_flush(args) return True