github_archive_7.py 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. def iterate_repos_to_archive(self, repos: List[Repository.Repository], operation: str) -> List[Optional[str]]:
  2. """Iterate over each repository and start a thread if it can be archived.
  3. We ignore repos not in the include or in the exclude list if either are present.
  4. """
  5. logger = woodchips.get(LOGGER_NAME)
  6. pool = ThreadPoolExecutor(self.threads)
  7. thread_list = []
  8. for repo in repos:
  9. if (
  10. (not self.include and not self.exclude)
  11. or (self.include and repo.name in self.include)
  12. or (self.exclude and repo.name not in self.exclude)
  13. ):
  14. repo_owner_username = repo.owner.login.lower()
  15. repo_path = os.path.join(self.location, 'repos', repo_owner_username, repo.name)
  16. thread_list.append(
  17. pool.submit(
  18. self.archive_repo,
  19. repo=repo,
  20. repo_path=repo_path,
  21. operation=operation,
  22. )
  23. )
  24. else:
  25. logger.debug(f'{repo.name} skipped due to include/exclude filtering')
  26. wait(thread_list, return_when=ALL_COMPLETED)
  27. failed_repos = [repo.result() for repo in thread_list if repo.result()]
  28. return failed_repos