From 872f72d2b82a44f8464757cbfae33518439149e7 Mon Sep 17 00:00:00 2001 From: Oscar Romero Date: Tue, 12 Aug 2014 12:41:42 -0500 Subject: [PATCH] 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 --- jeepyb/cmd/close_pull_requests.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 @@ def main(): # 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")