diff --git a/frappe/__init__.py b/frappe/__init__.py index 5dd11fd72f..781f850a86 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -438,7 +438,14 @@ def get_hooks(hook=None, default=None, app_name=None): hooks = {} for app in [app_name] if app_name else get_installed_apps(): app = "frappe" if app=="webnotes" else app - app_hooks = get_module(app + ".hooks") + try: + app_hooks = get_module(app + ".hooks") + except ImportError: + if local.flags.in_install_app: + # if app is not installed while restoring + # ignore it + pass + raise for key in dir(app_hooks): if not key.startswith("_"): append_hook(hooks, key, getattr(app_hooks, key)) diff --git a/frappe/cli.py b/frappe/cli.py index d654b2eff7..9c3f1055d4 100755 --- a/frappe/cli.py +++ b/frappe/cli.py @@ -140,6 +140,8 @@ def setup_install(parser): help="Install a new app") parser.add_argument("--add_to_installed_apps", metavar="APP-NAME", nargs="*", help="Add these app(s) to Installed Apps") + parser.add_argument("--remove_from_installed_apps", metavar="APP-NAME", nargs="*", + help="Remove these app(s) from Installed Apps") parser.add_argument("--reinstall", default=False, action="store_true", help="Install a fresh app in db_name specified in conf.py") parser.add_argument("--restore", metavar=("DB-NAME", "SQL-FILE"), nargs=2, @@ -352,9 +354,17 @@ def add_to_installed_apps(*apps): from frappe.installer import add_to_installed_apps frappe.connect() all_apps = frappe.get_all_apps(with_frappe=True) - for each in apps: - if each in all_apps: - add_to_installed_apps(each, rebuild_website=False) + for app in apps: + if app in all_apps: + add_to_installed_apps(app, rebuild_website=False) + frappe.destroy() + +@cmd +def remove_from_installed_apps(*apps): + from frappe.installer import remove_from_installed_apps + frappe.connect() + for app in apps: + remove_from_installed_apps(app) frappe.destroy() @cmd diff --git a/frappe/installer.py b/frappe/installer.py index 96e04a7aff..4edb7b26a0 100755 --- a/frappe/installer.py +++ b/frappe/installer.py @@ -127,14 +127,23 @@ def add_to_installed_apps(app_name, rebuild_website=True): installed_apps.append(app_name) frappe.db.set_global("installed_apps", json.dumps(installed_apps)) frappe.db.commit() + post_install(rebuild_website) - if rebuild_website: - render.clear_cache() - statics.sync().start() - +def remove_from_installed_apps(app_name): + installed_apps = frappe.get_installed_apps() + if app_name in installed_apps: + installed_apps.remove(app_name) + frappe.db.set_global("installed_apps", json.dumps(installed_apps)) frappe.db.commit() + post_install() - frappe.clear_cache() +def post_install(rebuild_website=False): + if rebuild_website: + render.clear_cache() + statics.sync().start() + + frappe.db.commit() + frappe.clear_cache() def set_all_patches_as_completed(app): patch_path = os.path.join(frappe.get_pymodule_path(app), "patches.txt") diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index a01508f058..9186e2d626 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -133,7 +133,7 @@ def get_backup(): frappe.conf.db_password, db_host = frappe.db.host) odb.get_backup() recipient_list = odb.send_email() - frappe.msgprint(_("Download link for your backup will be emailed on the following email address:").format(', '.join(recipient_list))) + frappe.msgprint(_("Download link for your backup will be emailed on the following email address: {0}").format(', '.join(recipient_list))) def scheduled_backup(older_than=6, ignore_files=False, backup_path_db=None, backup_path_files=None): """this function is called from scheduler