mirror of
https://github.com/frappe/bench.git
synced 2024-11-11 15:51:03 +00:00
migrate frappe calls to v5
This commit is contained in:
parent
971c4305a5
commit
33a63f2343
12
bench/app.py
12
bench/app.py
@ -1,5 +1,5 @@
|
||||
import os
|
||||
from .utils import exec_cmd, get_frappe, check_git_for_shallow_clone, get_config, build_assets, restart_supervisor_processes, get_cmd_output
|
||||
from .utils import exec_cmd, get_frappe, check_git_for_shallow_clone, get_config, build_assets, restart_supervisor_processes, get_cmd_output, run_frappe_cmd
|
||||
|
||||
import logging
|
||||
import requests
|
||||
@ -60,8 +60,12 @@ def get_app(app, git_url, branch=None, bench='.', build_asset_files=True):
|
||||
|
||||
def new_app(app, bench='.'):
|
||||
logger.info('creating new app {}'.format(app))
|
||||
exec_cmd("{frappe} --make_app {apps} {app}".format(frappe=get_frappe(bench=bench),
|
||||
apps=os.path.join(bench, 'apps'), app=app))
|
||||
apps = os.path.join(bench, 'apps')
|
||||
if FRAPPE_VERSION == '4':
|
||||
exec_cmd("{frappe} --make_app {apps} {app}".format(frappe=get_frappe(bench=bench),
|
||||
apps=apps, app=app))
|
||||
else:
|
||||
run_frappe_cmd('make-app', apps, app)
|
||||
install_app(app, bench=bench)
|
||||
|
||||
def install_app(app, bench='.'):
|
||||
@ -152,3 +156,5 @@ def get_apps_json(path):
|
||||
else:
|
||||
with open(path) as f:
|
||||
return json.load(f)
|
||||
|
||||
FRAPPE_VERSION = get_current_frappe_version()
|
||||
|
@ -16,7 +16,7 @@ from .utils import (build_assets, patch_sites, exec_cmd, update_bench, get_env_c
|
||||
fix_file_perms, fix_prod_setup_perms, set_ssl_certificate, set_ssl_certificate_key, get_cmd_output)
|
||||
from .app import get_app as _get_app
|
||||
from .app import new_app as _new_app
|
||||
from .app import pull_all_apps, get_apps, MajorVersionUpgradeException
|
||||
from .app import pull_all_apps, get_apps, MajorVersionUpgradeException, get_current_frappe_version
|
||||
from .config import generate_nginx_config, generate_supervisor_config, generate_redis_config
|
||||
from .production_setup import setup_production as _setup_production
|
||||
from .migrate_to_v5 import migrate_to_v5
|
||||
@ -31,6 +31,8 @@ import subprocess
|
||||
|
||||
logger = logging.getLogger('bench')
|
||||
|
||||
global FRAPPE_VERSION
|
||||
|
||||
def cli():
|
||||
check_uid()
|
||||
change_dir()
|
||||
@ -132,6 +134,8 @@ def shell(bench='.'):
|
||||
def bench(bench='.'):
|
||||
"Bench manager for Frappe"
|
||||
# TODO add bench path context
|
||||
global FRAPPE_VERSION
|
||||
FRAPPE_VERSION = get_current_frappe_version()
|
||||
setup_logging(bench=bench)
|
||||
|
||||
@click.command()
|
||||
@ -210,7 +214,7 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
||||
pull_all_apps(upgrade=upgrade)
|
||||
except MajorVersionUpgradeException, e:
|
||||
print "This update will cause a major version change in Frappe/ERPNext from v{0} to v{1}.".format(e.local_version, e.upstream_version)
|
||||
print "This would take significant time to migrate and might break custom apps. Please use --upgrade to confirm."
|
||||
print "This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm."
|
||||
sys.exit(1)
|
||||
if requirements:
|
||||
update_requirements()
|
||||
|
@ -10,6 +10,7 @@ import pwd, grp
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
default_config = {
|
||||
'restart_supervisor_on_update': False,
|
||||
'auto_update': False,
|
||||
@ -106,10 +107,16 @@ 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='.'):
|
||||
exec_cmd("{frappe} --latest all".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites'))
|
||||
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')
|
||||
|
||||
def build_assets(bench='.'):
|
||||
exec_cmd("{frappe} --build".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites'))
|
||||
if FRAPPE_VERSION == '4':
|
||||
exec_cmd("{frappe} --build".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites'))
|
||||
else:
|
||||
run_frappe_cmd('build')
|
||||
|
||||
def get_sites(bench='.'):
|
||||
sites_dir = os.path.join(bench, "sites")
|
||||
@ -133,8 +140,13 @@ def setup_auto_update(bench='.'):
|
||||
|
||||
def setup_backups(bench='.'):
|
||||
logger.info('setting up backups')
|
||||
add_to_crontab('0 */6 * * * cd {sites_dir} && {frappe} --backup all >> {logfile} 2>&1'.format(sites_dir=get_sites_dir(bench=bench),
|
||||
frappe=get_frappe(bench=bench),
|
||||
bench_dir = get_bench_dir(bench=bench)
|
||||
if FRAPPE_VERSION == '4':
|
||||
backup_command = "cd {sites_dir} && {frappe} --backup all".format(frappe=get_frappe(bench=bench),)
|
||||
else:
|
||||
backup_command = "cd {bench_dir} && {bench} --site all backup".format(bench_dir=bench_dir, bench=sys.argv[0])
|
||||
|
||||
add_to_crontab('0 */6 * * * {backup_command} --backup all >> {logfile} 2>&1'.format(backup_command=backup_command,
|
||||
logfile=os.path.join(get_bench_dir(bench=bench), 'logs', 'backup.log')))
|
||||
|
||||
def add_to_crontab(line):
|
||||
@ -394,3 +406,15 @@ def get_redis_version():
|
||||
return "2.6"
|
||||
if re.search("Redis server v=2.8", version_string):
|
||||
return "2.8"
|
||||
|
||||
def get_current_frappe_version():
|
||||
from .app import get_current_frappe_version as fv
|
||||
return fv()
|
||||
|
||||
def run_frappe_cmd(*args):
|
||||
bench = '.'
|
||||
f = get_env_cmd('python', bench=bench)
|
||||
os.chdir(os.path.join(bench, 'sites'))
|
||||
subprocess.check_call((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args)
|
||||
|
||||
FRAPPE_VERSION = get_current_frappe_version()
|
||||
|
Loading…
Reference in New Issue
Block a user