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


Python TASClient.projects_for_group方法代码示例

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


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

示例1: user_projects

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_group [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: view

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_group [as 别名]
def view( request ):
    resp = ''
    try:
        tas = TASClient()
        resp = tas.projects_for_group('Chameleon')
        logger.debug( 'Total projects: %s', len(resp) )
    except Exception as e:
        logger.exception('Error loading chameleon projects')
        messages.error( request, e[0] )
        raise Exception('Error loading chameleon projects')
    return HttpResponse(json.dumps(resp), content_type="application/json")
开发者ID:,项目名称:,代码行数:13,代码来源:

示例3: view

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_group [as 别名]
def view( request ):
    #resp = ''
    try:
        tas = TASClient()
        resp = tas.projects_for_group('Chameleon')
        for p in resp:
            tempAlloc = []
            for a in p['allocations']:
                if a['resource'] == 'Chameleon':
                    tempAlloc.append(a)
            p['allocations'] = tempAlloc

        logger.debug( 'Total projects: %s', len(resp) )
    except Exception as e:
        logger.exception('Error loading chameleon projects')
        messages.error( request, e[0] )
        raise Exception('Error loading chameleon projects')
    return HttpResponse(json.dumps(resp), content_type="application/json")
开发者ID:ChameleonCloud,项目名称:portal,代码行数:20,代码来源:views.py

示例4: get_projects_json

# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import projects_for_group [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


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