本文整理汇总了Python中webnotes.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: request
def request(args):
import webnotes.handler
webnotes.connect()
webnotes.form_dict = webnotes._dict([a.split("=") for a in args.split("&")])
webnotes.handler.execute_cmd(webnotes.form_dict.cmd)
print webnotes.response
webnotes.destroy()
开发者ID:bindscha,项目名称:wnframework_old,代码行数:7,代码来源:cli.py
示例2: clear_web
def clear_web(site=None):
import webnotes.webutils
webnotes.connect(site=site)
from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
build_website_sitemap_config()
webnotes.webutils.clear_cache()
webnotes.destroy()
开发者ID:Halfnhav,项目名称:wnframework,代码行数:7,代码来源:wnf.py
示例3: backup_to_dropbox
def backup_to_dropbox():
from dropbox import client, session
from conf import dropbox_access_key, dropbox_secret_key
from webnotes.utils.backups import new_backup
if not webnotes.conn:
webnotes.connect()
sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
sess.set_token(webnotes.conn.get_value("Backup Manager", None, "dropbox_access_key"),
webnotes.conn.get_value("Backup Manager", None, "dropbox_access_secret"))
dropbox_client = client.DropboxClient(sess)
# upload database
backup = new_backup()
filename = backup.backup_path_db
upload_file_to_dropbox(filename, "database", dropbox_client)
# upload files
response = dropbox_client.metadata("files")
# add missing files
for filename in os.listdir(os.path.join("public", "files")):
found = False
for file_metadata in response["contents"]:
if filename==os.path.basename(file_metadata["path"]):
if os.stat(os.path.join("public", "files", filename)).st_size==file_metadata["bytes"]:
found=True
if not found:
upload_file_to_dropbox(os.path.join("public", "files", filename), "files", dropbox_client)
开发者ID:alvz,项目名称:erpnext,代码行数:34,代码来源:backup_dropbox.py
示例4: backup_to_dropbox
def backup_to_dropbox():
from dropbox import client, session
from conf import dropbox_access_key, dropbox_secret_key
from webnotes.utils.backups import new_backup
if not webnotes.conn:
webnotes.connect()
sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
sess.set_token(webnotes.conn.get_value("Backup Manager", None, "dropbox_access_key"),
webnotes.conn.get_value("Backup Manager", None, "dropbox_access_secret"))
dropbox_client = client.DropboxClient(sess)
# upload database
backup = new_backup()
filename = os.path.join(get_base_path(), "public", "backups",
os.path.basename(backup.backup_path_db))
upload_file_to_dropbox(filename, "database", dropbox_client)
response = dropbox_client.metadata("/files")
# upload files to files folder
path = os.path.join(get_base_path(), "public", "files")
for filename in os.listdir(path):
found = False
filepath = os.path.join(path, filename)
for file_metadata in response["contents"]:
if os.path.basename(filepath) == os.path.basename(file_metadata["path"]) and os.stat(filepath).st_size == int(file_metadata["bytes"]):
found = True
break
if not found:
upload_file_to_dropbox(filepath, "files", dropbox_client)
开发者ID:PhamThoTam,项目名称:erpnext,代码行数:32,代码来源:backup_dropbox.py
示例5: make
def make():
import os
import webnotes
import website.utils
import startup.event_handlers
if not webnotes.conn:
webnotes.connect()
home_page = website.utils.get_home_page()
fname = 'js/wn-web.js'
if os.path.basename(os.path.abspath('.'))!='public':
fname = os.path.join('public', fname)
if hasattr(startup.event_handlers, 'get_web_script'):
with open(fname, 'w') as f:
script = 'window.home_page = "%s";\n' % home_page
script += startup.event_handlers.get_web_script()
f.write(script)
fname = 'css/wn-web.css'
if os.path.basename(os.path.abspath('.'))!='public':
fname = os.path.join('public', fname)
# style - wn.css
if hasattr(startup.event_handlers, 'get_web_style'):
with open(fname, 'w') as f:
f.write(startup.event_handlers.get_web_style())
开发者ID:AminfiBerlin,项目名称:erpnext,代码行数:29,代码来源:make_web_include_files.py
示例6: reset_perms
def reset_perms(site=None):
webnotes.connect(site=site)
for d in webnotes.conn.sql_list("""select name from `tabDocType`
where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
webnotes.clear_cache(doctype=d)
webnotes.reset_perms(d)
webnotes.destroy()
开发者ID:Halfnhav,项目名称:wnframework,代码行数:7,代码来源:wnf.py
示例7: run
def run():
webnotes.connect()
# Confirmation from user
confirm = ''
while not confirm:
confirm = raw_input("Are you sure you want to delete the data from the system (N/Y)?")
if confirm.lower() != 'y':
raise Exception
cleanup_type = ''
while cleanup_type not in ['1', '2']:
cleanup_type = raw_input("""\nWhat type of cleanup you want ot perform?
1. Only Transactions
2. Both Masters and Transactions
Please enter your choice (1/2):
""")
# delete
delete_transactions()
if cleanup_type == '1':
reset_transaction_series()
else:
delete_masters()
reset_all_series()
delete_main_masters()
reset_global_defaults()
print "System cleaned up succesfully"
webnotes.conn.close()
开发者ID:hbkfabio,项目名称:erpnext,代码行数:32,代码来源:cleanup_data.py
示例8: latest
def latest(site=None, verbose=True):
import webnotes.modules.patch_handler
import webnotes.model.sync
import webnotes.plugins
from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
webnotes.connect(site=site)
try:
# run patches
webnotes.local.patch_log_list = []
webnotes.modules.patch_handler.run_all()
if verbose:
print "\n".join(webnotes.local.patch_log_list)
# sync
webnotes.model.sync.sync_all()
# remove __init__.py from plugins
webnotes.plugins.remove_init_files()
# build website config if any changes in templates etc.
build_website_sitemap_config()
except webnotes.modules.patch_handler.PatchError, e:
print "\n".join(webnotes.local.patch_log_list)
raise
开发者ID:Halfnhav,项目名称:wnframework,代码行数:27,代码来源:wnf.py
示例9: patch
def patch(patch_module, site=None, force=False):
import webnotes.modules.patch_handler
webnotes.connect(site=site)
webnotes.local.patch_log_list = []
webnotes.modules.patch_handler.run_single(patch_module, force=force)
print "\n".join(webnotes.local.patch_log_list)
webnotes.destroy()
开发者ID:Halfnhav,项目名称:wnframework,代码行数:7,代码来源:wnf.py
示例10: make
def make():
webnotes.connect()
webnotes.mute_emails = True
install()
complete_setup()
make_items()
make_customers_suppliers_contacts()
开发者ID:frank1638,项目名称:erpnext,代码行数:7,代码来源:make_demo.py
示例11: get_html
def get_html(page_name):
"""get page html"""
page_name = scrub_page_name(page_name)
html = ''
# load from cache, if auto cache clear is falsy
if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0):
if not page_name in no_cache:
html = webnotes.cache().get_value("page:" + page_name)
from_cache = True
if not html:
webnotes.connect()
html = load_into_cache(page_name)
from_cache = False
if not html:
html = get_html("404")
if page_name=="error":
html = html.replace("%(error)s", webnotes.getTraceback())
else:
comments = "\n\npage:"+page_name+\
"\nload status: " + (from_cache and "cache" or "fresh")
html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments)
return html
开发者ID:leondai78,项目名称:erpnext,代码行数:28,代码来源:utils.py
示例12: main
def main():
import argparse
parser = argparse.ArgumentParser(description='Run tests.')
parser.add_argument('-d', '--doctype', nargs=1, metavar = "DOCTYPE",
help="test for doctype")
parser.add_argument('-v', '--verbose', default=False, action="store_true")
parser.add_argument('-e', '--export', nargs=2, metavar="DOCTYPE DOCNAME")
parser.add_argument('-a', '--all', default=False, action="store_true")
parser.add_argument('-m', '--module', default=1, metavar="MODULE")
args = parser.parse_args()
if not webnotes.conn:
webnotes.connect()
webnotes.flags.print_messages = args.verbose
webnotes.flags.in_test = True
if args.doctype:
run_unittest(args.doctype[0], verbose=args.verbose)
elif args.all:
run_all_tests(args.verbose)
elif args.export:
export_doc(args.export[0], args.export[1])
elif args.module:
import importlib
test_suite = unittest.TestSuite()
module = importlib.import_module(args.module)
if hasattr(module, "test_dependencies"):
for doctype in module.test_dependencies:
make_test_records(doctype, verbose=args.verbose)
test_suite.addTest(unittest.TestLoader().loadTestsFromModule(sys.modules[args.module]))
unittest.TextTestRunner(verbosity=1+(args.verbose and 1 or 0)).run(test_suite)
开发者ID:Halfnhav,项目名称:wnframework,代码行数:35,代码来源:test_runner.py
示例13: set_admin_password
def set_admin_password(admin_password, site=None):
import webnotes
webnotes.connect(site=site)
webnotes.conn.sql("""update __Auth set `password`=password(%s)
where user='Administrator'""", (admin_password,))
webnotes.conn.commit()
webnotes.destroy()
开发者ID:Halfnhav,项目名称:wnframework,代码行数:7,代码来源:wnf.py
示例14: build_page
def build_page(page_name):
if not webnotes.conn:
webnotes.connect()
sitemap = get_website_sitemap()
page_options = sitemap.get(page_name)
if not page_options:
if page_name=="index":
# page not found, try home page
home_page = get_home_page()
page_options = sitemap.get(home_page)
if not page_options:
raise PageNotFoundError
page_options["page_name"] = home_page
else:
raise PageNotFoundError
else:
page_options["page_name"] = page_name
basepath = webnotes.utils.get_base_path()
module = None
no_cache = False
if page_options.get("controller"):
module = webnotes.get_module(page_options["controller"])
no_cache = getattr(module, "no_cache", False)
# if generator, then load bean, pass arguments
if page_options.get("is_generator"):
if not module:
raise Exception("Generator controller not defined")
name = webnotes.conn.get_value(module.doctype, {
page_options.get("page_name_field", "page_name"): page_options["page_name"]})
obj = webnotes.get_obj(module.doctype, name, with_children=True)
if hasattr(obj, 'get_context'):
obj.get_context()
context = webnotes._dict(obj.doc.fields)
context["obj"] = obj
else:
# page
context = webnotes._dict({ 'name': page_name })
if module and hasattr(module, "get_context"):
context.update(module.get_context())
context.update(get_website_settings())
jenv = webnotes.get_jenv()
context["base_template"] = jenv.get_template(webnotes.get_config().get("base_template"))
template_name = page_options['template']
html = jenv.get_template(template_name).render(context)
if not no_cache:
webnotes.cache().set_value("page:" + page_name, html)
return html
开发者ID:ricardomomm,项目名称:wnframework,代码行数:59,代码来源:webutils.py
示例15: domain
def domain(host_url=None, site=None):
webnotes.connect(site=site)
if host_url:
webnotes.conn.set_value("Website Settings", None, "subdomain", host_url)
webnotes.conn.commit()
else:
print webnotes.conn.get_value("Website Settings", None, "subdomain")
webnotes.destroy()
开发者ID:Halfnhav,项目名称:wnframework,代码行数:8,代码来源:wnf.py
示例16: run_scheduler
def run_scheduler():
from webnotes.utils.file_lock import create_lock, delete_lock
import webnotes.utils.scheduler
if create_lock('scheduler'):
webnotes.connect()
print webnotes.utils.scheduler.execute()
delete_lock('scheduler')
webnotes.destroy()
开发者ID:bindscha,项目名称:wnframework_old,代码行数:8,代码来源:cli.py
示例17: create_owrang_folder
def create_owrang_folder(service):
if not webnotes.conn:
webnotes.connect()
owrang = {
'title': 'owrang',
'mimeType': 'application/vnd.google-apps.folder'
}
owrang = service.files().insert(body=owrang).execute()
return owrang['id']
开发者ID:Yellowen,项目名称:Owrang,代码行数:9,代码来源:backup_googledrive.py
示例18: backup
def backup(site=None, with_files=False, verbose=True, backup_path_db=None, backup_path_files=None):
from webnotes.utils.backups import scheduled_backup
webnotes.connect(site=site)
print backup_path_db
odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files)
if verbose:
from webnotes.utils import now
print "backup taken -", odb.backup_path_db, "- on", now()
return odb
开发者ID:ricardomomm,项目名称:wnframework,代码行数:9,代码来源:wnf.py
示例19: make_demo_app
def make_demo_app():
webnotes.mute_emails = 1
webnotes.connect()
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)
开发者ID:rohitw1991,项目名称:latestadberp,代码行数:9,代码来源:make_erpnext_demo.py
示例20: make
def make(reset=False):
webnotes.connect()
#webnotes.print_messages = True
webnotes.mute_emails = True
webnotes.rollback_on_exception = True
if reset:
setup()
simulate()
开发者ID:imjk768646z,项目名称:erpnext,代码行数:9,代码来源:make_demo.py
注:本文中的webnotes.connect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论