mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 09:02:10 +00:00
chore: remove support for older versions of frappe
This commit is contained in:
parent
777b204490
commit
ec2ce0f3b8
@ -152,13 +152,7 @@ def new_app(app, bench_path='.'):
|
|||||||
app = app.lower().replace(" ", "_").replace("-", "_")
|
app = app.lower().replace(" ", "_").replace("-", "_")
|
||||||
logger.log('creating new app {}'.format(app))
|
logger.log('creating new app {}'.format(app))
|
||||||
apps = os.path.abspath(os.path.join(bench_path, 'apps'))
|
apps = os.path.abspath(os.path.join(bench_path, 'apps'))
|
||||||
bench.set_frappe_version(bench_path=bench_path)
|
run_frappe_cmd('make-app', apps, app, bench_path=bench_path)
|
||||||
|
|
||||||
if bench.FRAPPE_VERSION == 4:
|
|
||||||
exec_cmd("{frappe} --make_app {apps} {app}".format(frappe=get_frappe(bench_path=bench_path),
|
|
||||||
apps=apps, app=app))
|
|
||||||
else:
|
|
||||||
run_frappe_cmd('make-app', apps, app, bench_path=bench_path)
|
|
||||||
install_app(app, bench_path=bench_path)
|
install_app(app, bench_path=bench_path)
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import os
|
|||||||
|
|
||||||
# imports - module imports
|
# imports - module imports
|
||||||
import bench
|
import bench
|
||||||
from bench.app import get_current_frappe_version, use_rq
|
from bench.app import use_rq
|
||||||
from bench.utils import get_bench_name, find_executable
|
from bench.utils import get_bench_name, find_executable
|
||||||
from bench.config.common_site_config import get_config, update_config, get_gunicorn_workers
|
from bench.config.common_site_config import get_config, update_config, get_gunicorn_workers
|
||||||
|
|
||||||
@ -29,7 +29,6 @@ def generate_supervisor_config(bench_path, user=None, yes=False, skip_redis=Fals
|
|||||||
"bench_dir": bench_dir,
|
"bench_dir": bench_dir,
|
||||||
"sites_dir": os.path.join(bench_dir, 'sites'),
|
"sites_dir": os.path.join(bench_dir, 'sites'),
|
||||||
"user": user,
|
"user": user,
|
||||||
"frappe_version": get_current_frappe_version(bench_path),
|
|
||||||
"use_rq": use_rq(bench_path),
|
"use_rq": use_rq(bench_path),
|
||||||
"http_timeout": config.get("http_timeout", 120),
|
"http_timeout": config.get("http_timeout", 120),
|
||||||
"redis_server": find_executable('redis-server'),
|
"redis_server": find_executable('redis-server'),
|
||||||
|
@ -7,7 +7,7 @@ import click
|
|||||||
|
|
||||||
# imports - module imports
|
# imports - module imports
|
||||||
import bench
|
import bench
|
||||||
from bench.app import get_current_frappe_version, use_rq
|
from bench.app import use_rq
|
||||||
from bench.config.common_site_config import get_config, get_gunicorn_workers, update_config
|
from bench.config.common_site_config import get_config, get_gunicorn_workers, update_config
|
||||||
from bench.utils import exec_cmd, find_executable, get_bench_name
|
from bench.utils import exec_cmd, find_executable, get_bench_name
|
||||||
|
|
||||||
@ -51,7 +51,6 @@ def generate_systemd_config(bench_path, user=None, yes=False,
|
|||||||
"bench_dir": bench_dir,
|
"bench_dir": bench_dir,
|
||||||
"sites_dir": os.path.join(bench_dir, 'sites'),
|
"sites_dir": os.path.join(bench_dir, 'sites'),
|
||||||
"user": user,
|
"user": user,
|
||||||
"frappe_version": get_current_frappe_version(bench_path),
|
|
||||||
"use_rq": use_rq(bench_path),
|
"use_rq": use_rq(bench_path),
|
||||||
"http_timeout": config.get("http_timeout", 120),
|
"http_timeout": config.get("http_timeout", 120),
|
||||||
"redis_server": find_executable('redis-server'),
|
"redis_server": find_executable('redis-server'),
|
||||||
|
@ -136,7 +136,6 @@ user={{ user }}
|
|||||||
directory={{ sites_dir }}
|
directory={{ sites_dir }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if frappe_version > 5 %}
|
|
||||||
{% if not skip_redis %}
|
{% if not skip_redis %}
|
||||||
[program:{{ bench_name }}-redis-socketio]
|
[program:{{ bench_name }}-redis-socketio]
|
||||||
command={{ redis_server }} {{ redis_socketio_config }}
|
command={{ redis_server }} {{ redis_socketio_config }}
|
||||||
@ -161,8 +160,6 @@ user={{ user }}
|
|||||||
directory={{ bench_dir }}
|
directory={{ bench_dir }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
[group:{{ bench_name }}-web]
|
[group:{{ bench_name }}-web]
|
||||||
programs={{ bench_name }}-frappe-web {%- if node -%} ,{{ bench_name }}-node-socketio {%- endif%}
|
programs={{ bench_name }}-frappe-web {%- if node -%} ,{{ bench_name }}-node-socketio {%- endif%}
|
||||||
|
|
||||||
@ -180,5 +177,5 @@ programs={{ bench_name }}-frappe-workerbeat,{{ bench_name }}-frappe-worker,{{ be
|
|||||||
|
|
||||||
{% if not skip_redis %}
|
{% if not skip_redis %}
|
||||||
[group:{{ bench_name }}-redis]
|
[group:{{ bench_name }}-redis]
|
||||||
programs={{ bench_name }}-redis-cache,{{ bench_name }}-redis-queue {%- if frappe_version > 5 -%} ,{{ bench_name }}-redis-socketio {%- endif %}
|
programs={{ bench_name }}-redis-cache,{{ bench_name }}-redis-queue,{{ bench_name }}-redis-socketio
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -163,11 +163,8 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
|||||||
if apps_path:
|
if apps_path:
|
||||||
install_apps_from_path(apps_path, bench_path=path)
|
install_apps_from_path(apps_path, bench_path=path)
|
||||||
|
|
||||||
|
if not skip_assets:
|
||||||
bench.set_frappe_version(bench_path=path)
|
update_node_packages(bench_path=path)
|
||||||
if bench.FRAPPE_VERSION > 5:
|
|
||||||
if not skip_assets:
|
|
||||||
update_node_packages(bench_path=path)
|
|
||||||
|
|
||||||
set_all_patches_executed(bench_path=path)
|
set_all_patches_executed(bench_path=path)
|
||||||
if not skip_assets:
|
if not skip_assets:
|
||||||
@ -358,27 +355,17 @@ def setup_socketio(bench_path='.'):
|
|||||||
|
|
||||||
|
|
||||||
def patch_sites(bench_path='.'):
|
def patch_sites(bench_path='.'):
|
||||||
bench.set_frappe_version(bench_path=bench_path)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if bench.FRAPPE_VERSION == 4:
|
run_frappe_cmd('--site', 'all', 'migrate', bench_path=bench_path)
|
||||||
exec_cmd("{frappe} --latest all".format(frappe=get_frappe(bench_path=bench_path)), cwd=os.path.join(bench_path, 'sites'))
|
|
||||||
else:
|
|
||||||
run_frappe_cmd('--site', 'all', 'migrate', bench_path=bench_path)
|
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
raise PatchError
|
raise PatchError
|
||||||
|
|
||||||
|
|
||||||
def build_assets(bench_path='.', app=None):
|
def build_assets(bench_path='.', app=None):
|
||||||
bench.set_frappe_version(bench_path=bench_path)
|
command = 'bench build'
|
||||||
|
if app:
|
||||||
if bench.FRAPPE_VERSION == 4:
|
command += ' --app {}'.format(app)
|
||||||
exec_cmd("{frappe} --build".format(frappe=get_frappe(bench_path=bench_path)), cwd=os.path.join(bench_path, 'sites'))
|
exec_cmd(command, cwd=bench_path)
|
||||||
else:
|
|
||||||
command = 'bench build'
|
|
||||||
if app:
|
|
||||||
command += ' --app {}'.format(app)
|
|
||||||
exec_cmd(command, cwd=bench_path)
|
|
||||||
|
|
||||||
|
|
||||||
def get_sites(bench_path='.'):
|
def get_sites(bench_path='.'):
|
||||||
@ -395,14 +382,8 @@ def setup_backups(bench_path='.'):
|
|||||||
bench_dir = os.path.abspath(bench_path)
|
bench_dir = os.path.abspath(bench_path)
|
||||||
user = get_config(bench_path=bench_dir).get('frappe_user')
|
user = get_config(bench_path=bench_dir).get('frappe_user')
|
||||||
logfile = os.path.join(bench_dir, 'logs', 'backup.log')
|
logfile = os.path.join(bench_dir, 'logs', 'backup.log')
|
||||||
bench.set_frappe_version(bench_path=bench_path)
|
|
||||||
system_crontab = CronTab(user=user)
|
system_crontab = CronTab(user=user)
|
||||||
|
backup_command = "cd {bench_dir} && {bench} --verbose --site all backup".format(bench_dir=bench_dir, bench=sys.argv[0])
|
||||||
if bench.FRAPPE_VERSION == 4:
|
|
||||||
backup_command = "cd {sites_dir} && {frappe} --backup all".format(frappe=get_frappe(bench_path=bench_path),)
|
|
||||||
else:
|
|
||||||
backup_command = "cd {bench_dir} && {bench} --verbose --site all backup".format(bench_dir=bench_dir, bench=sys.argv[0])
|
|
||||||
|
|
||||||
job_command = "{backup_command} >> {logfile} 2>&1".format(backup_command=backup_command, logfile=logfile)
|
job_command = "{backup_command} >> {logfile} 2>&1".format(backup_command=backup_command, logfile=logfile)
|
||||||
|
|
||||||
if job_command not in str(system_crontab):
|
if job_command not in str(system_crontab):
|
||||||
@ -662,13 +643,7 @@ def update_npm_packages(bench_path='.'):
|
|||||||
|
|
||||||
|
|
||||||
def backup_site(site, bench_path='.'):
|
def backup_site(site, bench_path='.'):
|
||||||
bench.set_frappe_version(bench_path=bench_path)
|
run_frappe_cmd('--site', site, 'backup', bench_path=bench_path)
|
||||||
|
|
||||||
if bench.FRAPPE_VERSION == 4:
|
|
||||||
exec_cmd("{frappe} --backup {site}".format(frappe=get_frappe(bench_path=bench_path), site=site),
|
|
||||||
cwd=os.path.join(bench_path, 'sites'))
|
|
||||||
else:
|
|
||||||
run_frappe_cmd('--site', site, 'backup', bench_path=bench_path)
|
|
||||||
|
|
||||||
|
|
||||||
def backup_all_sites(bench_path='.'):
|
def backup_all_sites(bench_path='.'):
|
||||||
@ -754,11 +729,6 @@ def fix_prod_setup_perms(bench_path='.', frappe_user=None):
|
|||||||
os.chown(path, uid, gid)
|
os.chown(path, uid, gid)
|
||||||
|
|
||||||
|
|
||||||
def get_current_frappe_version(bench_path='.'):
|
|
||||||
from .app import get_current_frappe_version as fv
|
|
||||||
return fv(bench_path=bench_path)
|
|
||||||
|
|
||||||
|
|
||||||
def run_frappe_cmd(*args, **kwargs):
|
def run_frappe_cmd(*args, **kwargs):
|
||||||
from .cli import from_command_line
|
from .cli import from_command_line
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user