From b6b9481b7b11f5ef6b3c5f866483cfdbcace97a3 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 10 Aug 2022 11:42:34 +0530 Subject: [PATCH 1/2] fix(DX): make warnings go to stderr --- bench/utils/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bench/utils/__init__.py b/bench/utils/__init__.py index 010ae94b..ff8f8fcd 100644 --- a/bench/utils/__init__.py +++ b/bench/utils/__init__.py @@ -79,7 +79,7 @@ def is_valid_frappe_branch(frappe_path: str, frappe_branch: str): raise InvalidRemoteException(f"Invalid frappe path: {frappe_path}") from e -def log(message, level=0, no_log=False): +def log(message, level=0, no_log=False, stderr=False): import bench import bench.cli @@ -96,13 +96,13 @@ def log(message, level=0, no_log=False): bench.LOG_BUFFER.append({"prefix": prefix, "message": message, "color": color}) if no_log: - click.secho(message, fg=color) + click.secho(message, fg=color, err=stderr) else: loggers = {2: logger.error, 3: logger.warning} level_logger = loggers.get(level, logger.info) level_logger(message) - click.secho(f"{prefix}: {message}", fg=color) + click.secho(f"{prefix}: {message}", fg=color, err=stderr) def check_latest_version(): @@ -125,7 +125,7 @@ def check_latest_version(): local_version = Version(VERSION) if pypi_version > local_version: - log(f"A newer version of bench is available: {local_version} → {pypi_version}") + log(f"A newer version of bench is available: {local_version} → {pypi_version}", stderr=True) def pause_exec(seconds=10): From 3e749ba547f80f40eefce7775ab5c2c6bbb8e8a9 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 10 Aug 2022 13:53:06 +0530 Subject: [PATCH 2/2] fix: update check condition Right now updates are checked for src and --version command, it used to be opposite of this. ref: https://github.com/frappe/bench/commit/7c653db70322604471fad120b779212119e3d010 --- bench/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/cli.py b/bench/cli.py index 312c4c63..140ea662 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -123,7 +123,7 @@ def cli(): bench_command() if cmd_from_sys in bench_command.commands: - with execute_cmd(check_for_update=not is_cli_command, command=command, logger=logger): + with execute_cmd(check_for_update=is_cli_command, command=command, logger=logger): bench_command() if in_bench: