Author: robweir Date: Fri Oct 26 13:56:44 2012 New Revision: 1402516 URL: http://svn.apache.org/viewvc?rev=1402516&view=rev Log: Delete aoo-stats.py (get-aoo-stats.py is the preferred script). Also updated countries.py to run against .lst files so it works with AOO 3.4.0 and AOO 3.4.1 downloads and is future-proof.
Removed: incubator/ooo/devtools/aoo-stats/aoo-stats.py Modified: incubator/ooo/devtools/aoo-stats/countries.py Modified: incubator/ooo/devtools/aoo-stats/countries.py URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/aoo-stats/countries.py?rev=1402516&r1=1402515&r2=1402516&view=diff ============================================================================== --- incubator/ooo/devtools/aoo-stats/countries.py (original) +++ incubator/ooo/devtools/aoo-stats/countries.py Fri Oct 26 13:56:44 2012 @@ -20,24 +20,36 @@ ################################################################ -# In order to speed up the script on repeat executions, partial results -# are cachced in the ./cache directory - - import urllib import json import os import hashlib import datetime import time +import sys from urllib import urlencode def getSourceForgeStats(download, start_date, end_date): - + print download url = download + "/stats/json?start_date=" + start_date + "&" "end_date=" + end_date - return urllib.urlopen(url).read() + attempts = 0 + + while attempts < 3: + try: + conn = urllib.urlopen(url) + data = conn.read() + + return data + + except: + attempts += 1 + print "error " + str(attempts) + + return "" + + #extracts the language code from the URL # this logic is very sensitive to the exact naming conventions @@ -55,100 +67,6 @@ def getLanguage(url): return s[s.rfind("_")+1:len(s)] -#all of the URLs for AOO 3.4 install downloads, excluding SDK's and langpacks -downloads = [ - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ar/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_ar.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ar/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_ar.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ar/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_ar.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ar/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_ar.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ar/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_ar.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ar/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_ar.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-CN/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_zh-CN.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-CN/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_zh-CN.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-CN/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_zh-CN.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-CN/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_zh-CN.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-CN/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_zh-CN.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-CN/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_zh-CN.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-TW/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_zh-TW.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-TW/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_zh-TW.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-TW/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_zh-TW.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-TW/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_zh-TW.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-TW/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_zh-TW.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/zh-TW/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_zh-TW.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/cs/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_cs.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/cs/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_cs.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/cs/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_cs.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/cs/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_cs.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/cs/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_cs.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/cs/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_cs.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/nl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_nl.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/nl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_nl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/nl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_nl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/nl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_nl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/nl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_nl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/nl/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_nl.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/stable/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_en-US.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/stable/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_en-US.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/stable/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_en-US.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/stable/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_en-US.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/stable/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_en-US.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/stable/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_en-US.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/fr/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_fr.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/fr/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_fr.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/fr/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_fr.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/fr/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_fr.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/fr/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_fr.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/fr/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_fr.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/gl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_gl.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/gl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_gl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/gl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_gl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/gl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_gl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/gl/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_gl.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/gl/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_gl.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/de/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_de.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/de/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_de.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/de/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_de.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/de/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_de.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/de/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_de.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/de/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_de.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/hu/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_hu.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/hu/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_hu.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/hu/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_hu.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/hu/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_hu.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/hu/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_hu.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/hu/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_hu.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/it/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_it.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/it/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_it.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/it/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_it.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/it/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_it.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/it/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_it.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/it/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_it.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ja/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_ja.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ja/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_ja.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ja/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_ja.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ja/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_ja.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ja/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_ja.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ja/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_ja.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/pt-BR/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_pt-BR.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/pt-BR/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_pt-BR.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/pt-BR/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_pt-BR.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/pt-BR/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_pt-BR.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/pt-BR/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_pt-BR.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/pt-BR/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_pt-BR.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ru/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_ru.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ru/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_ru.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ru/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_ru.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ru/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_ru.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ru/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_ru.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/ru/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_ru.dmg" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/es/3.4.0/Apache_OpenOffice_incubating_3.4.0_Win_x86_install_es.exe" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/es/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-rpm_es.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/es/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86_install-deb_es.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/es/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-rpm_es.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/es/3.4.0/Apache_OpenOffice_incubating_3.4.0_Linux_x86-64_install-deb_es.tar.gz" , - "http://sourceforge.net/projects/openofficeorg.mirror/files/localized/es/3.4.0/Apache_OpenOffice_incubating_3.4.0_MacOS_x86_install_es.dmg" , -] - # dictionary of language code to country_dict (dictionary of country name to count) master_dict = {} @@ -173,16 +91,20 @@ def mergeCountries(lang, countries): -for download in downloads : - # Remember that range functions do not include the end value, so set range to n+1 if you want to include date n - start_date = "2012-05-07" - end_date = "2012-05-28" - - data = json.loads(getSourceForgeStats(download,start_date, end_date)) +if len(sys.argv) == 0: + print "syntax: python countries.py <urls.lst> <start-date> <end-date>" + print "where <file.list> is a list of files URL's to gather stats on, and <start-date> and <end-date> are in YYYY-MM-DD format." + +downloads = [line.strip() for line in open(sys.argv[1])] + +for download in downloads : + + data = json.loads(getSourceForgeStats(download, sys.argv[2], sys.argv[3])) lang = getLanguage(download) + #lang = "foo" countries = data["countries"]