scraper/tfs/__init__.py
def get_all_projects(url, token, top=HARD_CODED_TOP):
    """
    Returns a list of all projects with their collection info from the server. Currently limited functionality to only return the first 1000 projects.
    #TODO refactor to add multiple calls to api to retrieve all projects if more exist beyond top.
    """
    project_list = []
    tfs_client = create_tfs_core_client(url, token)

    collections = tfs_client.get_project_collections(top=top)

    for collection in collections:
        collection_client = create_tfs_core_client('{url}/{collection_name}'.format(url=url, collection_name=collection.name), token)

        logger.debug('Retrieving Projects for Project Collection: {collection_name}'.format(collection_name=collection.name))
        # Retrieves all projects in the project collection
        projects = collection_client.get_projects(top=HARD_CODED_TOP)
        # get_projects only gets the project references, have to call get_project_history_entries to get last update info for projects
        # Only calling this once per collection as its an expensive API call, wil refactor later if there is a better API call to use
        collection_history_list = collection_client.get_project_history_entries()
        for project in projects:

            # get_projects only gets team project ref objects,
            # have to call get_project to get the team project object which includes the TFS Web Url for the project
            logger.debug('Retrieving Team Project for Project: {project_name}'.format(project_name=project.name))
            projectInfo = collection_client.get_project(project.id, True, True)

            tfsProject = TFSProject(projectInfo, collection)

            logger.debug('Retrieving Last Updated and Created Info for Project: {project_name}'.format(project_name=project.name))
            tfsProject.projectLastUpdateInfo = get_project_last_update_time(collection_history_list, project.id)
            tfsProject.projectCreateInfo = get_project_create_time(collection_history_list, project.id)
            project_list.append(tfsProject)

    return project_list
def get_all_projects(url, token, top=HARD_CODED_TOP):
    """
    Returns a list of all projects with their collection info from the server. Currently limited functionality to only return the first 1000 projects.
    #TODO refactor to add multiple calls to api to retrieve all projects if more exist beyond top.
    """
    project_list = []
    tfs_client = create_tfs_core_client(url, token)

    collections = tfs_client.get_project_collections(top=top)

    for collection in collections:
        collection_client = create_tfs_core_client('{url}/{collection_name}'.format(url=url, collection_name=collection.name), token)

        logger.debug('Retrieving Projects for Project Collection: {collection_name}'.format(collection_name=collection.name))
        # Retrieves all projects in the project collection
        projects = collection_client.get_projects(top=HARD_CODED_TOP)
        # get_projects only gets the project references, have to call get_project_history_entries to get last update info for projects
        # Only calling this once per collection as its an expensive API call, wil refactor later if there is a better API call to use
        collection_history_list = collection_client.get_project_history_entries()
        for project in projects:

            # get_projects only gets team project ref objects,
            # have to call get_project to get the team project object which includes the TFS Web Url for the project
            logger.debug('Retrieving Team Project for Project: {project_name}'.format(project_name=project.name))
            projectInfo = collection_client.get_project(project.id, True, True)

            tfsProject = TFSProject(projectInfo, collection)

            logger.debug('Retrieving Last Updated and Created Info for Project: {project_name}'.format(project_name=project.name))
            tfsProject.projectLastUpdateInfo = get_project_last_update_time(collection_history_list, project.id)
            tfsProject.projectCreateInfo = get_project_create_time(collection_history_list, project.id)
            project_list.append(tfsProject)

    return project_list
Returns a list of all projects with their collection info from the server. Currently limited functionality to only return the first 1000 projects.
    #TODO refactor to add multiple calls to api to retrieve all projects if more exist beyond top.