Ejemplo n.º 1
0
    def __autorefresh_studies(self, cfg):
        """Execute autorefresh for areas of code study if configured"""

        if 'studies' not in self.conf[self.backend_section] or \
                'enrich_areas_of_code:git' not in self.conf[self.backend_section]['studies']:
            logger.debug("Not doing autorefresh for studies, Areas of Code study is not active.")
            return

        aoc_index = self.conf['enrich_areas_of_code:git'].get('out_index', GitEnrich.GIT_AOC_ENRICHED)

        # if `out_index` exists but has no value, use default
        if not aoc_index:
            aoc_index = GitEnrich.GIT_AOC_ENRICHED

        logger.debug("Autorefresh for Areas of Code study index: %s", aoc_index)

        es = Elasticsearch([self.conf['es_enrichment']['url']], timeout=100,
                           verify_certs=self._get_enrich_backend().elastic.requests.verify)

        if not es.indices.exists(index=aoc_index):
            logger.debug("Not doing autorefresh, index doesn't exist for Areas of Code study")
            return

        logger.debug("Doing autorefresh for Areas of Code study")

        # Create a GitEnrich backend tweaked to work with AOC index
        aoc_backend = GitEnrich(self.db_sh, None, cfg['projects']['projects_file'],
                                self.db_user, self.db_password, self.db_host)
        aoc_backend.mapping = None
        aoc_backend.roles = ['author']
        elastic_enrich = get_elastic(self.conf['es_enrichment']['url'],
                                     aoc_index, clean=False, backend=aoc_backend)
        aoc_backend.set_elastic(elastic_enrich)

        self.__autorefresh(aoc_backend, studies=True)
Ejemplo n.º 2
0
def enrich_git_items(es, index_git_raw, commits_sha_list, project, db_config):
    commits = _get_git_commits(es, index_git_raw, commits_sha_list)
    projects_file_path = _create_projects_file(project, "git", commits)
    logger.info("Total git track items to be enriched: %i", len(commits))

    enriched_items = []
    enricher = GitEnrich(db_sortinghat=db_config['database'],
                         db_user=db_config['user'],
                         db_password=db_config['password'],
                         db_host=db_config['host'],
                         json_projects_map=projects_file_path)

    # First load identities
    load_identities(commits, enricher)

    # Then enrich
    for commit in commits:
        enriched_items.append(enricher.get_rich_item(commit))

    os.unlink(projects_file_path)

    return enriched_items
Ejemplo n.º 3
0
def parse_sh_section(parser, sh_section, general_section):

    sh_user = parser.get(sh_section, 'db_user')
    sh_password = parser.get(sh_section, 'password')
    sh_name = parser.get(sh_section, 'db_name')
    sh_host = parser.get(sh_section, 'host')
    sh_port = parser.get(sh_section, 'port')

    projects_file_path = parser.get(general_section, 'projects')

    # TODO add port when parameter is available
    return GitEnrich(db_sortinghat=sh_name,
                     db_user=sh_user,
                     db_password=sh_password,
                     db_host=sh_host,
                     json_projects_map=projects_file_path)