Merge pull request #418 from pdvyas/agent-fixes

Fixes for getting agent working
This commit is contained in:
Rushabh Mehta 2014-01-26 23:49:08 -08:00
commit f2a9e52140
3 changed files with 23 additions and 13 deletions

View file

@ -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')]:

View file

@ -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,14 @@ 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))
and not site in ('assets',)]
def setup_parser():
import argparse
@ -222,9 +224,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()
@ -710,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)

View file

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