[sysadmin-bin] Minor improvements: list the username who added a key via account.gnome.org, also clean up users fro



commit be629009bee27e26aaa587dd8e091912185eaec9
Author: Andrea Veri <averi redhat com>
Date:   Thu Sep 10 16:20:41 2020 +0200

    Minor improvements: list the username who added a key via account.gnome.org, also clean up users from 
Teams/Translation, do not error out when a project repo is 404

 gitlab/gitlab-operations.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/gitlab/gitlab-operations.py b/gitlab/gitlab-operations.py
index 5107617..b65a929 100755
--- a/gitlab/gitlab-operations.py
+++ b/gitlab/gitlab-operations.py
@@ -50,7 +50,7 @@ for username, id in ldapusers_dict.iteritems():
         try:
             user.keys.create({'title': 'Imported from account.gnome.org', 'key': ssh_key})
 
-            print 'Key for username with id %i has been added' % id
+            print 'Key for username %i with id %i has been added' % (user, id)
         except gitlab.exceptions.GitlabCreateError as e:
             if e.response_code == 400:
                 pass
@@ -74,7 +74,7 @@ for username, id in ldapusers_dict.iteritems():
                 l10n_group.members.create({'user_id': id,
                                            'access_level': gitlab.REPORTER_ACCESS})
 
-                print 'Username %s with id %i has been added to the Teams/Translations group' % (username, 
id)
+                print 'Username %s with id %i has been added to the Teams/Translation group' % (username, id)
         except gitlab.exceptions.GitlabCreateError as e:
             if e.response_code == 409:
                 pass
@@ -86,9 +86,11 @@ for username, id in gnomeusers_dict.iteritems():
             pass
         else:
             group.members.delete(id)
-
             print 'Username with id %i has been removed from the GNOME group' % id
 
+            l10n_group.members.delete(id)
+            print 'Username with id %i has been removed from the Teams/Translation group' % id
+
 maints = dict()
 for project in projects:
     project_name = project.attributes['path']
@@ -146,7 +148,12 @@ for project in projects:
         maints[project_name] = uids
 
 for project in maints:
-    proj = gl.projects.get('GNOME/%s' % project)
+    try:
+        proj = gl.projects.get('GNOME/%s' % project)
+    except gitlab.exceptions.GitlabGetError as e:
+        if e.response_code == 404:
+            continue
+
     for user in maints[project]:
         if user in gnomeusers_dict:
             userid = gnomeusers_dict[user]


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