[sysadmin-bin] Do not fail in case gnome_pushlog is not there yet (i.e for new projects)



commit 954e815ba0461bb150666fe4e1764a59654aab48
Author: Andrea Veri <averi redhat com>
Date:   Tue Sep 4 09:34:23 2018 +0200

    Do not fail in case gnome_pushlog is not there yet (i.e for new projects)

 cleanup-inactive-ldap-accounts.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/cleanup-inactive-ldap-accounts.py b/cleanup-inactive-ldap-accounts.py
index b970386..9c4d74a 100755
--- a/cleanup-inactive-ldap-accounts.py
+++ b/cleanup-inactive-ldap-accounts.py
@@ -37,13 +37,17 @@ last_pushed_times = {}
 
 
 for repository in repositories:
-    pushlog = open('%s/%s/gnome_pushlog' % (GL_PATH, repository), 'r')
-    for line in pushlog.readlines():
-        fields = line.rstrip().split('\t')
-        username = fields[3]
-        pushtime = calendar.timegm(time.strptime(fields[4], '%a, %d %b %Y %H:%M:%S +0000'))
-        if not username in last_pushed_times or pushtime > last_pushed_times[username]:
-            last_pushed_times[username] = pushtime
+    try:
+        pushlog = open('%s/%s/gnome_pushlog' % (GL_PATH, repository), 'r')
+        for line in pushlog.readlines():
+            fields = line.rstrip().split('\t')
+            username = fields[3]
+            pushtime = calendar.timegm(time.strptime(fields[4], '%a, %d %b %Y %H:%M:%S +0000'))
+            if not username in last_pushed_times or pushtime > last_pushed_times[username]:
+                last_pushed_times[username] = pushtime
+    except IOError as e:
+        if e.errno == 2:
+            pass
 
 now = time.time()
 


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