diff --git a/frappe/__init__.py b/frappe/__init__.py index 5453ab248c..fa62f3b405 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -410,8 +410,8 @@ def get_module_list(app_name): def get_all_apps(with_frappe=False, with_internal_apps=True, sites_path=None): if not sites_path: sites_path = local.sites_path - - apps = get_file_items(os.path.join(sites_path, "apps.txt")) + + apps = get_file_items(os.path.join(sites_path, "apps.txt"), raise_not_found=True) if with_internal_apps: apps.extend(get_file_items(os.path.join(local.site_path, "apps.txt"))) if with_frappe: @@ -465,8 +465,8 @@ def setup_module_map(): _cache.set_value("app_modules", local.app_modules) _cache.set_value("module_app", local.module_app) -def get_file_items(path): - content = read_file(path) +def get_file_items(path, raise_not_found=False): + content = read_file(path, raise_not_found=raise_not_found) if content: return [p.strip() for p in content.splitlines() if p.strip() and not p.startswith("#")] else: @@ -476,10 +476,12 @@ def get_file_json(path): with open(path, 'r') as f: return json.load(f) -def read_file(path): +def read_file(path, raise_not_found=False): if os.path.exists(path): with open(path, "r") as f: return unicode(f.read(), encoding="utf-8") + elif raise_not_found: + raise IOError("{} Not Found".format(path)) else: return None diff --git a/frappe/cli.py b/frappe/cli.py index 0995bcbf46..0f8b39e187 100755 --- a/frappe/cli.py +++ b/frappe/cli.py @@ -255,7 +255,7 @@ def install(db_name, root_login="root", root_password=None, source_sql=None, install_db(root_login=root_login, root_password=root_password, db_name=db_name, source_sql=source_sql, admin_password = admin_password, verbose=verbose, force=force, site_config=site_config, reinstall=reinstall) make_site_dirs() - install_app("frappe", verbose=verbose) + install_app("frappe", verbose=verbose, set_as_patched=not source_sql) frappe.destroy() @cmd diff --git a/frappe/installer.py b/frappe/installer.py index 2224443253..ed5c921799 100755 --- a/frappe/installer.py +++ b/frappe/installer.py @@ -83,7 +83,7 @@ def make_connection(root_login, root_password): return frappe.database.Database(user=root_login, password=root_password) @frappe.whitelist() -def install_app(name, verbose=False): +def install_app(name, verbose=False, set_as_patched=True): frappe.flags.in_install_app = name frappe.clear_cache() @@ -104,11 +104,12 @@ def install_app(name, verbose=False): sync_for(name, force=True, sync_everything=True, verbose=verbose) add_to_installed_apps(name) - set_all_patches_as_completed(name) + + if set_as_patched: + set_all_patches_as_completed(name) for after_install in app_hooks.after_install or []: frappe.get_attr(after_install)() - frappe.flags.in_install_app = False diff --git a/frappe/patches.txt b/frappe/patches.txt index 881d8aeca9..57e2485f60 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -19,4 +19,5 @@ frappe.patches.4_0.rename_sitemap_to_route frappe.patches.4_0.set_website_route_idx execute:import frappe.installer;frappe.installer.make_site_dirs() #2014-02-19 frappe.patches.4_0.private_backups -frappe.patches.4_0.set_module_in_report \ No newline at end of file +frappe.patches.4_0.set_module_in_report +frappe.patches.4_0.remove_old_parent \ No newline at end of file diff --git a/frappe/patches/4_0/remove_old_parent.py b/frappe/patches/4_0/remove_old_parent.py new file mode 100644 index 0000000000..7c738f43f4 --- /dev/null +++ b/frappe/patches/4_0/remove_old_parent.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + for doctype in frappe.db.sql_list("""select name from `tabDocType` where istable=1"""): + frappe.db.sql("""delete from `tab{0}` where parent like "old_par%:%" """.format(doctype))