From d79d1af2c5bef03107a3dc619cca165d0e4426e9 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 11 May 2015 20:51:17 +0530 Subject: [PATCH] One Trace --- bench/cli.py | 7 +++++-- bench/utils.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bench/cli.py b/bench/cli.py index 35ea9b55..4040183a 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -14,7 +14,7 @@ from .utils import (build_assets, patch_sites, exec_cmd, update_bench, get_env_c get_config, update_config, restart_supervisor_processes, put_config, default_config, update_requirements, backup_all_sites, backup_site, get_sites, prime_wheel_cache, is_root, set_mariadb_host, drop_privileges, fix_file_perms, fix_prod_setup_perms, set_ssl_certificate, set_ssl_certificate_key, get_cmd_output, post_upgrade, - pre_upgrade) + pre_upgrade, PatchError) from .app import get_app as _get_app from .app import new_app as _new_app from .app import pull_all_apps, get_apps, get_current_frappe_version, is_version_upgrade, switch_to_v4, switch_to_master, switch_to_develop @@ -52,7 +52,10 @@ def cli(): elif len(sys.argv) > 1 and sys.argv[1] in get_apps(): return app_cmd() else: - bench() + try: + bench() + except PatchError: + sys.exit(1) def cmd_requires_root(): if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers'): diff --git a/bench/utils.py b/bench/utils.py index 5cf6a651..cb257f20 100644 --- a/bench/utils.py +++ b/bench/utils.py @@ -8,6 +8,10 @@ import json from distutils.spawn import find_executable import pwd, grp + +class PatchError(Exception): + pass + logger = logging.getLogger(__name__) @@ -112,10 +116,13 @@ def new_site(site, mariadb_root_password=None, admin_password=None, bench='.'): exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench=bench), site=site), cwd=os.path.join(bench, 'sites')) def patch_sites(bench='.'): - if FRAPPE_VERSION == 4: - exec_cmd("{frappe} --latest all".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites')) - else: - run_frappe_cmd('--site', 'all', 'migrate', bench=bench) + try: + if FRAPPE_VERSION == 4: + exec_cmd("{frappe} --latest all".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites')) + else: + run_frappe_cmd('--site', 'all', 'migrate', bench=bench) + except subprocess.CalledProcessError: + raise PatchError def build_assets(bench='.'): if FRAPPE_VERSION == 4: