def process(runtime_storage_inst, record_processor_inst): repos = utils.load_repos(runtime_storage_inst) current_date = utils.date_to_timestamp('now') bug_modified_since = runtime_storage_inst.get_by_key('bug_modified_since') rcs_inst = rcs.get_rcs(cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) for repo in repos: _process_repo(repo, runtime_storage_inst, record_processor_inst, rcs_inst, bug_modified_since) rcs_inst.close() runtime_storage_inst.set_by_key('bug_modified_since', current_date) LOG.info('Processing mail lists') mail_lists = runtime_storage_inst.get_by_key('mail_lists') or [] for mail_list in mail_lists: _process_mail_list(mail_list, runtime_storage_inst, record_processor_inst) _post_process_records(record_processor_inst, repos)
def _process_repo_reviews(repo, runtime_storage_inst, record_processor_inst): rcs_inst = rcs.get_rcs(repo['gerrit_uri']) rcs_inst.setup(key_filename=repo['key_filename'], username=repo['ssh_username'], gerrit_retry=CONF.gerrit_retry) for branch in _get_repo_branches(repo): LOG.info('Processing reviews for repo: %s, branch: %s', repo['uri'], branch) quoted_uri = six.moves.urllib.parse.quote_plus(repo['uri']) rcs_key = 'rcs:%s:%s' % (quoted_uri, branch) last_retrieval_time = runtime_storage_inst.get_by_key(rcs_key) current_retrieval_time = utils.date_to_timestamp('now') review_iterator = itertools.chain( rcs_inst.log(repo, branch, last_retrieval_time, status='open'), rcs_inst.log(repo, branch, last_retrieval_time, status='merged'), rcs_inst.log(repo, branch, last_retrieval_time, status='abandoned', grab_comments=True), ) review_iterator_typed = _record_typer(review_iterator, 'review') processed_review_iterator = record_processor_inst.process( review_iterator_typed) runtime_storage_inst.set_records(processed_review_iterator, utils.merge_records) runtime_storage_inst.set_by_key(rcs_key, current_retrieval_time) rcs_inst.close()
def process_repo(repo, runtime_storage_inst, record_processor_inst): uri = repo['uri'] LOG.debug('Processing repo uri %s' % uri) # OpenDaylight is not using launchpad at this time -- ignore # bp_iterator = lp.log(repo) # bp_iterator_typed = _record_typer(bp_iterator, 'bp') # processed_bp_iterator = record_processor_inst.process( # bp_iterator_typed) #runtime_storage_inst.set_records(processed_bp_iterator, # utils.merge_records) vcs_inst = vcs.get_vcs(repo, cfg.CONF.sources_root) vcs_inst.fetch() rcs_inst = rcs.get_rcs(repo, cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) branches = set(['master']) for release in repo.get('releases'): if 'branch' in release: branches.add(release['branch']) for branch in branches: LOG.debug('Processing repo %s, branch %s', uri, branch) vcs_key = 'vcs:' + str(urllib.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(vcs_key) commit_iterator = vcs_inst.log(branch, last_id) commit_iterator_typed = _record_typer(commit_iterator, 'commit') processed_commit_iterator = record_processor_inst.process( commit_iterator_typed) runtime_storage_inst.set_records( processed_commit_iterator, _merge_commits) last_id = vcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(vcs_key, last_id) LOG.debug('Processing reviews for repo %s, branch %s', uri, branch) rcs_key = 'rcs:' + str(urllib.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(rcs_key) review_iterator = rcs_inst.log(branch, last_id) review_iterator_typed = _record_typer(review_iterator, 'review') processed_review_iterator = record_processor_inst.process( review_iterator_typed) runtime_storage_inst.set_records(processed_review_iterator, utils.merge_records) last_id = rcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(rcs_key, last_id)
def process_repo(repo, runtime_storage_inst, record_processor_inst): uri = repo['uri'] LOG.debug('Processing repo uri %s' % uri) bp_iterator = lp.log(repo) bp_iterator_typed = _record_typer(bp_iterator, 'bp') processed_bp_iterator = record_processor_inst.process(bp_iterator_typed) runtime_storage_inst.set_records(processed_bp_iterator, utils.merge_records) vcs_inst = vcs.get_vcs(repo, cfg.CONF.sources_root) vcs_inst.fetch() rcs_inst = rcs.get_rcs(repo, cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) branches = set(['master']) for release in repo.get('releases'): if 'branch' in release: branches.add(release['branch']) for branch in branches: LOG.debug('Processing repo %s, branch %s', uri, branch) vcs_key = 'vcs:' + str(parse.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(vcs_key) commit_iterator = vcs_inst.log(branch, last_id) commit_iterator_typed = _record_typer(commit_iterator, 'commit') processed_commit_iterator = record_processor_inst.process( commit_iterator_typed) runtime_storage_inst.set_records(processed_commit_iterator, _merge_commits) last_id = vcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(vcs_key, last_id) LOG.debug('Processing reviews for repo %s, branch %s', uri, branch) rcs_key = 'rcs:' + str(parse.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(rcs_key) review_iterator = rcs_inst.log(branch, last_id) review_iterator_typed = _record_typer(review_iterator, 'review') processed_review_iterator = record_processor_inst.process( review_iterator_typed) runtime_storage_inst.set_records(processed_review_iterator, utils.merge_records) last_id = rcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(rcs_key, last_id)
def process(runtime_storage_inst, record_processor_inst): repos = utils.load_repos(runtime_storage_inst) rcs_inst = rcs.get_rcs(CONF.review_uri) # rcs_inst.setup(key_filename=CONF.ssh_key_filename, # username=CONF.ssh_username, # gerrit_retry=CONF.gerrit_retry) for repo in repos: _process_repo(repo, runtime_storage_inst, record_processor_inst, rcs_inst) rcs_inst.close() _post_process_records(record_processor_inst, repos)
def process(runtime_storage_inst, record_processor_inst): repos = utils.load_repos(runtime_storage_inst) rcs_inst = rcs.get_rcs(cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) for repo in repos: _process_repo(repo, runtime_storage_inst, record_processor_inst, rcs_inst) rcs_inst.close() LOG.info("Processing mail lists") mail_lists = runtime_storage_inst.get_by_key("mail_lists") or [] for mail_list in mail_lists: _process_mail_list(mail_list, runtime_storage_inst, record_processor_inst) _post_process_records(record_processor_inst, repos)
def process_repo(repo, runtime_storage_inst, record_processor_inst): uri = repo['uri'] LOG.debug('Processing repo uri %s' % uri) bp_iterator = lp.log(repo) bp_iterator_typed = _record_typer(bp_iterator, 'bp') processed_bp_iterator = record_processor_inst.process( bp_iterator_typed) runtime_storage_inst.set_records(processed_bp_iterator) vcs_inst = vcs.get_vcs(repo, cfg.CONF.sources_root) vcs_inst.fetch() rcs_inst = rcs.get_rcs(repo, cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) for branch in repo['branches']: LOG.debug('Processing repo %s, branch %s', uri, branch) vcs_key = 'vcs:' + str(urllib.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(vcs_key) commit_iterator = vcs_inst.log(branch, last_id) commit_iterator_typed = _record_typer(commit_iterator, 'commit') processed_commit_iterator = record_processor_inst.process( commit_iterator_typed) runtime_storage_inst.set_records( processed_commit_iterator, _merge_commits) last_id = vcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(vcs_key, last_id) LOG.debug('Processing reviews for repo %s, branch %s', uri, branch) rcs_key = 'rcs:' + str(urllib.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(rcs_key) review_iterator = rcs_inst.log(branch, last_id) review_iterator_typed = _record_typer(review_iterator, 'review') processed_review_iterator = record_processor_inst.process( review_iterator_typed) runtime_storage_inst.set_records(processed_review_iterator) last_id = rcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(rcs_key, last_id)
def main(): # init conf and logging conf = cfg.CONF conf.register_cli_opts(config.OPTS) conf.register_opts(config.OPTS) conf(project='stackalytics') logging.setup('stackalytics') LOG.info('Logging enabled') runtime_storage_inst = runtime_storage.get_runtime_storage( cfg.CONF.runtime_storage_uri) default_data = utils.read_json_from_uri(cfg.CONF.default_data_uri) if not default_data: LOG.critical('Unable to load default data') return not 0 gerrit = rcs.get_rcs(None, cfg.CONF.review_uri) gerrit.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) default_data_processor.process(runtime_storage_inst, default_data, cfg.CONF.git_base_uri, gerrit, cfg.CONF.driverlog_data_uri) process_program_list(runtime_storage_inst, cfg.CONF.program_list_uri) update_pids(runtime_storage_inst) record_processor_inst = record_processor.RecordProcessor( runtime_storage_inst) process(runtime_storage_inst, record_processor_inst) apply_corrections(cfg.CONF.corrections_uri, runtime_storage_inst) # long operation should be the last update_members(runtime_storage_inst, record_processor_inst) runtime_storage_inst.set_by_key('runtime_storage_update_time', utils.date_to_timestamp('now'))
def process(runtime_storage_inst, record_processor_inst): repos = utils.load_repos(runtime_storage_inst) rcs_inst = rcs.get_rcs(cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) for repo in repos: _process_repo(repo, runtime_storage_inst, record_processor_inst, rcs_inst) rcs_inst.close() LOG.info('Processing mail lists') mail_lists = runtime_storage_inst.get_by_key('mail_lists') or [] for mail_list in mail_lists: _process_mail_list(mail_list, runtime_storage_inst, record_processor_inst) _post_process_records(record_processor_inst, repos)
def process_repo(repo, runtime_storage, record_processor_inst): uri = repo['uri'] LOG.debug('Processing repo uri %s' % uri) vcs_inst = vcs.get_vcs(repo, cfg.CONF.sources_root) vcs_inst.fetch() rcs_inst = rcs.get_rcs(repo, cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) for branch in repo['branches']: LOG.debug('Processing repo %s, branch %s', uri, branch) vcs_key = 'vcs:' + str(urllib.quote_plus(uri) + ':' + branch) last_id = runtime_storage.get_by_key(vcs_key) commit_iterator = vcs_inst.log(branch, last_id) commit_iterator_typed = _record_typer(commit_iterator, 'commit') processed_commit_iterator = record_processor_inst.process( commit_iterator_typed) runtime_storage.set_records(processed_commit_iterator, _merge_commits) last_id = vcs_inst.get_last_id(branch) runtime_storage.set_by_key(vcs_key, last_id) LOG.debug('Processing reviews for repo %s, branch %s', uri, branch) rcs_key = 'rcs:' + str(urllib.quote_plus(uri) + ':' + branch) last_id = runtime_storage.get_by_key(rcs_key) review_iterator = rcs_inst.log(branch, last_id) review_iterator_typed = _record_typer(review_iterator, 'review') processed_review_iterator = record_processor_inst.process( review_iterator_typed) runtime_storage.set_records(processed_review_iterator) last_id = rcs_inst.get_last_id(branch) runtime_storage.set_by_key(rcs_key, last_id)
def process(runtime_storage_inst, record_processor_inst): repos = utils.load_repos(runtime_storage_inst) rcs_inst = rcs.get_rcs(cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) for repo in repos: _process_repo(repo, runtime_storage_inst, record_processor_inst, rcs_inst) rcs_inst.close() LOG.info('Processing mail lists') mail_lists = runtime_storage_inst.get_by_key('mail_lists') or [] for mail_list in mail_lists: _process_mail_list(mail_list, runtime_storage_inst, record_processor_inst) #TODO(adiantum): replace stub with tranlslation acquisition logic _process_translation(runtime_storage_inst, record_processor_inst) _post_process_records(record_processor_inst, repos)
def process(runtime_storage_inst, record_processor_inst): repos = utils.load_repos(runtime_storage_inst) rcs_inst = rcs.get_rcs(CONF.review_uri) rcs_inst.setup(key_filename=CONF.ssh_key_filename, username=CONF.ssh_username, gerrit_retry=CONF.gerrit_retry) for repo in repos: _process_repo(repo, runtime_storage_inst, record_processor_inst, rcs_inst) rcs_inst.close() LOG.info('Processing mail lists') mail_lists = runtime_storage_inst.get_by_key('mail_lists') or [] for mail_list in mail_lists: _process_mail_list(mail_list, runtime_storage_inst, record_processor_inst) LOG.info('Processing translations stats') _process_translation_stats(runtime_storage_inst, record_processor_inst) _post_process_records(record_processor_inst, repos)
def _process_repo(repo, runtime_storage_inst, record_processor_inst, bug_modified_since): uri = repo['uri'] LOG.info('Processing repo uri: %s', uri) LOG.debug('Processing blueprints for repo uri: %s', uri) bp_iterator = lp.log(repo) bp_iterator_typed = _record_typer(bp_iterator, 'bp') processed_bp_iterator = record_processor_inst.process( bp_iterator_typed) runtime_storage_inst.set_records(processed_bp_iterator, utils.merge_records) LOG.debug('Processing bugs for repo uri: %s', uri) bug_iterator = bps.log(repo, bug_modified_since) bug_iterator_typed = _record_typer(bug_iterator, 'bug') processed_bug_iterator = record_processor_inst.process( bug_iterator_typed) runtime_storage_inst.set_records(processed_bug_iterator, utils.merge_records) vcs_inst = vcs.get_vcs(repo, cfg.CONF.sources_root) vcs_inst.fetch() rcs_inst = rcs.get_rcs(repo, cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) branches = set(['master']) for release in repo.get('releases'): if 'branch' in release: branches.add(release['branch']) for branch in branches: LOG.debug('Processing commits in repo: %s, branch: %s', uri, branch) vcs_key = 'vcs:' + str(parse.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(vcs_key) commit_iterator = vcs_inst.log(branch, last_id) commit_iterator_typed = _record_typer(commit_iterator, 'commit') processed_commit_iterator = record_processor_inst.process( commit_iterator_typed) runtime_storage_inst.set_records( processed_commit_iterator, _merge_commits) last_id = vcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(vcs_key, last_id) LOG.debug('Processing reviews for repo: %s, branch: %s', uri, branch) rcs_key = 'rcs:' + str(parse.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(rcs_key) review_iterator = rcs_inst.log(branch, last_id, grab_comments=('ci' in repo)) review_iterator_typed = _record_typer(review_iterator, 'review') if 'ci' in repo: # add external CI data review_iterator_typed = _process_reviews( review_iterator_typed, repo['ci'], repo['module'], branch) processed_review_iterator = record_processor_inst.process( review_iterator_typed) runtime_storage_inst.set_records(processed_review_iterator, utils.merge_records) last_id = rcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(rcs_key, last_id)
def _process_repo(repo, runtime_storage_inst, record_processor_inst, bug_modified_since): uri = repo['uri'] LOG.info('Processing repo uri: %s', uri) LOG.debug('Processing blueprints for repo uri: %s', uri) bp_iterator = lp.log(repo) bp_iterator_typed = _record_typer(bp_iterator, 'bp') processed_bp_iterator = record_processor_inst.process(bp_iterator_typed) runtime_storage_inst.set_records(processed_bp_iterator, utils.merge_records) LOG.debug('Processing bugs for repo uri: %s', uri) bug_iterator = bps.log(repo, bug_modified_since) bug_iterator_typed = _record_typer(bug_iterator, 'bug') processed_bug_iterator = record_processor_inst.process(bug_iterator_typed) runtime_storage_inst.set_records(processed_bug_iterator, utils.merge_records) vcs_inst = vcs.get_vcs(repo, cfg.CONF.sources_root) vcs_inst.fetch() rcs_inst = rcs.get_rcs(repo, cfg.CONF.review_uri) rcs_inst.setup(key_filename=cfg.CONF.ssh_key_filename, username=cfg.CONF.ssh_username) branches = set(['master']) for release in repo.get('releases'): if 'branch' in release: branches.add(release['branch']) for branch in branches: LOG.debug('Processing commits in repo: %s, branch: %s', uri, branch) vcs_key = 'vcs:' + str(parse.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(vcs_key) commit_iterator = vcs_inst.log(branch, last_id) commit_iterator_typed = _record_typer(commit_iterator, 'commit') processed_commit_iterator = record_processor_inst.process( commit_iterator_typed) runtime_storage_inst.set_records(processed_commit_iterator, _merge_commits) last_id = vcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(vcs_key, last_id) LOG.debug('Processing reviews for repo: %s, branch: %s', uri, branch) rcs_key = 'rcs:' + str(parse.quote_plus(uri) + ':' + branch) last_id = runtime_storage_inst.get_by_key(rcs_key) review_iterator = rcs_inst.log(branch, last_id, grab_comments=('ci' in repo)) review_iterator_typed = _record_typer(review_iterator, 'review') if 'ci' in repo: # add external CI data review_iterator_typed = _process_reviews(review_iterator_typed, repo['ci'], repo['module'], branch) processed_review_iterator = record_processor_inst.process( review_iterator_typed) runtime_storage_inst.set_records(processed_review_iterator, utils.merge_records) last_id = rcs_inst.get_last_id(branch) runtime_storage_inst.set_by_key(rcs_key, last_id)