2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-27 22:39:03 +00:00

Add readme, first cut

This commit is contained in:
Pratik Vyas 2014-07-15 11:08:58 +05:30
parent 8dac5a55b8
commit 418452f775
2 changed files with 17 additions and 2 deletions

View File

@ -5,7 +5,7 @@ from .utils import new_site as _new_site
from .utils import setup_backups as _setup_backups
from .utils import setup_auto_update as _setup_auto_update
from .utils import setup_sudoers as _setup_sudoers
from .utils import build_assets, patch_sites, exec_cmd, update_bench, get_frappe, setup_logging
from .utils import build_assets, patch_sites, exec_cmd, update_bench, get_frappe, setup_logging, get_config
from .app import get_app as _get_app
from .app import new_app as _new_app
from .app import pull_all_apps
@ -61,7 +61,7 @@ def new_site(site):
def update(pull=False, patch=False, build=False, bench=False):
if not (pull or patch or build or bench):
pull, patch, build, bench = True, True, True, True
if bench:
if bench and get_config().get('update_bench_on_update'):
update_bench()
if pull:
pull_all_apps()

View File

@ -3,9 +3,15 @@ import sys
import subprocess
import getpass
import logging
import json
logger = logging.getLogger(__name__)
default_config = {
'restart_supervisor_on_update': True,
'update_bench_on_update': True
}
def get_frappe(bench='.'):
frappe = os.path.abspath(os.path.join(bench, 'env', 'bin', 'frappe'))
if not os.path.exists(frappe):
@ -26,6 +32,7 @@ def init(path):
setup_logging()
setup_env(bench=path)
put_config(default_config, bench=path)
get_app('frappe', 'https://github.com/frappe/frappe.git', bench=path)
setup_backups(bench=path)
setup_auto_update(bench=path)
@ -94,3 +101,11 @@ def setup_logging(bench='.'):
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
def get_config(bench='.'):
with open(os.path.join(bench, 'config.json')) as f:
return json.load(f)
def put_config(config, bench='.'):
with open(os.path.join(bench, 'config.json'), 'w') as f:
return json.dump(config, f)