[sysadmin-bin] Simplify the members list
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Simplify the members list
- Date: Fri, 12 Mar 2021 11:11:40 +0000 (UTC)
commit ddabec089c5c19a52284ee874fe4b6b97ab13d33
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date: Fri Mar 12 12:11:13 2021 +0100
Simplify the members list
membership/foundation-operations.py | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/membership/foundation-operations.py b/membership/foundation-operations.py
index 44c0e77..799fcb5 100755
--- a/membership/foundation-operations.py
+++ b/membership/foundation-operations.py
@@ -109,32 +109,27 @@ def remove_expired_memberships_from_foundation():
def generate_membership_list():
import json
- foundationmembers = glu.get_uids_from_group('foundation')
- emeritus = glu.get_uids_from_group('emeritus')
+ foundationmembers = glu.get_uids_from_group("foundation")
+ emeritus = glu.get_uids_from_group("emeritus")
- result = { 'members': [], 'emeritus': [] }
+ result = {"members": [], "emeritus": []}
for member in foundationmembers:
- ldap_fields = glu.get_attributes_from_ldap(member, 'cn', 'LastRenewedOn')
- common_name_attr = ldap_fields[1].decode('utf-8')
- last_renewed_on_attr = ldap_fields[2].decode('utf-8')
+ ldap_fields = glu.get_attributes_from_ldap(member, "cn", "LastRenewedOn")
+ common_name_attr = ldap_fields[1].decode("utf-8")
- result['members'].append({ 'common_name' : common_name_attr, 'last_renewed_on' :
last_renewed_on_attr })
+ result["members"].append(common_name_attr)
+ result["members"].sort(key=str.casefold)
for member in emeritus:
- ldap_fields = glu.get_attributes_from_ldap(member, 'cn', 'LastRenewedOn')
- common_name_attr = ldap_fields[1].decode('utf-8')
- last_renewed_on_attr = ldap_fields[2].decode('utf-8')
-
- result['emeritus'].append({ 'common_name' : common_name_attr, 'last_renewed_on' :
last_renewed_on_attr })
+ ldap_fields = glu.get_attributes_from_ldap(member, "cn", "LastRenewedOn")
+ common_name_attr = ldap_fields[1].decode("utf-8")
- memberslist = json.dumps(result, ensure_ascii=False)
+ result["emeritus"].append(common_name_attr)
+ result["emeritus"].sort(key=str.casefold)
- if len(memberslist) > 0:
- import codecs
- membershipfile = codecs.open('/srv/http/www.gnome.org/html/membership/memberslist', 'w', 'utf8')
- membershipfile.write(memberslist)
- membershipfile.close()
+ with open("memberslist.json") as f:
+ json.dump(result, f)
def send_form_letters(form_letter, email, name, *args):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]