本文整理汇总了Python中util.uuid函数的典型用法代码示例。如果您正苦于以下问题:Python uuid函数的具体用法?Python uuid怎么用?Python uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_config_update
def admin_config_update():
config_db = model.Config.get_master_db()
form = ConfigUpdateForm(obj=config_db)
if form.validate_on_submit():
form.populate_obj(config_db)
if not config_db.flask_secret_key:
config_db.flask_secret_key = util.uuid()
if not config_db.salt:
config_db.salt = util.uuid()
config_db.put()
reload(config)
app.config.update(CONFIG_DB=config_db)
return flask.redirect(flask.url_for('welcome'))
if flask.request.path.startswith('/_s/'):
return util.jsonify_model_db(config_db)
instances_url = None
if config.PRODUCTION:
instances_url = '%s?app_id=%s&version_id=%s' % (
'https://appengine.google.com/instances',
app_identity.get_application_id(),
config.CURRENT_VERSION_ID,
)
return flask.render_template(
'admin/config_update.html',
title='Admin Config',
html_class='admin-config',
form=form,
config_db=config_db,
instances_url=instances_url,
has_json=True,
)
示例2: admin_config
def admin_config():
config_db = model.Config.get_master_db()
form = ConfigUpdateForm(obj=config_db)
if form.validate_on_submit():
if form.trusted_hosts.data:
form.trusted_hosts.data = set(
[e.strip() for e in form.trusted_hosts.data.split(',')])
else:
form.trusted_hosts.data = []
form.populate_obj(config_db)
if not config_db.flask_secret_key:
config_db.flask_secret_key = util.uuid()
if not config_db.salt:
config_db.salt = util.uuid()
config_db.put()
reload(config)
app.config.update(CONFIG_DB=config_db)
return flask.redirect(flask.url_for('admin'))
form.trusted_hosts.data = ', '.join(config_db.trusted_hosts)
return flask.render_template(
'admin/admin_config.html',
title=_('App Config'),
html_class='admin-config',
form=form,
api_url=flask.url_for('api.admin.config'),
)
示例3: user_reset
def user_reset(token=None):
user_db = model.User.get_by('token', token)
if not user_db:
flask.flash(__('That link is either invalid or expired.'), category='danger')
return flask.redirect(flask.url_for('welcome'))
if auth.is_logged_in():
login.logout_user()
return flask.redirect(flask.request.path)
form = UserResetForm()
if form.validate_on_submit():
user_db.password_hash = util.password_hash(user_db, form.new_password.data)
user_db.token = util.uuid()
user_db.verified = True
user_db.put()
flask.flash(__('Your password was changed succesfully.'), category='success')
return auth.signin_user_db(user_db)
return flask.render_template(
'user/user_reset.html',
title='Reset Password',
html_class='user-reset',
form=form,
user_db=user_db,
)
示例4: user_activate
def user_activate(token):
if auth.is_logged_in():
login.logout_user()
return flask.redirect(flask.request.path)
user_db = model.User.get_by('token', token)
if not user_db:
flask.flash(__('That link is either invalid or expired.'), category='danger')
return flask.redirect(flask.url_for('welcome'))
form = UserActivateForm(obj=user_db)
if form.validate_on_submit():
form.populate_obj(user_db)
user_db.password_hash = util.password_hash(user_db, form.password.data)
user_db.token = util.uuid()
user_db.verified = True
user_db.put()
return auth.signin_user_db(user_db)
return flask.render_template(
'user/user_activate.html',
title='Activate Account',
html_class='user-activate',
user_db=user_db,
form=form,
)
示例5: reset_password_notification
def reset_password_notification(user_db):
"""Sends email with url, which user can use to reset his password
Args:
user_db (model.User): User, who requested password reset
"""
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
receiver = '%s <%s>' % (user_db.name, user_db.email)
body = '''Hello %(name)s,
it seems someone (hopefully you) tried to reset your password with %(brand)s.
In case it was you, please reset it by following this link:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'name': user_db.name,
'link': flask.url_for('user_reset', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
send_mail_notification('Reset your password', body, receiver)
示例6: create_user_db
def create_user_db(auth_id, name, username, email='', verified=False, **props):
email = email.lower() if email else ''
if verified and email:
user_dbs, _ = model.User.get_dbs(email=email, verified=True, limit=2)
if len(user_dbs) == 1:
user_db = user_dbs[0]
user_db.auth_ids.append(auth_id)
user_db.put()
task.new_user_notification(user_db)
return user_db
if isinstance(username, str):
username = username.decode('utf-8')
username = unidecode.unidecode(username.split('@')[0].lower()).strip()
username = re.sub(r'[\W_]+', '.', username)
new_username = username
n = 1
while not model.User.is_username_available(new_username):
new_username = '%s%d' % (username, n)
n += 1
user_db = model.User(
name=name,
email=email,
username=new_username,
auth_ids=[auth_id],
verified=verified,
token=util.uuid(),
**props
)
user_db.put()
task.new_user_notification(user_db)
return user_db
示例7: verify_user_email_notification
def verify_user_email_notification(user_db):
"""Sends email, which user can use to verify his email address
Args:
user_db (model.User): user, who should verify his email
"""
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
receiver = user_db.email
body = '''Welcome to %(brand)s.
Follow the link below to confirm your email address and activate your account:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'link': flask.url_for('user_verify', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
send_mail_notification('Verify your email', body, receiver)
示例8: activate_user_notification
def activate_user_notification(user_db):
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
to = user_db.email
body = '''Welcome to %(brand)s.
Follow the link below to confirm your email address and activate your account:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'link': flask.url_for('user_activate', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
flask.flash(
'An activation link has been sent to your email address.',
category='success',
)
send_mail_notification('Activate your account', body, to)
示例9: reset_password_notification
def reset_password_notification(user_db):
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
to = '%s <%s>' % (user_db.name, user_db.email)
body = '''Hello %(name)s,
it seems someone (hopefully you) tried to reset your password with %(brand)s.
In case it was you, please reset it by following this link:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'name': user_db.name,
'link': flask.url_for('user_reset', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
flask.flash(
'A reset link has been sent to your email address.',
category='success',
)
send_mail_notification('Reset your password', body, to)
示例10: verify_email_notification
def verify_email_notification(user_db):
if not (config.CONFIG_DB.verify_email and user_db.email) or user_db.verified:
return
user_db.token = util.uuid()
user_db.put()
to = '%s <%s>' % (user_db.name, user_db.email)
body = '''Hello %(name)s,
it seems someone (hopefully you) tried to verify your email with %(brand)s.
In case it was you, please verify it by following this link:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'name': user_db.name,
'link': flask.url_for('user_verify', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
send_mail_notification('Verify your email!', body, to)
示例11: incoming_call
def incoming_call(user_id):
'''
Entry point for new, incoming calls.
'''
numberInfo = mongo.db.numbers.find_one({'number': request.form['To']})
# Verify that the dialed phone number is in the database
if not numberInfo:
app.logger.info("WARNING: Number {} not in database.".format(request.form['To']))
err = plivoxml.Response()
err.addSpeak(body="There has been an error. Please contact somebody.")
return Response(str(err), mimetype='text/xml')
# Get basic data from the POST
caller_number = request.form['From']
dialed_number = request.form['To']
route_type = numberInfo['defaultRoute'][0]['type']
bridge_name = uuid()
# Get list of numbers to ring
if route_type == "ringOne":
connect_to_number = numberInfo['defaultRoute'][0]['number']
connect_to_number_digits = readable_digits(connect_to_number)
numbers_to_try = [connect_to_number]
elif route_type == "ringMany":
numbers_to_try = [number for number in numberInfo['defaultRoute'][0]['numbers']]
connect_to_number_digits = "one of multiple phone numbers."
if DEBUG:
log_state('incoming_call', locals())
r = plivoxml.Response()
r.addSpeak(body="I will attempt to connect you to " + connect_to_number_digits)
r.addConference(
body=bridge_name,
waitSound=base_url_for(
'wait_sound',
user_id=user_id
),
callbackUrl=base_url_for(
'bridge_enter_exit',
user_id=user_id,
bridge_name=bridge_name,
caller_number=caller_number,
dialed_number=dialed_number,
numbers_to_try='+'.join(numbers_to_try)
),
action=base_url_for(
'action_by_caller',
user_id=user_id,
bridge_name=bridge_name,
caller_number=caller_number,
dialed_number=dialed_number
)
)
return Response(str(r), mimetype='text/xml')
示例12: user_verify
def user_verify(token):
user_db = auth.current_user_db()
if user_db.token != token:
flask.flash(__('That link is either invalid or expired.'), category='danger')
return flask.redirect(flask.url_for('profile'))
user_db.verified = True
user_db.token = util.uuid()
user_db.put()
flask.flash(__('Hooray! Your email is now verified.'), category='success')
return flask.redirect(flask.url_for('profile'))
示例13: add
def add(self, file, type):
# if /dev/null, say bye bye
if self.url == "/dev/null":
return
name = os.path.basename(file)
id = util.uuid()
shutil.copy(file, path.ftp_queue_dir + '/' + id)
self.queue.append({'name': name, 'id': id, 'type': type})
st = os.stat(path.ftp_queue_dir + '/' + id)
self.status += "%10d %s\n" % (st.st_size, name)
示例14: user_verify
def user_verify(token):
user_db = auth.current_user_db()
if user_db.token != token:
flask.flash("That link is either invalid or expired.", category="danger")
return flask.redirect(flask.url_for("profile"))
user_db.verified = True
user_db.token = util.uuid()
user_db.put()
flask.flash("Hooray! Your email is now verified.", category="success")
return flask.redirect(flask.url_for("profile"))
示例15: send_rpmqa
def send_rpmqa():
tmp = path.build_dir + '/' + util.uuid() + '/'
os.mkdir(tmp)
log = tmp + config.rpmqa_filename
open(log, 'a').write("Query done at: %s\n" % datetime.datetime.now().isoformat(' '))
chroot.run("rpm -qa|sort", logfile=log)
os.chmod(log,0644)
ftp.init(rpmqa=True)
ftp.add(log)
ftp.flush()
os.unlink(log)
os.rmdir(tmp)