openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robw...@apache.org
Subject svn commit: r1406696 - /incubator/ooo/devtools/aoo-stats/get-aoo-stats.py
Date Wed, 07 Nov 2012 16:15:02 GMT
Author: robweir
Date: Wed Nov  7 16:15:02 2012
New Revision: 1406696

URL: http://svn.apache.org/viewvc?rev=1406696&view=rev
Log:
Added support for date ranges as command line inputs, rather than just a single date.

Modified:
    incubator/ooo/devtools/aoo-stats/get-aoo-stats.py

Modified: incubator/ooo/devtools/aoo-stats/get-aoo-stats.py
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/aoo-stats/get-aoo-stats.py?rev=1406696&r1=1406695&r2=1406696&view=diff
==============================================================================
--- incubator/ooo/devtools/aoo-stats/get-aoo-stats.py (original)
+++ incubator/ooo/devtools/aoo-stats/get-aoo-stats.py Wed Nov  7 16:15:02 2012
@@ -34,9 +34,9 @@ import time
 
 from urllib import urlencode
 
-def getSourceForgeStats(download,date):
+def getSourceForgeStats(download, startDate, endDate):
 
-    url = download + "/stats/json?start_date=" + date + "&" "end_date=" + date
+    url = download + "/stats/json?start_date=" + startDate + "&" "end_date=" + endDate
 
     attempts = 0
 
@@ -53,10 +53,25 @@ def getSourceForgeStats(download,date):
 
     return ""
     
-
-if len(sys.argv) == 0:
-    print "syntax:  python get-aoo-stats.py <urls.lst> <iso-date>"
-    print "where <file.list> is a list of files URL's to gather stats on, and <iso-date>
is a date of interest, in YYYY-MM-DD format."
+def printSyntax():
+    print "syntax:  python get-aoo-stats.py <urls.lst> <iso-date> [<iso-date>]"
+    print "where <file.list> is a list of files URL's to gather stats on,"
+    print "and <iso-date> is a date of interest, in YYYY-MM-DD format."
+    print "If two dates are given this expresses a range of dates."
+
+
+if len(sys.argv) == 2:
+    startDate = datetime.date.today().isoformat()
+    endDate = startDate
+elif len(sys.argv) == 3:
+    startDate = sys.argv[2]
+    endDate = startDate
+elif len(sys.argv) == 4:
+    startDate = sys.argv[2]
+    endDate = sys.argv[3]
+else:
+    printSyntax()
+    exit(-1)
 
 #all of the URLs for AOO 3.4 install downloads
 downloads = [line.strip() for line in open(sys.argv[1])]
@@ -65,12 +80,7 @@ count = 0
 
 for download in downloads :
 
-    if len(sys.argv) == 2:
-        date = datetime.date.today().isoformat()
-    else:
-        date = sys.argv[2]
-
-    data = json.loads(getSourceForgeStats(download,date))
+    data = json.loads(getSourceForgeStats(download,startDate,endDate))
 
     day_count = data["total"]
 
@@ -78,8 +88,9 @@ for download in downloads :
 
     count = count + day_count
 
-print data["stats_updated"]
-print str(count)
+print "date range: " +  startDate + " - " + endDate
+print "stats_updated: " + data["stats_updated"]
+print "count: " + str(count)
 
 
 



Mime
View raw message