[Libreoffice-commits] dev-tools.git: esc-reporting/esc-analyze.py

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 8 08:48:50 UTC 2019


 esc-reporting/esc-analyze.py |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 20612c555d2f96a3616d27fade27d2acbc14a020
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Oct 8 10:47:20 2019 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Oct 8 10:47:20 2019 +0200

    ESC: Compress archive files

diff --git a/esc-reporting/esc-analyze.py b/esc-reporting/esc-analyze.py
index 3326360..8085393 100755
--- a/esc-reporting/esc-analyze.py
+++ b/esc-reporting/esc-analyze.py
@@ -54,7 +54,8 @@ import datetime
 import json
 import xmltodict
 import re
-
+import gzip
+from shutil import copyfile
 
 
 def util_load_file(fileName, isJson=True):
@@ -876,7 +877,14 @@ def analyze_final():
     sFile = cfg['homedir'] + 'stats.json'
     util_dump_file(sFile, statList)
     x = myDay.strftime('%Y-%m-%d')
-    os.system('cp '+ sFile + ' ' + cfg['homedir'] + 'archive/stats_' + x + '.json')
+
+    sArchiveFile = cfg['homedir'] + 'archive/stats_' + x + '.json'
+    copyfile(sFile, sArchiveFile)
+    with open(sArchiveFile, 'rb') as f_in:
+      with gzip.open(sArchiveFile + '.gz', 'wb') as f_out:
+        f_out.writelines(f_in)
+    os.remove(sArchiveFile)
+
     if myDay.strftime('%w') == '4':
       if 'people' in statList:
         del statList['people']
@@ -950,7 +958,8 @@ def runAnalyze():
     global openhubData, bugzillaData, bugzillaESCData, gerritData, gitData, crashData, weekList, automateData, committersNames
 
     x = (cfg['nowDate'] - datetime.timedelta(days=7)).strftime('%Y-%m-%d')
-    weekList = util_load_file(cfg['homedir'] + 'archive/stats_' + x + '.json')
+    with gzip.open(cfg['homedir'] + 'archive/stats_' + x + '.json.gz', 'rb'):
+      weekList = util_load_file(x + '.json')
 
     openhubData = util_load_data_file(cfg['homedir'] + 'dump/openhub_dump.json')
     bugzillaData = util_load_data_file(cfg['homedir'] + 'dump/bugzilla_dump.json')


More information about the Libreoffice-commits mailing list