Fix close_pull_requests from jeepyb
Adding a 'try' to handle errors when the repo or organization is
not found in github.
Change-Id: Ib86f848cfa0babd9091cc9610ae973b0d00758b6
diff --git a/jeepyb/cmd/close_pull_requests.py b/jeepyb/cmd/close_pull_requests.py
index 232291e..ce07501 100644
--- a/jeepyb/cmd/close_pull_requests.py
+++ b/jeepyb/cmd/close_pull_requests.py
@@ -84,11 +84,18 @@
# Find the project's repo
project_split = project.split('/', 1)
- if len(project_split) > 1:
- org = orgs_dict[project_split[0].lower()]
- repo = org.get_repo(project_split[1])
- else:
- repo = ghub.get_user().get_repo(project)
+
+ # Handle errors in case the repo or the organization doesn't exists
+ try:
+ if len(project_split) > 1:
+ org = orgs_dict[project_split[0].lower()]
+ repo = org.get_repo(project_split[1])
+ else:
+ repo = ghub.get_user().get_repo(project)
+ except KeyError:
+ continue
+ except github.GithubException:
+ continue
# Close each pull request
pull_requests = repo.get_pulls("open")