This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openoffice-devtools.git


The following commit(s) were added to refs/heads/main by this push:
     new 0f2eaca  Update script to Python 3
0f2eaca is described below

commit 0f2eacaf24724849a926576dcca140143aaf95ac
Author: mseidel <msei...@apache.org>
AuthorDate: Sun Aug 24 02:52:12 2025 +0200

    Update script to Python 3
---
 aoo-stats/downloads-by-country.py                  | 55 +++++++++++-----------
 ...s-by-country.py => downloads-by-country.py.old} |  0
 2 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/aoo-stats/downloads-by-country.py 
b/aoo-stats/downloads-by-country.py
index c5a4a04..265412c 100644
--- a/aoo-stats/downloads-by-country.py
+++ b/aoo-stats/downloads-by-country.py
@@ -19,8 +19,7 @@
 #
 ################################################################
 
-
-import urllib
+import urllib.request, urllib.parse, urllib.error
 import json
 import os
 import hashlib
@@ -28,26 +27,26 @@ import datetime
 import time
 import sys
 
-from urllib import urlencode
+from urllib.parse import urlencode
 
 def getSourceForgeStats(download, start_date, end_date):
 
     #print download
 
     url = download + "/stats/json?start_date=" + start_date + "&" "end_date=" 
+ end_date
-    
+
     attempts = 0
 
     while attempts < 3:
         try:
-            conn = urllib.urlopen(url)
+            conn = urllib.request.urlopen(url)
             data = conn.read()
-            
+
             return data
 
         except:
             attempts += 1
-            print "error " + str(attempts)
+            print("error " + str(attempts))
 
     return ""
 
@@ -68,8 +67,8 @@ def mergeCountries(countries):
 
 
 if len(sys.argv) == 0:
-    print "syntax: python downloads-by-country.py <urls.lst> <start-date> 
<end-date>"
-    print "where <urls.lst> is a list of files URLs to gather stats on, and 
<start-date> and <end-date> are in YYYY-MM-DD format."
+    print("syntax: python downloads-by-country.py <urls.lst> <start-date> 
<end-date>")
+    print("where <urls.lst> is a list of files URLs 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])]
 
@@ -86,30 +85,30 @@ for download in downloads :
     mergeCountries(countries)
 
 
-print "<html>"
-print "<head>"
-print "<title>OpenOffice Downloads by Country/Territory</title>"
-print "</head>"
-print "<body>"
-print "<p>This table shows downloads per <a 
href='https://en.wikipedia.org/wiki/Country_code_top-level_domain'>country/territory</a>
 for the period from " + sys.argv[2] + " to " + sys.argv[3] + ".</p>"
-print "<table border='1' cellpadding='10'>"
+print("<html>")
+print("<head>")
+print("<title>OpenOffice Downloads by Country/Territory</title>")
+print("</head>")
+print("<body>")
+print("<p>This table shows downloads per <a 
href='https://en.wikipedia.org/wiki/Country_code_top-level_domain'>country/territory</a>
 for the period from " + sys.argv[2] + " to " + sys.argv[3] + ".</p>")
+print("<table border='1' cellpadding='10'>")
 
-print "<tr>"
-print "<th>Rank</th>"
-print "<th>Country/Territory</th>"
-print "<th>Downloads</th>"
-print "</tr>"
+print("<tr>")
+print("<th>Rank</th>")
+print("<th>Country/Territory</th>")
+print("<th>Downloads</th>")
+print("</tr>")
 
 rank = 1
 
 for country in sorted(country_dict,key=lambda x: country_dict[x], 
reverse=True):
-    print "<tr>"
-    print "<td align='right'>" + "#" + str(rank) + "</td>"
-    print "<td>" + country.encode("utf-8") + "</td>"
-    print "<td align='right'>" + str(country_dict[country]) + "</td>"
-    print "</tr>"
+    print("<tr>")
+    print("<td align='right'>" + "#" + str(rank) + "</td>")
+    print("<td>" + country.encode("utf-8") + "</td>")
+    print("<td align='right'>" + str(country_dict[country]) + "</td>")
+    print("</tr>")
     rank +=1
 
-print"</table>"
-print "</body>"
+print("</table>")
+print("</body>")
 
diff --git a/aoo-stats/downloads-by-country.py 
b/aoo-stats/downloads-by-country.py.old
similarity index 100%
copy from aoo-stats/downloads-by-country.py
copy to aoo-stats/downloads-by-country.py.old

Reply via email to