[sysadmin-bin] Use common_name_attr on the expired_membership function. Also make foundationmembers a global variab
- From: Andrea Veri <av src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Use common_name_attr on the expired_membership function. Also make foundationmembers a global variab
- Date: Tue, 18 Nov 2014 17:00:51 +0000 (UTC)
commit 5f870fb06b09a7d3fde6b409ac1aad73e3e30db5
Author: Andrea Veri <av gnome org>
Date: Tue Nov 18 17:59:28 2014 +0100
Use common_name_attr on the expired_membership function. Also make foundationmembers a global variable.
Hint for the future would be making a global dict storing the member name and all the relevant
LDAP values.
membership/foundation-operations.py | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/membership/foundation-operations.py b/membership/foundation-operations.py
index 7a68cf3..6e0d97b 100755
--- a/membership/foundation-operations.py
+++ b/membership/foundation-operations.py
@@ -79,6 +79,9 @@ def _get_foundation_members():
return foundationmembers
+foundationmembers = _get_foundation_members()
+
+
def _get_attributes_from_ldap(uid, attr):
filter = ldap.filter.filter_format('(uid=%s)', (uid, ))
results = l.search_s(LDAP_USER_BASE, ldap.SCOPE_SUBTREE, filter, ('uid', attr, ))
@@ -90,8 +93,6 @@ def _get_attributes_from_ldap(uid, attr):
def _get_foundation_fields_from_ldap():
- foundationmembers = _get_foundation_members()
-
for member in foundationmembers:
first_added_attr = _get_attributes_from_ldap(member, 'FirstAdded')
last_renewed_on_attr = _get_attributes_from_ldap(member, 'LastRenewedOn')
@@ -117,7 +118,6 @@ def remove_user_from_foundation_member(member):
def _sync_foundation_with_mailusers():
- foundationmembers = _get_foundation_members()
mailusers = _parse_members_from_group('mailusers')
for member in foundationmembers:
@@ -126,23 +126,22 @@ def _sync_foundation_with_mailusers():
def remove_expired_memberships_from_foundation():
- foundationmembers = _get_foundation_members()
now = time()
for member in foundationmembers:
last_renewed_on_attr = _get_attributes_from_ldap(member, 'LastRenewedOn')
convert_to_unix_time = calendar.timegm(strptime(last_renewed_on_attr, '%Y-%m-%d'))
mail_attr = _get_attributes_from_ldap(member,'mail')
+ common_name_attr = _get_attributes_from_ldap(member, 'cn')
if member in foundationmembers and convert_to_unix_time < now - 365 * 2 * 24 * 60 * 60:
print "Removing %s from the foundation LDAP group as the membership expired on %s" % (member,
last_renewed_on_attr)
remove_user_from_foundation_member(member)
- send_form_letters(expired_membership_form_letter, mail_attr, member)
+ send_form_letters(expired_membership_form_letter, mail_attr, common_name_attr)
def generate_membership_list():
import json
- foundationmembers = _get_foundation_members()
membershiplist = []
membershipdict = {}
@@ -187,8 +186,6 @@ def subscribe_new_members():
if socket.gethostname() != 'restaurant.gnome.org':
sys.exit("This function should only be used on restaurant.gnome.org")
- foundationmembers = _get_foundation_members()
-
f = open('/tmp/new_subscribers', 'w')
for member in foundationmembers:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]