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

Added command to remove app

This commit is contained in:
Valmik Jangla 2016-07-17 22:57:05 -07:00
parent 47a65b9411
commit c3efdb01ab
4 changed files with 39 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import json
import re
import subprocess
import bench
import sys
import shutil
logging.basicConfig(level="DEBUG")
logger = logging.getLogger(__name__)
@ -101,6 +103,32 @@ def install_app(app, bench_path='.', verbose=False):
find_links=find_links))
add_to_appstxt(app, bench_path=bench_path)
def remove_app(app, bench_path='.'):
if not app in get_apps():
print "No app named {0}".format(app)
sys.exit(1)
app_path = os.path.join(bench_path, 'apps', app)
site_path = os.path.join(bench_path, 'sites')
pip = os.path.join(bench_path, 'env', 'bin', 'pip')
for site in os.listdir(site_path):
req_file = os.path.join(site_path, site, 'site_config.json')
if os.path.exists(req_file):
out = subprocess.check_output(["bench", "--site", site, "list-apps"], cwd=bench_path)
if re.search(r'\b' + app + r'\b', out):
print "Cannot remove, app is installed on site: {0}".format(site)
sys.exit(1)
exec_cmd(["{0} uninstall -y {1}".format(pip, app_path)], cwd=bench_path)
remove_from_appstxt(app, bench_path)
shutil.rmtree(app_path)
run_frappe_cmd("build", cwd=bench_path)
if get_config(bench_path).get('restart_supervisor_on_update'):
restart_supervisor_processes(bench_path=bench_path)
def pull_all_apps(bench_path='.'):
rebase = '--rebase' if get_config(bench_path).get('rebase_on_pull') else ''

3
bench/commands/__init__.py Normal file → Executable file
View File

@ -21,10 +21,11 @@ def bench_command(bench_path='.'):
setup_logging(bench_path=bench_path)
from bench.commands.make import init, get_app, new_app, new_site
from bench.commands.make import init, get_app, new_app, remove_app, new_site
bench_command.add_command(init)
bench_command.add_command(get_app)
bench_command.add_command(new_app)
bench_command.add_command(remove_app)
bench_command.add_command(new_site)

8
bench/commands/make.py Normal file → Executable file
View File

@ -36,6 +36,14 @@ def new_app(app_name):
new_app(app_name)
@click.command('remove-app')
@click.argument('app-name')
def remove_app(app_name):
"completely remove new app from bench"
from bench.app import remove_app
remove_app(app_name)
@click.command('new-site')
@click.option('--mariadb-root-password', help="MariaDB root password")
@click.option('--admin-password', help="admin password to set for site")

1
bench/utils.py Normal file → Executable file
View File

@ -77,6 +77,7 @@ def exec_cmd(cmd, cwd='.'):
stderr = stdout = subprocess.PIPE
else:
stderr = stdout = None
print cmd
p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr)
if async: