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


Python TASClient.projects_for_user方法代码示例

本文整理汇总了Python中pytas.http.TASClient.projects_for_user方法的典型用法代码示例。如果您正苦于以下问题:Python TASClient.projects_for_user方法的具体用法?Python TASClient.projects_for_user怎么用?Python TASClient.projects_for_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytas.http.TASClient的用法示例。


在下文中一共展示了TASClient.projects_for_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: user_projects

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_user [as 别名]
def user_projects( request, username ):
    logger.info( 'User projects requested by admin: %s for user %s', request.user, username )
    resp = {
        'status': 'error',
        'msg': '',
        'result': []
    }
    if username:
        tas = TASClient()
        try:
            userData = tas.get_user(username=username)
            try:
                userProjects = tas.projects_for_user( username=username )
                chameleonProjects = tas.projects_for_group('Chameleon');
                if (chameleonProjects and userProjects):
                    for project in userProjects:
                        if project in chameleonProjects:
                            resp['status'] = 'success'
                            resp['result'].append(project)
                            logger.info( 'Total chameleon projects for user %s: %s', username, len( resp ) )
            except Exception as e:
                logger.debug('Error loading projects for user: %s', username)
                resp['msg'] = 'Error loading projects for user: %s' %username
        except Exception as e:
            logger.debug('User not found with username: %s', username)
            resp['msg'] = 'User not found.'
    return HttpResponse(json.dumps(resp), content_type="application/json")
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: get_projects_json

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_user [as 别名]
def get_projects_json( request, username=None ):
    logger.info( 'Projects requested.')
    resp = []
    try:
        tas = TASClient()
        chameleonProjects = tas.projects_for_group('Chameleon')
        if username is not None:
            userProjects = tas.projects_for_user( username=username )
            if (chameleonProjects and userProjects):
                for project in userProjects:
                    if project in chameleonProjects:
                        resp.append(project)
                        logger.info( 'Total chameleon projects for user %s: %s', username, len( resp ) )
        else:
            logger.info( 'Total chameleon projects: %s', username, len( chameleonProjects ) )
            resp = chameleonProjects

    except Exception as e:
        traceback.print_exc()
        raise Exception('Error loading projects.')
    return HttpResponse(json.dumps(resp), content_type="application/json")
开发者ID:ChameleonCloud,项目名称:portal,代码行数:23,代码来源:views.py

示例3: user_projects

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_user [as 别名]
def user_projects( request, username ):
    logger.info( 'User projects requested by admin: %s for user %s', request.user, username )
    resp = {
        'status': 'error',
        'msg': '',
        'result': []
    }
    if username:
        tas = TASClient()
        try:
            userData = tas.get_user(username=username)
            try:
                userProjects = tas.projects_for_user( username=username )
                #logger.debug(userProjects)

                temp = {}
                # run through and make sure all the allocations are associated with one project
                for p in userProjects:
                     if p['source'] == 'Chameleon':
                        if p['chargeCode'] not in temp:
                            logger.debug('Project ' + p['chargeCode'] + ' is not in the temp yet, adding')
                            temp[p['chargeCode']] = p
                        else:
                            logger.debug('Project ' + p['chargeCode'] + ' is in temp...appending allocations')
                            tempProj = temp[p['chargeCode']]
                            for a in p['allocations']:
                                if a['resource'] == 'Chameleon':
                                    tempProj['allocations'].extend(a)
                            temp[p['chargeCode']] = tempProj
                for code, proj in temp.items():
                    resp['status'] = 'success'
                    resp['result'].append(proj)
                logger.info('Total chameleon projects for user %s: %s', username, len(resp))
            except Exception as e:
                logger.debug('Error loading projects for user: %s with error %s', username, e)
                resp['msg'] = 'Error loading projects for user: %s' %username
        except Exception as e:
            logger.debug('User not found with username: %s', username)
            resp['msg'] = 'User not found.'
    return HttpResponse(json.dumps(resp), content_type="application/json")
开发者ID:ChameleonCloud,项目名称:portal,代码行数:42,代码来源:views.py

示例4: get_user_info

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_user [as 别名]
def get_user_info(request, username):
    #username = request.GET.get('username')

    resp = {}
    resp['result'] = None
    resp['status'] = 'error'

    if username is None:
        resp['message'] = 'Username is required'

    try:
        tas = TASClient()
        resp['status'] = 'success'
        users = tas.get_user(username=username)
        projects = tas.projects_for_user(username)

        resp['result'] = users
        resp['result']['projects'] = projects

    except Exception as e:
        traceback.print_exc()
        raise Exception('Error fetching user.')
    return HttpResponse(json.dumps(resp), content_type="application/json")
开发者ID:ChameleonCloud,项目名称:portal,代码行数:25,代码来源:views.py


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