community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1858397 - /comdev/reporter.apache.org/trunk/site/addrelease.py
Date Mon, 29 Apr 2019 20:24:31 GMT
Author: sebb
Date: Mon Apr 29 20:24:31 2019
New Revision: 1858397

URL: http://svn.apache.org/viewvc?rev=1858397&view=rev
Log:
Use new ldap_info module

Modified:
    comdev/reporter.apache.org/trunk/site/addrelease.py

Modified: comdev/reporter.apache.org/trunk/site/addrelease.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/addrelease.py?rev=1858397&r1=1858396&r2=1858397&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/addrelease.py (original)
+++ comdev/reporter.apache.org/trunk/site/addrelease.py Mon Apr 29 20:24:31 2019
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
-import os, re, json, subprocess
+import os, sys, json
 import cgi
 
+sys.path.append("../scripts") # module is in sibling directory
+import ldap_info
+
+print("done")
+
 form = cgi.FieldStorage()
 user = os.environ['HTTP_X_AUTHENTICATED_USER'] if 'HTTP_X_AUTHENTICATED_USER' in os.environ
else "nobody"
 date = int(form['date'].value) if ('date' in form and len(form['date'].value) > 0) else
None
@@ -9,28 +14,6 @@ version = form['version'].value.strip()
 committee = form['committee'].value if 'committee' in form else None
 dojson = form['json'].value if 'json' in form else None
     
-def getPMCs(uid):
-    groups = []
-    ldapdata = subprocess.check_output(['ldapsearch', '-x', '-LLL',
-        '-b', 'ou=project,ou=groups,dc=apache,dc=org',
-        'member=uid=%s,ou=people,dc=apache,dc=org' % uid, 'dn'])
-    for match in re.finditer(r"dn: cn=([a-zA-Z0-9]+),ou=project,ou=groups,dc=apache,dc=org",
ldapdata):
-        group = match.group(1)
-        if group != "incubator":
-            groups.append(group)
-    return groups
-
-
-def isMember(uid):
-    members = []
-    ldapdata = subprocess.check_output(['ldapsearch', '-x', '-LLL', '-b', 'cn=member,ou=groups,dc=apache,dc=org'])
-    for match in re.finditer(r"memberUid: ([-a-z0-9_.]+)", ldapdata):
-        group = match.group(1)
-        members.append(group)
-    if uid in members:
-        return True
-    return False
-
 def getReleaseData(committee):
     try:
         with open("/var/www/reporter.apache.org/data/releases/%s.json" % committee, "r")
as f:
@@ -43,7 +26,7 @@ def getReleaseData(committee):
 saved = False
 err = None
 if date != None and version and committee:
-    if committee in getPMCs(user) or isMember(user):
+    if committee in ldap_info.getPMCownership(user) or ldap_info.isMember(user):
         rdata = getReleaseData(committee)
         if date >= 86400: # allow for local time just in case
             rdata[version] = date



Mime
View raw message