Return-Path: X-Original-To: apmail-community-commits-archive@minotaur.apache.org Delivered-To: apmail-community-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7FAF417391 for ; Thu, 1 Oct 2015 12:33:47 +0000 (UTC) Received: (qmail 47088 invoked by uid 500); 1 Oct 2015 12:33:47 -0000 Delivered-To: apmail-community-commits-archive@community.apache.org Received: (qmail 47062 invoked by uid 500); 1 Oct 2015 12:33:47 -0000 Mailing-List: contact commits-help@community.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@community.apache.org Delivered-To: mailing list commits@community.apache.org Received: (qmail 47053 invoked by uid 99); 1 Oct 2015 12:33:47 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2015 12:33:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F3B4A1A34E6 for ; Thu, 1 Oct 2015 12:33:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.002 X-Spam-Level: * X-Spam-Status: No, score=1.002 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id a5cMi0H-G0wB for ; Thu, 1 Oct 2015 12:33:45 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 99CA020513 for ; Thu, 1 Oct 2015 12:33:45 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 46CB6E0231 for ; Thu, 1 Oct 2015 12:33:45 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 4457A3A027A for ; Thu, 1 Oct 2015 12:33:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1706224 - /comdev/reporter.apache.org/trunk/site/getjson.py Date: Thu, 01 Oct 2015 12:33:45 -0000 To: commits@community.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151001123345.4457A3A027A@svn01-us-west.apache.org> Author: sebb Date: Thu Oct 1 12:33:44 2015 New Revision: 1706224 URL: http://svn.apache.org/viewvc?rev=1706224&view=rev Log: Docs Modified: comdev/reporter.apache.org/trunk/site/getjson.py Modified: comdev/reporter.apache.org/trunk/site/getjson.py URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/getjson.py?rev=1706224&r1=1706223&r2=1706224&view=diff ============================================================================== --- comdev/reporter.apache.org/trunk/site/getjson.py (original) +++ comdev/reporter.apache.org/trunk/site/getjson.py Thu Oct 1 12:33:44 2015 @@ -1,4 +1,32 @@ #!/usr/bin/env python +""" + CGI script to return data to the Javacript that renders the site (render.js) + + It also populates various json files from JIRA if they are stale: + data/JIRA/projects.json - list of all JIRA projects + data/JIRA/%.json - for each JIRA project + + Usage: + getjson.py[?only=pmcname] + + Reads the following: + projects.apache.org/site/json/foundation/pmcs.json + projects.apache.org/site/json/foundation/chairs.json + projects.apache.org/site/json/projects/%s.json + data/JIRA/projects.json + data/JIRA/%s.json + data/health.json + data/releases/%s.json + data/pmcs.json + data/projects.json + data/mailinglists.json + data/maildata_extended.json + + + Environment variables: + +""" + import os, sys, re, json, subprocess, time import base64, urllib2, cgi @@ -32,19 +60,22 @@ with open("/var/www/reporter.apache.org/ jirapass = f.read().strip() f.close() + def getPMCs(uid): + """ Reads LDAP and returns the array of committee groups to which the uid belongs + Excludes incubator""" groups = [] ldapdata = subprocess.check_output(['ldapsearch', '-x', '-LLL', '(|(memberUid=%s)(member=uid=%s,ou=people,dc=apache,dc=org))' % (uid, uid), 'cn']) picked = {} for match in re.finditer(r"dn: cn=([-a-zA-Z0-9]+),ou=pmc,ou=committees,ou=groups,dc=apache,dc=org", ldapdata): group = match.group(1) if group != "incubator": - groups.append(group) return groups def isMember(uid): + """Reads LDAP to determine if the uid is a member of the ASF""" 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): @@ -55,6 +86,10 @@ def isMember(uid): return False def getJIRAProjects(project): + """Reads data/JIRA/projects.json (updating it if it is stale) + Returns the list of JIRA projects for the project argument + Assumes that the project names match or the project category matches + (after trimming "Apache " and spaces and lower-casing)""" project = project.replace("Apache ", "").strip().lower() refresh = True x = {} @@ -94,6 +129,10 @@ def getJIRAProjects(project): return jiras def getJIRAS(project): + """Reads data/JIRA/%s.json (project), updating it if it is stale + with the number of issues created and resolved in the last 91 days + Returns array of [created, resolved, project] + """ refresh = True try: st=os.stat("/var/www/reporter.apache.org/data/JIRA/%s.json" % project) @@ -184,6 +223,7 @@ def getProjectData(project): return x,y,z def getReleaseData(project): + """Reads data/releases/%s.json and returns the contents""" try: with open("/var/www/reporter.apache.org/data/releases/%s.json" % project, "r") as f: x = json.loads(f.read())