From bbf38c7faf0d4bcd52b7af0ae7f79256ce397745 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 20 Nov 2014 13:00:57 +0530 Subject: [PATCH] remove from appstxt --- bench/app.py | 13 +++++++++++-- bench/migrate_to_v5.py | 9 +++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bench/app.py b/bench/app.py index c6805ced..7d479965 100644 --- a/bench/app.py +++ b/bench/app.py @@ -18,8 +18,17 @@ def add_to_appstxt(app, bench='.'): apps = get_apps(bench=bench) if app not in apps: apps.append(app) - with open(os.path.join(bench, 'sites', 'apps.txt'), 'w') as f: - return f.write('\n'.join(apps)) + return write_appstxt(apps, bench=bench) + +def remove_from_appstxt(app, bench='.'): + apps = get_apps(bench=bench) + if app in apps: + apps.remove(app) + return write_appstxt(apps, bench=bench) + +def write_appstxt(apps, bench='.'): + with open(os.path.join(bench, 'sites', 'apps.txt'), 'w') as f: + return f.write('\n'.join(apps)) def get_app(app, git_url, branch=None, bench='.'): logger.info('getting app {}'.format(app)) diff --git a/bench/migrate_to_v5.py b/bench/migrate_to_v5.py index ad191066..19fee216 100644 --- a/bench/migrate_to_v5.py +++ b/bench/migrate_to_v5.py @@ -1,7 +1,8 @@ from .utils import exec_cmd, get_frappe +from .release import get_current_version +from .app import remove_from_appstxt import os import shutil -from .release import get_current_version repos = ('frappe', 'erpnext') @@ -20,7 +21,11 @@ def migrate_to_v5(bench='.'): def remove_shopping_cart(bench='.'): exec_cmd("{pip} --no-input uninstall -y shopping_cart".format(pip=os.path.join(bench, 'env', 'bin', 'pip'))) - exec_cmd("{frappe} all --remove_from_installed_apps shopping_cart".format(frappe=get_frappe(bench=bench))) + exec_cmd("{frappe} all --remove_from_installed_apps shopping_cart".format( + frappe=get_frappe(bench=bench)), + cwd=os.path.join(bench, 'sites')) + remove_from_appstxt('shopping_cart', bench=bench) + archived_apps_dir = os.path.join(bench, 'archived_apps') shopping_cart_dir = os.path.join(bench, 'apps', 'shopping_cart') if not os.path.exists(archived_apps_dir):