当前位置: 首页>>代码示例>>Python>>正文


Python User.description方法代码示例

本文整理汇总了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)
开发者ID:panisson,项目名称:whatshot,代码行数:60,代码来源:app.py

示例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()
开发者ID:DreamReaver,项目名称:docklet,代码行数:52,代码来源:userManager.py

示例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()
开发者ID:ww-lessons,项目名称:datenhistorisierung,代码行数:18,代码来源:UserRepository.py

示例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()
开发者ID:Puppy95,项目名称:docklet,代码行数:38,代码来源:userManager.py


注:本文中的model.User.description方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。