[sysadmin-bin] Catch GitlabListError and skip if response is 404 for empty projects



commit d4a17827a56b55d460937acc4cff44e22d269843
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Mon Sep 30 16:27:32 2019 +0200

    Catch GitlabListError and skip if response is 404 for empty projects

 gitlab/gitlab-operations.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gitlab/gitlab-operations.py b/gitlab/gitlab-operations.py
index 0c4715e..093befc 100755
--- a/gitlab/gitlab-operations.py
+++ b/gitlab/gitlab-operations.py
@@ -109,8 +109,9 @@ for project in projects:
         for branch_name in (stable_branches - protected_branches):
             branch = proj.branches.get(branch_name, lazy=True)
             branch.protect(developers_can_push=True, developers_can_merge=True)
-    except:
-        print 'Skip setting protected branches for %s due to API error' % project_name
+        except gitlab.exceptions.GitlabListError as e:
+            if e.response_code == 404:
+                pass
 
     try:
         nodes = semi_rdf.read_rdf(doap_url % (project_name, default_branch, project_name))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]