incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1426813 - /incubator/public/trunk/clutch2report.py
Date Sat, 29 Dec 2012 19:37:39 GMT
Author: bimargulies
Date: Sat Dec 29 19:37:38 2012
New Revision: 1426813

URL: http://svn.apache.org/viewvc?rev=1426813&view=rev
Log:
Improve templates; add option to push to the wiki.

Modified:
    incubator/public/trunk/clutch2report.py

Modified: incubator/public/trunk/clutch2report.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/clutch2report.py?rev=1426813&r1=1426812&r2=1426813&view=diff
==============================================================================
--- incubator/public/trunk/clutch2report.py (original)
+++ incubator/public/trunk/clutch2report.py Sat Dec 29 19:37:38 2012
@@ -3,7 +3,10 @@ import pickle
 import pprint
 from string import Template
 import datetime
-
+import argparse
+import calendar
+import xmlrpc
+import xmlrpc.client
 
 '''
 'clutch2report' reads the pickle file which was created by 'clutch' and generates
@@ -16,7 +19,8 @@ months2groups = [ 'group-1', 'group-2', 
                   'group-1', 'group-2', 'group-3']
 
 boilerplate = """
-{{{
+Incubator PMC report for {month} 2013
+
 < narrative >
 
 o Community
@@ -35,14 +39,12 @@ o Releases
 
 o Legal / Trademarks
 
-
 o Infrastructure
 
 -------------------- Summary of podling reports --------------------
 
 Still getting started at the Incubator
 
-
   These projects are still getting started, so no immediate progress
   towards graduation is yet expected.
 
@@ -72,34 +74,63 @@ How has the community developed since th
 
 How has the project developed since the last report?
 
+Please check this [ ] when you have filled in the report for $name.
+
 Signed-off-by: 
+$mentorlist
 
-Shepherd note:
+Shepherd notes:
 """
 
-
-def main(argv = None):
-    if argv is None:
-        argv = sys.argv
-    now = datetime.datetime.now()
-    curGroup = months2groups[now.month - 1];
+def push(name, password, pagename, reportFile):
+    report = open(reportFile, 'r')
+    reportcontent = report.read(-1)
+    report.close()
+    srcwiki = xmlrpc.client.ServerProxy("http://wiki.apache.org/incubator/?action=xmlrpc2")
+    token =  srcwiki.getAuthToken(name, password)
+    
+    pushresults = srcwiki.system.multicall([{'methodName':'applyAuthToken', 'params': [token]},

+                                            {'methodName':'putPage', 'params': [pagename,
"{{{\n" + reportcontent + "\n}}}\n"]}])
+    print(pushresults)
+
+def cliargs():
+    parser = argparse.ArgumentParser(description='Create (and optionally push) a template
for an incubator report.')
+    parser.add_argument('--push', nargs=2, help='whether to push the report template.', metavar=('username',
'password'))
+    parser.add_argument('--month', type=int, help='the month to report for, defaults to current
month.', default=0)
+    return parser.parse_args()  # note that this exits on errors.
+
+
+def main():
+    options = cliargs()
+    if options.month == 0:
+        now = datetime.datetime.now()
+        month = now.month - 1
+    else:
+        month = options.month
+    curGroup = months2groups[month]
     inputFile = open('clutch.pkl', 'rb')
     projects = pickle.load(inputFile)
     inputFile.close()
     output = open('report.txt', 'w')
-    output.write(boilerplate)
+    output.write(boilerplate.format(month=calendar.month_abbr[month]))
     ptemplate = Template(perproject)
     
     for project in projects.keys():
         pdata = projects[project]
         
         if pdata['rawReportingGroup'] == curGroup or pdata['reportingMonthly']:
+            mentorlist = ""
+            for mentor in pdata['mentors']:
+                mentorlist = mentorlist + "{0}: [ ]({1})\n".format(mentor, project)
             pdict = { 'name': pdata['fullName'], 
                       'description': pdata['description'],
-                      'start': pdata['startDate']}
+                      'start': pdata['startDate'],
+                      'mentorlist' : mentorlist}
             output.write(ptemplate.substitute(pdict))
-    output.write("}}}")
     output.close()
+    pushdata = options.push
+    if pushdata != None:
+        push(pushdata[0], pushdata[1], "{0}2013".format(calendar.month_name[month]), 'report.txt')
     
 if __name__ == "__main__":
     main()



---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message