mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
Revert "fix: force use PYPI packaged bench"
This reverts commit 74bb1805b2d024ac32c4952c90c408c5b58b4969.
This commit is contained in:
parent
5e7ad22be9
commit
cdd7d34034
@ -1,7 +1,13 @@
|
||||
from bench.utils import install_checker
|
||||
from jinja2 import Environment, PackageLoader
|
||||
|
||||
__version__ = "4.1.0"
|
||||
|
||||
env = Environment(loader=PackageLoader('bench.config'))
|
||||
install_checker()
|
||||
|
||||
FRAPPE_VERSION = None
|
||||
|
||||
def set_frappe_version(bench_path='.'):
|
||||
from .app import get_current_frappe_version
|
||||
global FRAPPE_VERSION
|
||||
if not FRAPPE_VERSION:
|
||||
FRAPPE_VERSION = get_current_frappe_version(bench_path=bench_path)
|
@ -151,7 +151,13 @@ def new_app(app, bench_path='.'):
|
||||
app = app.lower().replace(" ", "_").replace("-", "_")
|
||||
logger.info('creating new app {}'.format(app))
|
||||
apps = os.path.abspath(os.path.join(bench_path, 'apps'))
|
||||
run_frappe_cmd('make-app', apps, app, bench_path=bench_path)
|
||||
bench.set_frappe_version(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)
|
||||
|
||||
def install_app(app, bench_path=".", verbose=False, no_cache=False):
|
||||
|
@ -17,6 +17,7 @@ def bench_command(bench_path='.'):
|
||||
import bench
|
||||
from bench.utils import setup_logging
|
||||
|
||||
bench.set_frappe_version(bench_path=bench_path)
|
||||
setup_logging(bench_path=bench_path)
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ from six import iteritems
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
import bench
|
||||
from bench import env
|
||||
|
||||
|
||||
class PatchError(Exception):
|
||||
@ -109,11 +110,15 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, no_auto_upda
|
||||
if apps_path:
|
||||
install_apps_from_path(apps_path, bench_path=path)
|
||||
|
||||
if not skip_assets:
|
||||
update_node_packages(bench_path=path)
|
||||
build_assets(bench_path=path)
|
||||
|
||||
bench.set_frappe_version(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)
|
||||
if not skip_assets:
|
||||
build_assets(bench_path=path)
|
||||
|
||||
if not skip_redis_config_generation:
|
||||
redis.generate_config(path)
|
||||
@ -212,16 +217,26 @@ def setup_socketio(bench_path='.'):
|
||||
babel-cli babel-preset-es2015 babel-preset-es2016 babel-preset-es2017 babel-preset-babili", cwd=bench_path)
|
||||
|
||||
def patch_sites(bench_path='.'):
|
||||
bench.set_frappe_version(bench_path=bench_path)
|
||||
|
||||
try:
|
||||
run_frappe_cmd('--site', 'all', 'migrate', bench_path=bench_path)
|
||||
if bench.FRAPPE_VERSION == 4:
|
||||
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:
|
||||
raise PatchError
|
||||
|
||||
def build_assets(bench_path='.', app=None):
|
||||
command = 'bench build'
|
||||
if app:
|
||||
command += ' --app {}'.format(app)
|
||||
exec_cmd(command, cwd=bench_path)
|
||||
bench.set_frappe_version(bench_path=bench_path)
|
||||
|
||||
if bench.FRAPPE_VERSION == 4:
|
||||
exec_cmd("{frappe} --build".format(frappe=get_frappe(bench_path=bench_path)), cwd=os.path.join(bench_path, 'sites'))
|
||||
else:
|
||||
command = 'bench build'
|
||||
if app:
|
||||
command += ' --app {}'.format(app)
|
||||
exec_cmd(command, cwd=bench_path)
|
||||
|
||||
def get_sites(bench_path='.'):
|
||||
sites_path = os.path.join(bench_path, 'sites')
|
||||
@ -240,7 +255,12 @@ def setup_auto_update(bench_path='.'):
|
||||
def setup_backups(bench_path='.'):
|
||||
logger.info('setting up backups')
|
||||
bench_dir = get_bench_dir(bench_path=bench_path)
|
||||
backup_command = "cd {bench_dir} && {bench} --site all backup".format(bench_dir=bench_dir, bench=sys.argv[0])
|
||||
bench.set_frappe_version(bench_path=bench_path)
|
||||
|
||||
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} --site all backup".format(bench_dir=bench_dir, bench=sys.argv[0])
|
||||
|
||||
add_to_crontab('0 */6 * * * {backup_command} >> {logfile} 2>&1'.format(backup_command=backup_command,
|
||||
logfile=os.path.join(get_bench_dir(bench_path=bench_path), 'logs', 'backup.log')))
|
||||
@ -282,8 +302,6 @@ def update_bench(bench_repo=True, requirements=True):
|
||||
logger.info("Bench Updated!")
|
||||
|
||||
def setup_sudoers(user):
|
||||
from bench import env
|
||||
|
||||
if not os.path.exists('/etc/sudoers.d'):
|
||||
os.makedirs('/etc/sudoers.d')
|
||||
|
||||
@ -539,7 +557,13 @@ def install_requirements(req_file, user=False):
|
||||
exec_cmd("{python} -m pip install {user_flag} -q -U -r {req_file}".format(python=python, user_flag=user_flag, req_file=req_file))
|
||||
|
||||
def backup_site(site, bench_path='.'):
|
||||
run_frappe_cmd('--site', site, 'backup', bench_path=bench_path)
|
||||
bench.set_frappe_version(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='.'):
|
||||
for site in get_sites(bench_path=bench_path):
|
||||
|
Loading…
Reference in New Issue
Block a user