Browse Source

Check if apps.txt exists, set as patched optional in install app

version-14
Anand Doshi 11 years ago
parent
commit
89ea436be4
5 changed files with 23 additions and 10 deletions
  1. +7
    -5
      frappe/__init__.py
  2. +1
    -1
      frappe/cli.py
  3. +4
    -3
      frappe/installer.py
  4. +2
    -1
      frappe/patches.txt
  5. +9
    -0
      frappe/patches/4_0/remove_old_parent.py

+ 7
- 5
frappe/__init__.py View File

@@ -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



+ 1
- 1
frappe/cli.py View File

@@ -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


+ 4
- 3
frappe/installer.py View File

@@ -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


+ 2
- 1
frappe/patches.txt View File

@@ -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
frappe.patches.4_0.set_module_in_report
frappe.patches.4_0.remove_old_parent

+ 9
- 0
frappe/patches/4_0/remove_old_parent.py View File

@@ -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))

Loading…
Cancel
Save