本文整理汇总了Python中community_share.models.secret.Secret.make_key方法的典型用法代码示例。如果您正苦于以下问题:Python Secret.make_key方法的具体用法?Python Secret.make_key怎么用?Python Secret.make_key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类community_share.models.secret.Secret
的用法示例。
在下文中一共展示了Secret.make_key方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from community_share.models.secret import Secret [as 别名]
# 或者: from community_share.models.secret.Secret import make_key [as 别名]
def setup(n_random_users=100):
logger.info('Starting setup script.')
init_db()
logger.info('Making labels.')
make_labels()
from community_share.models.secret import Secret
logger.info('Making Admin Users')
make_admin_user('[email protected]', '[email protected]', 'admin')
admin_emails = config.ADMIN_EMAIL_ADDRESSES.split(',')
admin_emails = [x.strip() for x in admin_emails]
logger.info('admin_emails is {0}'.format(admin_emails))
for email in admin_emails:
make_admin_user(email, email, Secret.make_key(20))
logger.info('Making {0} random users'.format(n_random_users))
for i in range(n_random_users):
make_random_user()
creator = get_creator()
logger.info('Creator of questions is {}'.format(creator.email))
questions = setup_data.get_questions(creator)
update_questions(questions)
store.session.commit()
creator = get_creator()
questions = setup_data.get_questions(creator)
update_questions(questions)
store.session.commit()
示例2: setup
# 需要导入模块: from community_share.models.secret import Secret [as 别名]
# 或者: from community_share.models.secret.Secret import make_key [as 别名]
def setup(n_random_users=100):
logger.info('Starting setup script.')
init_db()
first_admin = None
logger.info('Making labels.')
make_labels()
import os
from community_share.models.secret import Secret
admin_emails = config.ADMIN_EMAIL_ADDRESSES.split(',')
admin_emails = [x.strip() for x in admin_emails]
logger.info('admin_emails is {0}'.format(admin_emails))
logger.info('Making Admin Users')
for email in admin_emails:
if email:
user = make_admin_user(email, email, Secret.make_key(20))
if user is not None and first_admin is None:
first_admin = user
logger.info('Making {0} random users'.format(n_random_users))
for i in range(n_random_users):
make_random_user()
store.session.commit()
creator = get_creator()
questions = setup_data.get_questions(creator)
update_questions(questions)
store.session.commit()
示例3: make_random_user
# 需要导入模块: from community_share.models.secret import Secret [as 别名]
# 或者: from community_share.models.secret.Secret import make_key [as 别名]
def make_random_user():
# Make the user
first_name, last_name = gen_new_name(user_names_used, first_names, last_names)
if first_name is None:
return
user_names_used.add((first_name, last_name))
password = Secret.make_key(20)
password_hash = User.pwd_context.encrypt(password)
if random.randint(0, 1):
searcher_role = 'educator'
searching_for_role = 'partner'
bio = generate_educator_bio()
associations = [gen_random_institution(schools, educator_roles)]
else:
searcher_role = 'partner'
searching_for_role = 'educator'
bio = generate_expert_bio()
associations = [
gen_random_institution(companies, partner_roles) for _ in range(random.randint(1, 2))
]
new_user = User(
name='{0} {1}'.format(first_name, last_name),
email=gen_email(first_name, last_name),
password_hash=password_hash,
picture_filename=random.choice(profile_picture_filenames),
bio=bio,
institution_associations=associations,
is_administrator=False,
email_confirmed=True
)
store.session.add(new_user)
store.session.commit()
# Make the search
latitude, longitude = make_random_location()
search = Search(
searcher_user_id=new_user.id,
searcher_role=searcher_role,
searching_for_role=searching_for_role,
latitude=latitude,
longitude=longitude,
)
search.labels = Label.name_list_to_object_list(gen_labels())
store.session.add(search)
store.session.commit()
if search.searcher_role == 'educator':
new_user.educator_profile_search = search
else:
new_user.community_partner_profile_search = search
store.session.add(new_user)
store.session.commit()
示例4: make_random_user
# 需要导入模块: from community_share.models.secret import Secret [as 别名]
# 或者: from community_share.models.secret.Secret import make_key [as 别名]
def make_random_user():
# Make the user
finished = False
while not finished:
first_name = random_item_from_list(first_names)
last_name = random_item_from_list(last_names)
combined = (first_name, last_name)
if combined not in user_names_used:
finished = True
user_names_used.add(combined)
password = Secret.make_key(20)
email = make_email(first_name, last_name)
password_hash = User.pwd_context.encrypt(password)
name = '{0} {1}'.format(first_name, last_name)
picture_filename = random_item_from_list(profile_picture_filenames)
randombinary = random.randint(0, 1)
if randombinary:
searcher_role = 'educator'
searching_for_role = 'partner'
bio = generate_educator_bio()
institution_associations = [
InstitutionAssociation(
institution=random_item_from_list(schools),
role=random_item_from_list(educator_roles)
)]
else:
searcher_role = 'partner'
searching_for_role = 'educator'
bio = generate_expert_bio()
n_institutions = random.randint(1, 2)
institution_associations = [
InstitutionAssociation(
institution=random_item_from_list(companies),
role=random_item_from_list(partner_roles))
for x in range(n_institutions)]
new_user = User(name=name, email=email, password_hash=password_hash,
picture_filename=picture_filename, bio=bio,
institution_associations=institution_associations,
is_administrator=False, email_confirmed=True)
store.session.add(new_user)
store.session.commit()
# Make the search
location = make_random_location()
search = Search(
searcher_user_id=new_user.id,
searcher_role=searcher_role,
searching_for_role=searching_for_role,
latitude=location[0],
longitude=location[1],
)
search.labels = Label.name_list_to_object_list(get_labels())
store.session.add(search)
store.session.commit()
if search.searcher_role == 'educator':
new_user.educator_profile_search = search
else:
new_user.community_partner_profile_search = search
store.session.add(new_user)
store.session.commit()
示例5: main
# 需要导入模块: from community_share.models.secret import Secret [as 别名]
# 或者: from community_share.models.secret.Secret import make_key [as 别名]
def main():
logger.info('Loading settings from environment')
config.load_from_environment()
logger.info('Starting setup script produced on 2014 June 14th.')
setup.init_db()
first_admin = None
logger.info('Making labels.')
setup.make_labels()
admin_emails = os.environ.get('COMMUNITYSHARE_ADMIN_EMAILS', '').split(',')
admin_emails = [x.strip() for x in admin_emails]
logger.info('admin_emails is {0}'.format(admin_emails))
logger.info('Making Admin Users')
for email in admin_emails:
if email:
user = setup.make_admin_user(email, email, Secret.make_key(20))
if user is not None and first_admin is None:
first_admin = user
logger.info('Making questions')
setup.make_questions(first_admin)
store.session.commit()
示例6: setup
# 需要导入模块: from community_share.models.secret import Secret [as 别名]
# 或者: from community_share.models.secret.Secret import make_key [as 别名]
def setup(n_random_users=100):
logger.info('Starting setup script.')
init_db()
first_admin = None
logger.info('Making labels.')
make_labels()
import os
from community_share.models.secret import Secret
admin_emails = os.environ.get('COMMUNITYSHARE_ADMIN_EMAILS', '').split(',')
admin_emails = [x.strip() for x in admin_emails]
logger.info('admin_emails is {0}'.format(admin_emails))
logger.info('Making Admin Users')
for email in admin_emails:
if email:
user = make_admin_user(email, email, Secret.make_key(20))
if user is not None and first_admin is None:
first_admin = user
logger.info('Making {0} random users'.format(n_random_users))
for i in range(n_random_users):
make_random_user()
store.session.commit()