From b13adc28f2c99b05652430ceb0bbdbcf239ebedf Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 9 Mar 2015 19:12:10 +0530 Subject: [PATCH] fix bench init with v4 --- bench/app.py | 1 - bench/cli.py | 4 +++- bench/utils.py | 17 ++++++++++++++--- install_scripts/setup_frappe.sh | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bench/app.py b/bench/app.py index 3c48e4ad..82d40dce 100644 --- a/bench/app.py +++ b/bench/app.py @@ -148,7 +148,6 @@ def install_apps_from_path(path, bench='.'): apps = get_apps_json(path) for app in apps: get_app(app['name'], app['url'], branch=app.get('branch'), bench=bench, build_asset_files=False) - build_assets(bench=bench) def get_apps_json(path): if path.startswith('http'): diff --git a/bench/cli.py b/bench/cli.py index 208efe1e..b1cf893f 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -76,7 +76,7 @@ def change_uid(): sys.exit(1) def change_dir(): - if os.path.exists('config.json'): + if os.path.exists('config.json') or "init" in sys.argv: return dir_path_file = '/etc/frappe_bench_dir' if os.path.exists(dir_path_file): @@ -218,6 +218,8 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar version_upgrade = is_version_upgrade() if version_upgrade and not upgrade: + print + print print "This update will cause a major version change in Frappe/ERPNext from {0} to {1}.".format(*version_upgrade) print "This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm." sys.exit(1) diff --git a/bench/utils.py b/bench/utils.py index 7bf63518..c69bb6cf 100644 --- a/bench/utils.py +++ b/bench/utils.py @@ -35,6 +35,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None): from .app import get_app, install_apps_from_path from .config import generate_redis_config + global FRAPPE_VERSION if os.path.exists(path): print 'Directory {} already exists!'.format(path) sys.exit(1) @@ -50,9 +51,10 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, if wheel_cache_dir: update_config({"wheel_cache_dir":wheel_cache_dir}, bench=path) prime_wheel_cache(bench=path) + if not frappe_path: frappe_path = 'https://github.com/frappe/frappe.git' - get_app('frappe', frappe_path, branch=frappe_branch, bench=path) + get_app('frappe', frappe_path, branch=frappe_branch, bench=path, build_asset_files=False) if not no_procfile: setup_procfile(bench=path) if not no_backups: @@ -61,6 +63,8 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, setup_auto_update(bench=path) if apps_path: install_apps_from_path(apps_path, bench=path) + FRAPPE_VERSION = get_current_frappe_version(bench=path) + build_assets(bench=bench) generate_redis_config(bench=path) def exec_cmd(cmd, cwd='.'): @@ -407,9 +411,9 @@ def get_redis_version(): if re.search("Redis server v=2.8", version_string): return "2.8" -def get_current_frappe_version(): +def get_current_frappe_version(bench='.'): from .app import get_current_frappe_version as fv - return fv() + return fv(bench=bench) def run_frappe_cmd(*args, **kwargs): bench = kwargs.get('bench', '.') @@ -421,13 +425,20 @@ def run_frappe_cmd(*args, **kwargs): def pre_upgrade(from_ver, to_ver, bench='.'): from .migrate_to_v5 import validate_v4, remove_shopping_cart if from_ver == 4 and to_ver == 5: + apps = ('frappe', 'erpnext') remove_shopping_cart(bench=bench) + + for app in apps: + cwd = os.path.join(bench, 'apps', repo) + if os.path.exists(cwd): + exec_cmd("git clean -df", cwd=cwd) def post_upgrade(from_ver, to_ver, bench='.'): from .app import get_current_frappe_version from .config import generate_nginx_config, generate_supervisor_config, generate_redis_config conf = get_config(bench=bench) if from_ver == 4 and to_ver == 5: + print "-"*80 print "Your bench was upgraded to version 5" if conf.get('restart_supervisor_on_update'): generate_redis_config(bench=bench) diff --git a/install_scripts/setup_frappe.sh b/install_scripts/setup_frappe.sh index 29382cd7..1fe059f5 100644 --- a/install_scripts/setup_frappe.sh +++ b/install_scripts/setup_frappe.sh @@ -16,7 +16,7 @@ get_passwd() { } set_opts () { - OPTS=`getopt -o v --long verbose,mysql-root-password:,frappe-user:,setup-production,bench-branch:,skip-setup-bench,help -n 'parse-options' -- "$@"` + OPTS=`getopt -o v --long verbose,mysql-root-password:,frappe-user:,bench-branch:,setup-production,skip-setup-bench,help -n 'parse-options' -- "$@"` if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi