[cli] added --remove_from_installed_apps
This commit is contained in:
parent
46bc8a8583
commit
4e9f796298
4 changed files with 36 additions and 10 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue