From 3087069bce84f5962426af88ff204a2e3495ae32 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 21 Jan 2014 12:52:41 +0530 Subject: [PATCH 1/4] fix get_sites for 4.0.0 --- webnotes/cli.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/webnotes/cli.py b/webnotes/cli.py index cc9cb9ebe3..d36287d483 100755 --- a/webnotes/cli.py +++ b/webnotes/cli.py @@ -25,7 +25,7 @@ def main(): exit(1) if parsed_args.get("site")=="all": - for site in get_sites(): + for site in get_sites(parsed_args["sites_path"]): args = parsed_args.copy() args["site"] = site webnotes.init(site) @@ -65,12 +65,13 @@ def get_function(args): if (val or isinstance(val, list)) and globals().get(fn): return fn -def get_sites(): +def get_sites(sites_path=None): import os - import conf - return [site for site in os.listdir(conf.sites_dir) - if not os.path.islink(os.path.join(conf.sites_dir, site)) - and os.path.isdir(os.path.join(conf.sites_dir, site))] + if not sites_path: + sites_path = '.' + return [site for site in os.listdir(sites_path) + if not os.path.islink(os.path.join(sites_path, site)) + and os.path.isdir(os.path.join(sites_path, site))] def setup_parser(): import argparse From b97f467b98ecfca94511d445e8c0aa20388b0f38 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 21 Jan 2014 16:14:01 +0530 Subject: [PATCH 2/4] separate public dir making from building --- webnotes/build.py | 6 ++---- webnotes/cli.py | 3 ++- webnotes/installer.py | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/webnotes/build.py b/webnotes/build.py index c06cca4d0f..c3724f3e33 100644 --- a/webnotes/build.py +++ b/webnotes/build.py @@ -15,7 +15,7 @@ import webnotes.translate def bundle(no_compress): """concat / minify js files""" # build js files - make_site_public_dirs() + make_asset_dirs() build(no_compress) webnotes.translate.clear_cache() @@ -30,12 +30,10 @@ def watch(no_compress): time.sleep(3) -def make_site_public_dirs(): +def make_asset_dirs(): assets_path = os.path.join(webnotes.local.sites_path, "assets") site_public_path = os.path.join(webnotes.local.site_path, 'public') for dir_path in [ - os.path.join(site_public_path, 'backups'), - os.path.join(site_public_path, 'files'), os.path.join(assets_path, 'js'), os.path.join(assets_path, 'css')]: diff --git a/webnotes/cli.py b/webnotes/cli.py index d36287d483..5989d01840 100755 --- a/webnotes/cli.py +++ b/webnotes/cli.py @@ -223,9 +223,10 @@ def make_app(): @cmd def install(db_name, root_login="root", root_password=None, source_sql=None, admin_password = 'admin', verbose=True, force=False, site_config=None, reinstall=False): - from webnotes.installer import install_db, install_app + from webnotes.installer import install_db, install_app, make_site_dirs 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("webnotes", verbose=verbose) webnotes.destroy() diff --git a/webnotes/installer.py b/webnotes/installer.py index 0f6ca1c33f..192d1e1304 100755 --- a/webnotes/installer.py +++ b/webnotes/installer.py @@ -162,3 +162,11 @@ def get_conf_params(db_name=None, db_password=None): db_password = random_string(16) return {"db_name": db_name, "db_password": db_password} + +def make_site_dirs(): + site_public_path = os.path.join(webnotes.local.site_path, 'public') + for dir_path in ( + os.path.join(site_public_path, 'backups'), + os.path.join(site_public_path, 'files')): + if not os.path.exists(dir_path): + os.makedirs(dir_path) From c830f56fb7893cbe302e82fe9651ae7071c4b13a Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 27 Jan 2014 11:21:04 +0530 Subject: [PATCH 3/4] site name cannot be assets --- webnotes/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webnotes/cli.py b/webnotes/cli.py index 5989d01840..83fd448fca 100755 --- a/webnotes/cli.py +++ b/webnotes/cli.py @@ -71,7 +71,8 @@ def get_sites(sites_path=None): sites_path = '.' return [site for site in os.listdir(sites_path) if not os.path.islink(os.path.join(sites_path, site)) - and os.path.isdir(os.path.join(sites_path, site))] + and os.path.isdir(os.path.join(sites_path, site)) + and not site in ('assets',)] def setup_parser(): import argparse From 774ff77c1d42e7624dc7de8e17ed9331c0fe9b26 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 27 Jan 2014 12:34:57 +0530 Subject: [PATCH 4/4] fix update_site_config --- webnotes/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webnotes/cli.py b/webnotes/cli.py index 83fd448fca..747cb86a92 100755 --- a/webnotes/cli.py +++ b/webnotes/cli.py @@ -713,8 +713,9 @@ def update_site_config(site_config, verbose=False): if isinstance(site_config, basestring): site_config = json.loads(site_config) - webnotes.conf.site_config.update(site_config) - site_config_path = webnotes.get_conf_path(webnotes.conf.sites_dir) + config = webnotes.get_site_config() + config.update(site_config) + site_config_path = site_filepath = os.path.join(webnotes.local.site_path, "site_config.json") with open(site_config_path, "w") as f: json.dump(webnotes.conf.site_config, f, indent=1, sort_keys=True)