本文整理汇总了Python中webnotes.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mysql
def mysql(site=None):
import webnotes
import commands, os
msq = commands.getoutput('which mysql')
webnotes.init(site=site)
os.execv(msq, [msq, '-u', webnotes.conf.db_name, '-p'+webnotes.conf.db_password, webnotes.conf.db_name, '-h', webnotes.conf.db_host or "localhost", "-A"])
webnotes.destroy()
示例2: make_conf
def make_conf(db_name=None, db_password=None, site=None, site_config=None):
try:
from werkzeug.exceptions import NotFound
import conf
try:
webnotes.init(site=site)
except NotFound:
pass
if not site and webnotes.conf.site:
site = webnotes.conf.site
if site:
# conf exists and site is specified, create site_config.json
make_site_config(site, db_name, db_password, site_config)
elif os.path.exists("conf.py"):
print "conf.py exists"
else:
# pyc file exists but py doesn't
raise ImportError
except ImportError:
if site:
raise Exception("conf.py does not exist")
else:
# create conf.py
with open(os.path.join("lib", "conf", "conf.py"), "r") as confsrc:
with open("conf.py", "w") as conftar:
conftar.write(confsrc.read() % get_conf_params(db_name, db_password))
webnotes.destroy()
webnotes.init(site=site)
示例3: main
def main():
parsed_args = webnotes._dict(vars(setup_parser()))
fn = get_function(parsed_args)
if not parsed_args.get("sites_path"):
parsed_args["sites_path"] = "."
if not parsed_args.get("make_app"):
if parsed_args.get("site")=="all":
for site in get_sites(parsed_args["sites_path"]):
args = parsed_args.copy()
args["site"] = site
webnotes.init(site)
run(fn, args)
else:
if not fn in site_arg_optional:
if not parsed_args.get("site") and os.path.exists("currentsite.txt"):
with open("currentsite.txt", "r") as sitefile:
site = sitefile.read()
else:
site = parsed_args.get("site")
if not site:
print "Site argument required"
exit(1)
if fn != 'install' and not os.path.exists(site):
print "Did not find folder '{}'. Are you in sites folder?".format(parsed_args.get("site"))
exit(1)
webnotes.init(site)
run(fn, parsed_args)
else:
run(fn, parsed_args)
示例4: application
def application(request):
webnotes.local.request = request
try:
site = _site or get_site_name(request.host)
webnotes.init(site=site)
if not webnotes.local.conf:
# site does not exist
raise NotFound
webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
for k, v in (request.form or request.args).iteritems() })
webnotes.local._response = Response()
webnotes.http_request = webnotes.auth.HTTPRequest()
if webnotes.local.form_dict.cmd:
webnotes.handler.handle()
elif webnotes.request.path.startswith("/api/"):
webnotes.api.handle()
elif webnotes.local.request.method in ('GET', 'HEAD'):
webnotes.webutils.render(webnotes.request.path[1:])
else:
raise NotFound
except HTTPException, e:
return e
示例5: run_scheduler
def run_scheduler(site=None):
from webnotes.utils.file_lock import create_lock, delete_lock
import webnotes.utils.scheduler
webnotes.init(site=site)
if create_lock('scheduler'):
webnotes.connect(site=site)
print webnotes.utils.scheduler.execute()
delete_lock('scheduler')
webnotes.destroy()
示例6: python
def python(site=None):
import webnotes
import commands, os
python = commands.getoutput('which python')
webnotes.init(site=site)
if site:
os.environ["site"] = site
os.environ["PYTHONSTARTUP"] = os.path.join(os.path.dirname(__file__), "pythonrc.py")
os.execv(python, [python])
webnotes.destroy()
示例7: update_all_sites
def update_all_sites(remote=None, branch=None, verbose=True):
pull(remote, branch)
# maybe there are new framework changes, any consequences?
reload(webnotes)
build()
for site in get_sites():
webnotes.init(site)
latest(verbose=verbose)
示例8: make_demo_app
def make_demo_app(site=None):
webnotes.mute_emails = 1
webnotes.init(site=site)
utilities.demo.make_demo.make(reset=True, simulate=False)
# setup demo user etc so that the site it up faster, while the data loads
make_demo_user()
make_demo_login_page()
make_demo_on_login_script()
utilities.demo.make_demo.make(reset=False, simulate=True)
示例9: get_remote_and_branch
def get_remote_and_branch(remote=None, branch=None):
if not (remote and branch):
webnotes.init()
if not webnotes.conf.branch:
raise Exception("Please specify remote and branch")
remote = remote or "origin"
branch = branch or webnotes.conf.branch
webnotes.destroy()
return remote, branch
示例10: update_site_config
def update_site_config(site_config, site, verbose=False):
import json
if isinstance(site_config, basestring):
site_config = json.loads(site_config)
webnotes.init(site=site)
webnotes.conf.site_config.update(site_config)
site_config_path = webnotes.get_conf_path(webnotes.conf.sites_dir, site)
with open(site_config_path, "w") as f:
json.dump(webnotes.conf.site_config, f, indent=1, sort_keys=True)
webnotes.destroy()
示例11: application
def application(request):
webnotes.local.request = request
try:
site = webnotes.utils.get_site_name(request.host)
webnotes.init(site=site)
webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
for k, v in (request.form or request.args).iteritems() })
webnotes.local._response = Response()
try:
webnotes.http_request = webnotes.auth.HTTPRequest()
except webnotes.AuthenticationError, e:
pass
if webnotes.form_dict.cmd:
webnotes.handler.handle()
else:
webnotes.webutils.render(webnotes.request.path[1:])
示例12: move
def move(site=None, dest_dir=None):
import os
if not dest_dir:
raise Exception, "--dest_dir is required for --move"
if not os.path.isdir(dest_dir):
raise Exception, "destination is not a directory or does not exist"
webnotes.init(site=site)
old_path = webnotes.utils.get_site_path()
new_path = os.path.join(dest_dir, site)
# check if site dump of same name already exists
site_dump_exists = True
count = 0
while site_dump_exists:
final_new_path = new_path + (count and str(count) or "")
site_dump_exists = os.path.exists(final_new_path)
count = int(count or 0) + 1
os.rename(old_path, final_new_path)
webnotes.destroy()
return os.path.basename(final_new_path)
示例13: make_demo_fresh
def make_demo_fresh(site=None):
import utilities.demo.make_demo
webnotes.init(site=site)
utilities.demo.make_demo.make(reset=True)
webnotes.destroy()
示例14: make_demo
def make_demo(site=None):
import utilities.demo.make_demo
webnotes.init(site=site)
utilities.demo.make_demo.make()
webnotes.destroy()
示例15: install_fixtures
def install_fixtures(site=None):
webnotes.init(site=site)
from webnotes.install_lib.install import install_fixtures
install_fixtures()
webnotes.destroy()