From 794287d971a4c25a5bc9972bb4da29ab8b3f0fa9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 5 Jul 2017 09:19:01 +0530 Subject: [PATCH] [fixes] --- bench/app.py | 4 ++-- bench/commands/__init__.py | 3 +-- bench/commands/make.py | 10 ---------- bench/commands/setup.py | 5 +++-- bench/config/production_setup.py | 6 +++--- bench/utils.py | 16 +--------------- 6 files changed, 10 insertions(+), 34 deletions(-) diff --git a/bench/app.py b/bench/app.py index 281a0f8f..84827ea8 100755 --- a/bench/app.py +++ b/bench/app.py @@ -55,7 +55,7 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos #Gets repo name from URL repo_name = git_url.rsplit('/', 1)[1].rsplit('.', 1)[0] logger.info('getting app {}'.format(repo_name)) - shallow_clone = '--depth 1' if check_git_for_shallow_clone() else '' + shallow_clone = '--depth 1 --no-single-branch' if check_git_for_shallow_clone() else '' branch = '--branch {branch}'.format(branch=branch) if branch else '' exec_cmd("git clone {git_url} {branch} {shallow_clone} --origin upstream".format( @@ -135,7 +135,7 @@ def remove_app(app, bench_path='.'): def pull_all_apps(bench_path='.', reset=False): '''Check all apps if there no local changes, pull''' rebase = '--rebase' if get_config(bench_path).get('rebase_on_pull') else '' - + # chech for local changes if not reset: for app in get_apps(bench_path=bench_path): diff --git a/bench/commands/__init__.py b/bench/commands/__init__.py index 1bf61806..e31debab 100755 --- a/bench/commands/__init__.py +++ b/bench/commands/__init__.py @@ -21,12 +21,11 @@ def bench_command(bench_path='.'): setup_logging(bench_path=bench_path) -from bench.commands.make import init, get_app, new_app, remove_app, new_site +from bench.commands.make import init, get_app, new_app, remove_app bench_command.add_command(init) bench_command.add_command(get_app) bench_command.add_command(new_app) bench_command.add_command(remove_app) -bench_command.add_command(new_site) from bench.commands.update import update, retry_upgrade, switch_to_branch, switch_to_master, switch_to_develop diff --git a/bench/commands/make.py b/bench/commands/make.py index 8059f62f..e8a0d893 100755 --- a/bench/commands/make.py +++ b/bench/commands/make.py @@ -46,13 +46,3 @@ def remove_app(app_name): remove_app(app_name) -@click.command('new-site') -@click.option('--mariadb-root-password', help="MariaDB root password") -@click.option('--admin-password', help="admin password to set for site") -@click.argument('site') -def new_site(site, mariadb_root_password=None, admin_password=None): - "Create a new site in the bench" - from bench.utils import new_site - new_site(site, mariadb_root_password=mariadb_root_password, admin_password=admin_password) - - diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 76921023..5c635933 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -49,11 +49,12 @@ def setup_fonts(): @click.command('production') +@click.option('--yes', is_flag=True, default=False, help='Dont prompt for confirmation') @click.argument('user') -def setup_production(user): +def setup_production(user, yes=False): "setup bench for production" from bench.config.production_setup import setup_production - setup_production(user=user) + setup_production(user=user, yes=yes) @click.command('auto-update') diff --git a/bench/config/production_setup.py b/bench/config/production_setup.py index 3106f41f..afde3ff8 100755 --- a/bench/config/production_setup.py +++ b/bench/config/production_setup.py @@ -3,9 +3,9 @@ from bench.config.supervisor import generate_supervisor_config from bench.config.nginx import make_nginx_conf import os, subprocess -def setup_production(user, bench_path='.'): - generate_supervisor_config(bench_path=bench_path, user=user) - make_nginx_conf(bench_path=bench_path) +def setup_production(user, bench_path='.', yes=False): + generate_supervisor_config(bench_path=bench_path, user=user, yes=yes) + make_nginx_conf(bench_path=bench_path, yes=yes) fix_prod_setup_perms(bench_path, frappe_user=user) remove_default_nginx_configs() diff --git a/bench/utils.py b/bench/utils.py index 8ef8b70a..bd82d835 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -139,20 +139,6 @@ def setup_env(bench_path='.'): def setup_socketio(bench_path='.'): exec_cmd("npm install socket.io redis express superagent cookie", cwd=bench_path) -def new_site(site, mariadb_root_password=None, admin_password=None, bench_path='.'): - logger.info('creating new site {}'.format(site)) - mariadb_root_password_fragment = '--root_password {}'.format(mariadb_root_password) if mariadb_root_password else '' - admin_password_fragment = '--admin_password {}'.format(admin_password) if admin_password else '' - exec_cmd("{frappe} {site} --install {db_name} {mariadb_root_password_fragment} {admin_password_fragment}".format( - frappe=get_frappe(bench_path=bench_path), - site=site, - db_name = hashlib.sha1(site).hexdigest()[:10], - mariadb_root_password_fragment=mariadb_root_password_fragment, - admin_password_fragment=admin_password_fragment - ), cwd=os.path.join(bench_path, 'sites')) - if len(get_sites(bench_path=bench_path)) == 1: - exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench_path=bench_path), site=site), cwd=os.path.join(bench_path, 'sites')) - def patch_sites(bench_path='.'): bench.set_frappe_version(bench_path=bench_path) @@ -601,7 +587,7 @@ def update_translations(app, lang): f.flush() print('downloaded for', app, lang) - + def download_chart_of_accounts(): charts_dir = os.path.join('apps', "erpnext", "erpnext", 'accounts', 'chart_of_accounts', "submitted") csv_file = os.path.join(translations_dir, lang + '.csv')