2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-23 04:29:02 +00:00

pre install apps on init, fix #19

This commit is contained in:
Pratik Vyas 2014-07-21 11:40:03 +05:30
parent e6a6973eff
commit 1d60a52c01
3 changed files with 22 additions and 4 deletions

View File

@ -2,6 +2,8 @@ import os
from .utils import exec_cmd, get_frappe, check_git_for_shallow_clone, get_config
import logging
import requests
import json
logger = logging.getLogger(__name__)
@ -43,3 +45,16 @@ def pull_all_apps(bench='.'):
if os.path.exists(os.path.join(app_dir, '.git')):
logger.info('pulling {}'.format(app))
exec_cmd("git pull --rebase upstream HEAD", cwd=app_dir)
def install_apps_from_path(path, bench='.'):
apps = get_apps_dict(path)
for app, url in apps.items():
get_app(app, url, bench=bench)
def get_apps_dict(path):
if path.startswith('http'):
r = requests.get(path)
return r.json()
else:
with open(path) as f:
return json.load(f)

View File

@ -38,9 +38,10 @@ def bench(bench='.'):
@click.command()
@click.argument('path')
def init(path):
@click.option('--apps_path', default=None, help="path to json files with apps to install after init")
def init(path, apps_path):
"Create a new bench"
_init(path)
_init(path, apps_path=apps_path)
click.echo('Bench {} initialized'.format(path))
@click.command('get-app')

View File

@ -22,8 +22,8 @@ def get_frappe(bench='.'):
print 'bench get-app frappe https://github.com/frappe/frappe.git'
return frappe
def init(path):
from .app import get_app
def init(path, apps_path=None):
from .app import get_app, install_apps_from_path
if os.path.exists(path):
print 'Directory {} already exists!'.format(path)
sys.exit(1)
@ -41,6 +41,8 @@ def init(path):
setup_backups(bench=path)
setup_auto_update(bench=path)
exec_cmd("{frappe} --build".format(frappe=get_frappe(bench=path)), cwd=os.path.join(path, 'sites'))
if apps_path:
install_apps_from_path(apps_path, bench=path)
def exec_cmd(cmd, cwd='.'):
try: