本文整理汇总了Python中model.User.description方法的典型用法代码示例。如果您正苦于以下问题:Python User.description方法的具体用法?Python User.description怎么用?Python User.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.description方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: oauth_authorized
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import description [as 别名]
def oauth_authorized(resp):
"""Called after authorization. After this function finished handling,
the OAuth information is removed from the session again. When this
happened, the tokengetter from above is used to retrieve the oauth
token and secret.
Because the remote application could have re-authorized the application
it is necessary to update the values in the database.
If the application redirected back after denying, the response passed
to the function will be `None`. Otherwise a dictionary with the values
the application submitted. Note that Twitter itself does not really
redirect back unless the user clicks on the application name.
"""
next_url = request.args.get('next') or url_for('index')
if resp is None:
#TODO: show friendly message
#flash(u'You denied the request to sign in.')
return redirect(next_url)
screen_name = resp['screen_name']
oauth_token = resp['oauth_token']
oauth_token_secret = resp['oauth_token_secret']
user = User.select_by_screen_name(screen_name)
if not user:
app.logger.debug('User not found on database. Using the Twitter API')
auth = tweepy.OAuthHandler(config.CONSUMER_KEY, config.CONSUMER_SECRET)
auth.set_access_token(oauth_token, oauth_token_secret)
api = tweepy.API(auth)
twitter_user = api.get_user(screen_name=screen_name)
user = User()
user.id = twitter_user.id
user.screen_name = twitter_user.screen_name
user.blocked = 'N'
user.name = twitter_user.name
user.description = twitter_user.description
user.created_at = twitter_user.created_at
user.friends_count = twitter_user.friends_count
user.followers_count = twitter_user.followers_count
user.statuses_count = twitter_user.statuses_count
user.profile_image_url = twitter_user.profile_image_url
user.lang = twitter_user.lang
user.location = twitter_user.location
user.oauth_token = oauth_token
user.oauth_token_secret = oauth_token_secret
User.add(user)
else:
user.oauth_token = oauth_token
user.oauth_token_secret = oauth_token_secret
flask.session['screen_name'] = resp['screen_name']
flask.session['oauth_token'] = resp['oauth_token']
flask.session['oauth_token_secret'] = resp['oauth_token_secret']
commit()
return flask.redirect(next_url)
示例2: __init__
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import description [as 别名]
def __init__(self, username = 'root', password = None):
'''
Try to create the database when there is none
initialize 'root' user and 'root' & 'primary' group
'''
try:
User.query.all()
except:
db.create_all()
if password == None:
#set a random password
password = os.urandom(16)
password = b64encode(password).decode('utf-8')
fsdir = env.getenv('FS_PREFIX')
f = open(fsdir + '/local/generated_password.txt', 'w')
f.write("User=%s\nPass=%s\n"%(username, password))
f.close()
sys_admin = User(username, hashlib.sha512(password.encode('utf-8')).hexdigest())
sys_admin.status = 'normal'
sys_admin.nickname = 'root'
sys_admin.description = 'Root_User'
sys_admin.user_group = 'root'
sys_admin.auth_method = 'local'
db.session.add(sys_admin)
path = env.getenv('DOCKLET_LIB')
subprocess.call([path+"/userinit.sh", username])
db.session.commit()
if not os.path.exists(fspath+"/global/sys/quota"):
groupfile = open(fspath+"/global/sys/quota",'w')
groups = []
groups.append({'name':'root', 'quotas':{ 'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8' }})
groups.append({'name':'admin', 'quotas':{'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8'}})
groups.append({'name':'primary', 'quotas':{'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8'}})
groups.append({'name':'foundation', 'quotas':{'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8'}})
groupfile.write(json.dumps(groups))
groupfile.close()
if not os.path.exists(fspath+"/global/sys/quotainfo"):
quotafile = open(fspath+"/global/sys/quotainfo",'w')
quotas = {}
quotas['default'] = 'foundation'
quotas['quotainfo'] = []
quotas['quotainfo'].append({'name':'cpu', 'hint':'the cpu quota, number of cores, e.g. 4'})
quotas['quotainfo'].append({'name':'memory', 'hint':'the memory quota, number of MB , e.g. 4000'})
quotas['quotainfo'].append({'name':'disk', 'hint':'the disk quota, number of MB, e.g. 4000'})
quotas['quotainfo'].append({'name':'data', 'hint':'the quota of data space, number of GB, e.g. 100'})
quotas['quotainfo'].append({'name':'image', 'hint':'how many images the user can save, e.g. 10'})
quotas['quotainfo'].append({'name':'idletime', 'hint':'will stop cluster after idletime, number of hours, e.g. 24'})
quotas['quotainfo'].append({'name':'vnode', 'hint':'how many containers the user can have, e.g. 8'})
quotafile.write(json.dumps(quotas))
quotafile.close()
示例3: update_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import description [as 别名]
def update_user(self, user):
u = self.session.query(User).filter(User.username == user.username).\
filter(User.valid_until == ModelUtility.NullTimeStamp).first()
u_version = User(username=u.username, valid_until=datetime.now())
u_version.description = u.description
u_version.assigned_role = u.assigned_role
u_version.birthdate = u.birthdate
self.session.add(u_version)
u.assigned_role_name = user.assigned_rolename
u.birthdate = user.birthdate
u.description = user.description
self.session.add(u)
self.session.commit()
示例4: __init__
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import description [as 别名]
def __init__(self, username = 'root', password = None):
'''
Try to create the database when there is none
initialize 'root' user and 'root' & 'primary' group
'''
try:
User.query.all()
UserGroup.query.all()
except:
db.create_all()
root = UserGroup('root')
db.session.add(root)
db.session.commit()
if password == None:
#set a random password
password = os.urandom(16)
password = b64encode(password).decode('utf-8')
fsdir = env.getenv('FS_PREFIX')
f = open(fsdir + '/local/generated_password.txt', 'w')
f.write("User=%s\nPass=%s\n"%(username, password))
f.close()
sys_admin = User(username, hashlib.sha512(password.encode('utf-8')).hexdigest())
sys_admin.status = 'normal'
sys_admin.nickname = 'root'
sys_admin.description = 'Root_User'
sys_admin.user_group = 'root'
sys_admin.auth_method = 'local'
db.session.add(sys_admin)
path = env.getenv('DOCKLET_LIB')
subprocess.call([path+"/userinit.sh", username])
db.session.commit()
admin = UserGroup('admin')
primary = UserGroup('primary')
db.session.add(admin)
db.session.add(primary)
db.session.commit()