Author: sebb
Date: Wed Sep 30 23:32:45 2015
New Revision: 1706171

URL: http://svn.apache.org/viewvc?rev=1706171&view=rev
Log:
Extract pmc dates for display

Added:
    comdev/projects.apache.org/scripts/cronjobs/pmcdates.py   (with props)
    comdev/projects.apache.org/scripts/cronjobs/pmcdates.sh   (with props)
Modified:
    comdev/projects.apache.org/scripts/committee_info.py

Modified: comdev/projects.apache.org/scripts/committee_info.py
URL: 
http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/committee_info.py?rev=1706171&r1=1706170&r2=1706171&view=diff
==============================================================================
--- comdev/projects.apache.org/scripts/committee_info.py (original)
+++ comdev/projects.apache.org/scripts/committee_info.py Wed Sep 30 23:32:45 
2015
@@ -31,6 +31,8 @@ INTERVAL=300 # code won't recheck for up
 # time format used in Last-Modified/If-Modified-Since HTTP headers
 HTTP_TIME_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'
 
+cidata = {} # The data read from the file
+
 # get file mod date in suitable format for If-Modified-Since
 def mod_date(t):
     return time.strftime(HTTP_TIME_FORMAT, time.gmtime(t))
@@ -86,16 +88,16 @@ def get_url_if_newer(url, dir, name):
         os.utime(check, None) # touch the marker file
 
 def update_cache():
+    global cidata # Python defaults to creating a local variable
     get_url_if_newer(URL, CACHE_DIR, NAME)
+    with open(FILE, "r", encoding='utf-8') as f:
+        cidata = json.loads(f.read())
+        f.close()
 
 update_cache() # done when loading
 
 def chairs():
 
-    with open(FILE, "r", encoding='utf-8') as f:
-        cidata = json.loads(f.read())
-        f.close()
-
     committees = cidata['committees']
 
     chairjson={}
@@ -114,10 +116,6 @@ def chairs():
 
 def cycles():
 
-    with open(FILE, "r", encoding='utf-8') as f:
-        cidata = json.loads(f.read())
-        f.close()
-
     committees = cidata['committees']
 
     cycles={}
@@ -157,10 +155,6 @@ Returns an array of entries of the form:
 """
 def committees():
 
-    with open(FILE, "r", encoding='utf-8') as f:
-        cidata = json.loads(f.read())
-        f.close()
-
     committees = {}
     cttes = cidata['committees']
     for ent in cttes:
@@ -196,4 +190,34 @@ def committees():
             else:
                 c[key] = ctte[key]
         committees[ent]=c
-    return committees
\ No newline at end of file
+    return committees
+
+def pmcdates():
+    dates = {}
+    
+    cttes = cidata['committees']
+    for ent in cttes:
+        ctte = cttes[ent]
+        if not ctte['pmc']:
+            continue
+        roster = ctte['roster']
+        est = ctte['established']
+        date = 0
+        if not est == None:
+            # convert mm/yyyy to date (drop any subsequent text)
+            try:
+                date = calendar.timegm(time.strptime(est[0:7], '%m/%Y'))
+            except Exception as e:
+                print("Date parse error for %s: %s %s" % (ent, est, e))
+                pass
+        dates[ent] = {'pmc': date, 'roster': {} }
+        ids = {}
+        for id in roster:
+            rid = roster[id]
+            try:
+                date = calendar.timegm(time.strptime(rid['date'], '%Y-%m-%d'))
+            except:
+                date = 0
+            ids[id] = [rid['name'], date]
+        dates[ent]['roster'] = ids
+    return dates
\ No newline at end of file

Added: comdev/projects.apache.org/scripts/cronjobs/pmcdates.py
URL: 
http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/cronjobs/pmcdates.py?rev=1706171&view=auto
==============================================================================
--- comdev/projects.apache.org/scripts/cronjobs/pmcdates.py (added)
+++ comdev/projects.apache.org/scripts/cronjobs/pmcdates.py Wed Sep 30 23:32:45 
2015
@@ -0,0 +1,24 @@
+import sys
+sys.path.append("..") # module committee_info is in parent directory
+import committee_info
+import json
+
+"""
+
+Parse PMC start dates and member joining dates
+
+Reads committee-info.json via committee_info module
+
+Creates:
+../../data/cache/pmcdates.json
+
+"""
+
+pmcdates = committee_info.pmcdates()
+
+print("Writing pmcdates.json")
+with open("../../data/cache/pmcdates.json", "w", encoding='utf-8') as f:
+    json.dump(pmcdates, f, sort_keys = True, indent=1, ensure_ascii=False)
+    f.close()
+
+print("All done!")
\ No newline at end of file

Propchange: comdev/projects.apache.org/scripts/cronjobs/pmcdates.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: comdev/projects.apache.org/scripts/cronjobs/pmcdates.sh
URL: 
http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/cronjobs/pmcdates.sh?rev=1706171&view=auto
==============================================================================
--- comdev/projects.apache.org/scripts/cronjobs/pmcdates.sh (added)
+++ comdev/projects.apache.org/scripts/cronjobs/pmcdates.sh Wed Sep 30 23:32:45 
2015
@@ -0,0 +1,10 @@
+# Create the pmc dates file and copy it to reporter.a.o
+
+rm -f ../../data/cache/pmcdates.json
+
+python3 pmcdates.py || exit
+
+echo copying ../../data/cache/pmcdates.json  to ../../../reporter.apache.org/
+cp ../../data/cache/pmcdates.json ../../../reporter.apache.org/site/
+
+echo All done
\ No newline at end of file

Propchange: comdev/projects.apache.org/scripts/cronjobs/pmcdates.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: comdev/projects.apache.org/scripts/cronjobs/pmcdates.sh
------------------------------------------------------------------------------
    svn:executable = *


Reply via email to