def remove_app(app, bench_path='.'): if app not in get_apps(bench_path): 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).decode('utf-8') 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), cwd=bench_path) remove_from_appstxt(app, bench_path) shutil.rmtree(app_path) run_frappe_cmd("build", bench_path=bench_path) if get_config(bench_path).get('restart_supervisor_on_update'): restart_supervisor_processes(bench_path=bench_path) if get_config(bench_path).get('restart_systemd_on_update'): restart_systemd_processes(bench_path=bench_path)
def new_app(app, bench_path='.'): # For backwards compatibility app = app.lower().replace(" ", "_").replace("-", "_") logger.log('creating new app {}'.format(app)) apps = os.path.abspath(os.path.join(bench_path, 'apps')) 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)