本文整理汇总了Python中website.app.init_app函数的典型用法代码示例。如果您正苦于以下问题:Python init_app函数的具体用法?Python init_app怎么用?Python init_app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init_app函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(dry=True):
init_app(routes=False)
with transaction.atomic():
do_populate(clear=True)
if dry:
raise Exception('Abort Transaction - Dry Run')
开发者ID:erinspace,项目名称:osf.io,代码行数:7,代码来源:register_oauth_scopes.py
示例2: clear_sessions
def clear_sessions(ctx, months=1, dry_run=False):
from website.app import init_app
init_app(routes=False, set_backends=True)
from scripts import clear_sessions
clear_sessions.clear_sessions_relative(months=months, dry_run=dry_run)
开发者ID:ycchen1989,项目名称:osf.io,代码行数:7,代码来源:__init__.py
示例3: main
def main(send_email=False):
logger.info('Starting Project storage audit')
init_app(set_backends=True, routes=False)
lines = []
projects = {}
users = defaultdict(lambda: (0, 0))
for node in Node.find(Q('__backrefs.parent.node.nodes', 'eq', None)): # ODM hack to ignore all nodes with parents
if node._id in WHITE_LIST:
continue # Dont count whitelisted nodes against users
projects[node] = get_usage(node)
for contrib in node.contributors:
if node.can_edit(user=contrib):
users[contrib] = tuple(map(sum, zip(users[contrib], projects[node]))) # Adds tuples together, map(sum, zip((a, b), (c, d))) -> (a+c, b+d)
for collection, limit in ((users, USER_LIMIT), (projects, PROJECT_LIMIT)):
for item, (used, deleted) in filter(functools.partial(limit_filter, limit), collection.items()):
line = '{!r} has exceeded the limit {:.2f}GBs ({}b) with {:.2f}GBs ({}b) used and {:.2f}GBs ({}b) deleted.'.format(item, limit / GBs, limit, used / GBs, used, deleted / GBs, deleted)
logger.info(line)
lines.append(line)
if lines:
if send_email:
logger.info('Sending email...')
mails.send_mail('[email protected]', mails.EMPTY, body='\n'.join(lines), subject='Script: OsfStorage usage audit')
else:
logger.info('send_email is False, not sending email'.format(len(lines)))
logger.info('{} offending project(s) and user(s) found'.format(len(lines)))
else:
logger.info('No offending projects or users found')
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:31,代码来源:usage_audit.py
示例4: main
def main(dry_run=True):
init_app(routes=False)
popular_node_ids = popular_activity_json()['popular_node_ids']
popular_links_node = models.Node.find_one(Q('_id', 'eq', POPULAR_LINKS_NODE))
new_and_noteworthy_links_node = models.Node.find_one(Q('_id', 'eq', NEW_AND_NOTEWORTHY_LINKS_NODE))
new_and_noteworthy_node_ids = get_new_and_noteworthy_nodes()
update_node_links(popular_links_node, popular_node_ids, 'popular')
update_node_links(new_and_noteworthy_links_node, new_and_noteworthy_node_ids, 'new and noteworthy')
try:
popular_links_node.save()
logger.info('Node links on {} updated.'.format(popular_links_node._id))
except (KeyError, RuntimeError) as error:
logger.error('Could not migrate popular nodes due to error')
logger.exception(error)
try:
new_and_noteworthy_links_node.save()
logger.info('Node links on {} updated.'.format(new_and_noteworthy_links_node._id))
except (KeyError, RuntimeError) as error:
logger.error('Could not migrate new and noteworthy nodes due to error')
logger.exception(error)
if dry_run:
raise RuntimeError('Dry run -- transaction rolled back.')
开发者ID:HalcyonChimera,项目名称:osf.io,代码行数:27,代码来源:populate_new_and_noteworthy_projects.py
示例5: main
def main():
dry_run = '--dry' in sys.argv
if not dry_run:
script_utils.add_file_logger(logger, __file__)
init_app(set_backends=True, routes=False)
with transaction.atomic():
migrate(dry_run)
开发者ID:adlius,项目名称:osf.io,代码行数:7,代码来源:migrate_share_registration_data.py
示例6: main
def main():
init_app(routes=False) # Sets the storage backends on all models
dry = '--dry' in sys.argv
if not dry:
script_utils.add_file_logger(logger, __file__)
with TokuTransaction():
log_duplicate_acount(dry)
开发者ID:545zhou,项目名称:osf.io,代码行数:7,代码来源:get_duplicate_account.py
示例7: main
def main(dry_run=True):
init_app(routes=False)
from osf.models import AbstractNode
from website.project.utils import activity
popular_activity = activity()
popular_nodes = popular_activity['popular_public_projects']
popular_links_node = AbstractNode.find_one(Q('_id', 'eq', POPULAR_LINKS_NODE))
popular_registrations = popular_activity['popular_public_registrations']
popular_links_registrations = AbstractNode.find_one(Q('_id', 'eq', POPULAR_LINKS_REGISTRATIONS))
update_node_links(popular_links_node, popular_nodes, 'popular')
update_node_links(popular_links_registrations, popular_registrations, 'popular registrations')
try:
popular_links_node.save()
logger.info('Node links on {} updated.'.format(popular_links_node._id))
except (KeyError, RuntimeError) as error:
logger.error('Could not migrate popular nodes due to error')
logger.exception(error)
try:
popular_links_registrations.save()
logger.info('Node links for registrations on {} updated.'.format(popular_links_registrations._id))
except (KeyError, RuntimeError) as error:
logger.error('Could not migrate popular nodes for registrations due to error')
logger.exception(error)
if dry_run:
raise RuntimeError('Dry run -- transaction rolled back.')
开发者ID:adlius,项目名称:osf.io,代码行数:30,代码来源:populate_popular_projects_and_registrations.py
示例8: main
def main():
init_app(routes=False)
dry_run = '--dry' in sys.argv
with TokuTransaction():
lowercase_nids()
if dry_run:
raise Exception('Dry run')
开发者ID:545zhou,项目名称:osf.io,代码行数:7,代码来源:lowercase_log_nids.py
示例9: main
def main():
if 'dry' not in sys.argv:
scripts_utils.add_file_logger(logger, __file__)
# Set up storage backends
init_app(routes=False)
logger.info('{n} invalid GUID objects found'.format(n=len(get_targets())))
logger.info('Finished.')
开发者ID:545zhou,项目名称:osf.io,代码行数:7,代码来源:find_guids_without_referents.py
示例10: main
def main(dry=True):
init_app(set_backends=True, routes=False) # Sets the storage backends on all models
with TokuTransaction():
do_migration()
if dry:
raise Exception('Abort Transaction - Dry Run')
开发者ID:545zhou,项目名称:osf.io,代码行数:7,代码来源:migrate_to_generic.py
示例11: run_main
def run_main(dry_run=True):
if not dry_run:
scripts_utils.add_file_logger(logger, __file__)
init_app(routes=False)
with TokuTransaction():
main()
if dry_run:
raise RuntimeError("Dry run, rolling back transaction")
开发者ID:545zhou,项目名称:osf.io,代码行数:8,代码来源:approve_embargo_terminations.py
示例12: main
def main(dry=True):
init_app(set_backends=True, routes=False)
if not dry:
scripts_utils.add_file_logger(logger, __file__)
prereg = MetaSchema.find_one(
Q('name', 'eq', "Prereg Challenge"))
migrate_drafts_q5_metadata(prereg)
migrate_registrations_q5_metadata(prereg)
开发者ID:adlius,项目名称:osf.io,代码行数:8,代码来源:migrate_prereg_schema_multiple_choice_responses.py
示例13: main
def main():
dry = '--dry' in sys.argv
script_utils.add_file_logger(logger, __file__)
init_app(set_backends=True, routes=False)
with TokuTransaction():
migrate()
if dry:
raise RuntimeError('Dry run -- Transaction rolled back')
开发者ID:adlius,项目名称:osf.io,代码行数:8,代码来源:migrate_duplicate_external_accounts.py
示例14: main
def main(dry_run=True):
init_app()
nodes = find_file_mismatch_nodes()
print('Migrating {0} nodes'.format(len(nodes)))
if dry_run:
return
for node in nodes:
migrate_node(node)
开发者ID:545zhou,项目名称:osf.io,代码行数:8,代码来源:migrate_inconsistent_file_keys.py
示例15: main
def main():
dry_run = False
if '--dry' in sys.argv:
dry_run = True
if not dry_run:
script_utils.add_file_logger(logger, __file__)
init_app(set_backends=True, routes=False)
with TokuTransaction():
migrate(dry_run=dry_run)
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:migrate_folder_language.py
示例16: main
def main(dry=True):
init_app(set_backends=True, routes=False)
if not dry:
scripts_utils.add_file_logger(logger, __file__)
veer = MetaSchema.find_one(
Q('name', 'eq',
"Pre-Registration in Social Psychology (van 't Veer & Giner-Sorolla, 2016): Pre-Registration"))
migrate_drafts_metadata_key(veer)
migrate_registrations_metadata_key(veer)
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:migrate_metadata_for_veer_preregistrations.py
示例17: main
def main():
dry_run = '--dry' in sys.argv
if dry_run:
logger.warn('DRY RUN mode')
else:
utils.add_file_logger(logger, __file__)
init_app(routes=False)
with TokuTransaction():
migrate(dry_run)
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:migrate_primary_institutions.py
示例18: main
def main():
init_app(set_backends=True)
with open(BLACKLIST_FILE, 'r') as reader:
blacklist = [item.rstrip('\n') for item in reader]
chunk_size = len(blacklist)/4
chunks = [blacklist[0:chunk_size], blacklist[chunk_size:(chunk_size*2)], blacklist[(chunk_size*2):(chunk_size*3)], blacklist[(chunk_size*3):]]
for c in chunks:
create_blacklist_guid_objects(c)
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:add_blacklist_guids.py
示例19: main
def main():
init_app(routes=False) # Sets the storage backends on all models
if 'dry' in sys.argv:
user_list = get_targets()
for user in user_list:
log_info(user)
logger.info('[dry] Migrated {0} users'.format(len(user_list)))
else:
do_migration(get_targets())
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:migrate_unconfirmed_valid_users.py
示例20: main
def main():
init_app(set_backends=True, routes=False)
dry_run = '--dry' in sys.argv
if not dry_run:
script_utils.add_file_logger(logger, __file__)
with transaction.atomic():
update_taxonomies('bepress_taxonomy.json')
if dry_run:
raise RuntimeError('Dry run, transaction rolled back')
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:9,代码来源:update_taxonomies.py
注:本文中的website.app.init_app函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论