[Libreoffice-commits] dev-tools.git: 2 commits - esc-reporting/esc-analyze.py esc-reporting/esc-automate.py esc-reporting/esc-collect.py esc-reporting/esc-report.py

jan Iversen jani at libreoffice.org
Sun May 7 14:08:55 UTC 2017


 esc-reporting/esc-analyze.py  |  165 ++++++++++++++++++++++++++++++++-
 esc-reporting/esc-automate.py |  119 ++++++++++++++++++++++++
 esc-reporting/esc-collect.py  |   18 ++-
 esc-reporting/esc-report.py   |  206 ++++++------------------------------------
 4 files changed, 318 insertions(+), 190 deletions(-)

New commits:
commit 5ce255299da00e77e726e78ac8ece7db635bc3a0
Author: jan Iversen <jani at libreoffice.org>
Date:   Sun May 7 16:08:32 2017 +0200

    esc-report, first version of automate script

diff --git a/esc-reporting/esc-automate.py b/esc-reporting/esc-automate.py
new file mode 100755
index 0000000..23906c9
--- /dev/null
+++ b/esc-reporting/esc-automate.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python3
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+
+
+
+
+### DESCRIPTION
+#
+# This program automates update of bugzilla, gerrit and sends mail
+#
+# Installed on vm174:/usr/local/bin runs every night (generating and mailing reports)
+#
+#
+
+
+
+import sys
+import os
+import datetime
+import json
+
+
+def util_load_data_file(fileName):
+    try:
+      fp = open(fileName, encoding='utf-8')
+      rawData = json.load(fp)
+      fp.close()
+    except Exception as e:
+      print('Error load file ' + fileName + ' due to ' + str(e))
+      exit(-1)
+    return rawData
+
+
+
+def util_dump_file(fileName, rawList):
+    try:
+      fp = open(fileName, 'w', encoding='utf-8')
+      json.dump(rawList, fp, ensure_ascii=False, indent=4, sort_keys=True)
+      fp.close()
+    except Exception as e:
+      print('Error dump file ' + fileName + ' due to ' + str(e))
+      os.remove(fileName)
+      exit(-1)
+
+
+
+
+
+def runCfg(platform):
+    global cfg
+    if 'esc_homedir' in os.environ:
+      homeDir = os.environ['esc_homedir']
+    else:
+      homeDir = '/home/esc-mentoring/esc'
+
+    cfg = util_load_data_file(homeDir + '/config.json')
+    cfg['homedir'] = homeDir + '/'
+    cfg['platform'] = platform
+    print("Reading and writing data to " + cfg['homedir'])
+
+    cfg['award-mailed'] = util_load_data_file(cfg['homedir'] + 'award.json')['award-mailed']
+    cfg['nowDate'] = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
+    cfg['cutDate'] = cfg['nowDate'] - datetime.timedelta(days=365)
+    cfg['1weekDate'] = cfg['nowDate'] - datetime.timedelta(days=7)
+    cfg['1monthDate'] = cfg['nowDate'] - datetime.timedelta(days=30)
+    cfg['3monthDate'] = cfg['nowDate'] - datetime.timedelta(days=90)
+    cfg['1yearDate'] = cfg['nowDate'] - datetime.timedelta(days=365)
+    return cfg
+
+
+
+def runAutomate():
+    global cfg, autoList
+
+    autoList = util_load_data_file(cfg['homedir'] + 'automate.json')
+
+    xMail = []
+    try:
+      x = automate_gerrit()
+      if not x is None:
+        xMail.append(x)
+    except:
+      pass
+    try:
+      x = automate_bugzilla()
+      if not x is None:
+        xMail.append(x)
+    except:
+      pass
+    try:
+      x = automate_pdf()
+      if not x is None:
+        xMail.append(x)
+    except:
+      pass
+
+    fp = open('/tmp/runAutoMail', 'w', encoding='utf-8')
+    print("#!/bin/bash", file=fp)
+    print("")
+    for i in xMail:
+      if 'attach' in i:
+        attach = '-a ' + i['attach'] + ' '
+      else:
+        attach = ''
+      print("mail -s '" + i['title'] + "' " + attach + i['mail'] + " <  " + i['file'], file=fp)
+    fp.close()
+
+
+
+if __name__ == '__main__':
+    runCfg(sys.platform)
+    runAutomate()
commit 0412317845f6da3b0b5bb17aeb3db24e1ba9c6ef
Author: jan Iversen <jani at libreoffice.org>
Date:   Sun May 7 16:08:08 2017 +0200

    esc-report, moved analyze functions to esc-analyze

diff --git a/esc-reporting/esc-analyze.py b/esc-reporting/esc-analyze.py
index f4fc753..f749739 100755
--- a/esc-reporting/esc-analyze.py
+++ b/esc-reporting/esc-analyze.py
@@ -220,7 +220,9 @@ def util_create_statList():
                      'esc': {}},
                      'stat': {'openhub_last_analyse': "2001-01-01"},
                      'people': {},
-                     'escList': {}}
+                     'escList': {},
+                     'reportList': {},
+                     'automateList': {}}
 
 
 
@@ -560,6 +562,136 @@ def analyze_esc():
       statList['data']['esc']['component']['os'][id] = row['count']
 
 
+
+
+def analyze_reports():
+    global cfg, statList, openhubData, bugzillaData, gerritData, gitData
+
+    print("reports: analyze", flush=True)
+    mailedDate = datetime.datetime.strptime(cfg['git']['last-mail-run'], '%Y-%m-%d') - datetime.timedelta(days=90)
+    zeroDate = datetime.datetime(year=2001, month=1, day=1)
+    statList['reportList'] = {'we_miss_you_email': [],
+                              'award_1st_email': [],
+                              'pending_license': [],
+                              'missing_license': [],
+                              'to_be_closed': [],
+                              'needsDevEval': [],
+                              'needsUXEval': [],
+                              'needinfo': [],
+                              'easyhacks_new': [],
+                              'too_many_comments': [],
+                              'top10commit': [],
+                              'top10review': []}
+    statList['automateList'] = {'to_abandon': [],
+                                'to_review': [],
+                                'missing_ui_cc': [],
+                                'to_unassign': [],
+                                'missing_cc': [],
+                                'assign_problem': [],
+                                'remove_cc': []}
+
+    for id, row in statList['people'].items():
+      entry = {'name': row['name'], 'email': id, 'license': row['licenseText']}
+      if row['newestCommit'] > mailedDate and row['newestCommit'] < cfg['3monthDate']:
+        statList['reportList']['we_miss_you_email'].append(entry)
+      x = row['commits']['1month']['owner']
+      if x != 0 and row['commits']['total'] == x and not id in cfg['award-mailed']:
+          statList['reportList']['award_1st_email'].append(entry)
+      if row['licenseText'].startswith('PENDING'):
+          statList['reportList']['pending_license'].append(entry)
+
+    for key,row in gerritData['patch'].items():
+      if row['status'] == 'SUBMITTED' or row['status'] == 'DRAFT':
+        row['status'] = 'NEW'
+      xDate = datetime.datetime.strptime(row['updated'], '%Y-%m-%d %H:%M:%S.%f000')
+      ownerEmail = util_check_mail(row['owner']['name'], row['owner']['email'])
+      entry = {'id': key, 'name': row['owner']['name'], 'email': ownerEmail, 'title': row['subject']}
+      if row['status'] != 'ABANDONED':
+        if ownerEmail is None:
+          ownerEmail = row['owner']['email']
+          entry['email'] = ownerEmail
+          entry['license'] = 'GERRIT NO LICENSE'
+          statList['reportList']['missing_license'].append(entry)
+        elif not statList['people'][ownerEmail]['licenseOK']:
+          entry['license'] = 'GERRIT: ' + statList['people'][ownerEmail]['licenseText']
+          statList['reportList']['missing_license'].append(entry)
+
+      if row['status'] == 'NEW':
+        doBlock = False
+        cntReview = 0
+        for x1 in 'Code-Review', 'Verified':
+          for x in row['labels'][x1]['all']:
+            if x['value'] == -2:
+              doBlock = True
+            if x['email'] != ownerEmail and x['email'] != 'ci at libreoffice.org':
+              cntReview += 1
+        if xDate < cfg['1monthDate'] and not doBlock:
+            statList['automateList']['to_abandon'].append(entry)
+        if cntReview == 0 and not statList['people'][ownerEmail]['isCommitter']:
+            statList['automateList']['to_review'].append(entry)
+
+    for key, row in bugzillaData['bugs'].items():
+      if not 'cc' in row:
+        row['cc'] = []
+      if not 'keywords' in row:
+        row['keywords'] = []
+
+      if row['status'] == 'RESOLVED' or row['status'] == 'VERIFIED':
+        continue
+
+      if not 'easyHack' in row['keywords']:
+        if 'mentoring' in row['cc']:
+          statList['automateList']['remove_cc'].append(key)
+        continue
+
+      if 'needsDevEval' in row['keywords']:
+          statList['reportList']['needsDevEval'].append(key)
+      if 'needsUXEval' in row['keywords']:
+          statList['reportList']['needsUXEval'].append(key)
+      if 'topicUI' in row['keywords'] and 'libreoffice-ux-advise at lists.freedesktop.org' not in row['cc']:
+          statList['automateList']['missing_ui_cc'].append(key)
+      if row['status'] == 'NEEDINFO':
+          statList['reportList']['needinfo'].append(key)
+      elif row['status'] == 'ASSIGNED':
+        xDate = datetime.datetime.strptime(row['last_change_time'], "%Y-%m-%dT%H:%M:%SZ")
+        if xDate < cfg['1monthDate']:
+          statList['automateList']['to_unassign'].append(key)
+      if (row['status'] == 'ASSIGNED' and (row['assigned_to'] == '' or row['assigned_to'] == 'libreoffice-bugs at lists.freedesktop.org')) or \
+         (row['status'] != 'ASSIGNED' and row['assigned_to'] != '' and row['assigned_to'] != 'libreoffice-bugs at lists.freedesktop.org') :
+          statList['automateList']['assign_problem'].append(key)
+      if len(row['comments']) >= 5:
+        statList['reportList']['too_many_comments'].append(key)
+      if not 'mentoring at documentfoundation.org' in row['cc']:
+        statList['automateList']['missing_cc'].append(key)
+      if row['comments'][-1]['creator'] == 'libreoffice-commits at lists.freedesktop.org' and not key in cfg['bugzilla']['close_except']:
+        statList['reportList']['to_be_closed'].append(key)
+      cDate = datetime.datetime.strptime(row['creation_time'], "%Y-%m-%dT%H:%M:%SZ")
+      if cDate >= cfg['1weekDate'] or 'easyhack' in row['history'][-1]['changes'][0]['added']:
+        statList['reportList']['easyhacks_new'].append(key)
+
+    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['commits']['1month']['owner']),reverse=True)
+    for i in tmpClist:
+        if not statList['people'][i]['isCommitter']:
+            x = {'mail': i, 'name': statList['people'][i]['name'],
+                 'month': statList['people'][i]['commits']['1month']['owner'],
+                 'year': statList['people'][i]['commits']['1year']['owner']}
+            statList['reportList']['top10commit'].append(x)
+            if len(statList['reportList']['top10commit']) >= 10:
+                break
+    tmpRlist = sorted(statList['people'], key=lambda k: (statList['people'][k]['gerrit']['1month']['reviewer']),reverse=True)
+    for i in tmpRlist:
+        if i != 'ci at libreoffice.org':
+            x = {'mail': i, 'name': statList['people'][i]['name'],
+                 'month': statList['people'][i]['gerrit']['1month']['reviewer'],
+                 'year': statList['people'][i]['gerrit']['1year']['reviewer']}
+            statList['reportList']['top10review'].append(x)
+            if len(statList['reportList']['top10review']) >= 10:
+                break
+
+    statList['automateList']['award_1st_email'] = statList['reportList']['award_1st_email']
+
+
+
 def analyze_myfunc():
     global cfg, statList, openhubData, bugzillaData, gerritData, gitData, licenceCompanyData, licencePersonalData
 
@@ -619,6 +751,10 @@ def analyze_final():
         del statList['aliases']
       if 'escList' in statList:
         del statList['escList']
+      if 'reportList' in statList:
+        del statList['reportList']
+      if 'automateList' in statList:
+        del statList['automateList']
       util_dump_file(cfg['homedir'] + 'weeks/week_' + myDay.strftime('%Y_%W') + '.json', statList)
 
 
@@ -665,6 +801,7 @@ def loadCfg(platform):
 
     cfg = util_load_data_file(homeDir + '/config.json')
     cfg['homedir'] = homeDir + '/'
+    cfg['award-mailed'] = util_load_data_file(cfg['homedir'] + 'award.json')['award-mailed']
     cfg['platform'] = platform
     cfg['nowDate'] = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
     cfg['cutDate'] = cfg['nowDate']
@@ -690,31 +827,43 @@ def runAnalyze():
     statList = util_create_statList()
     try:
       runLoadCSV()
-    except:
+    except Exception as e:
+      print('ERROR: runLoadCSV failed with ' + str(e))
       pass
     try:
       analyze_mentoring()
-    except:
+    except Exception as e:
+      print('ERROR: analyze_mentoring failed with ' + str(e))
       pass
     try:
       analyze_ui()
-    except:
+    except Exception as e:
+      print('ERROR: analyze_ui failed with ' + str(e))
       pass
     try:
       analyze_qa()
-    except:
+    except Exception as e:
+      print('ERROR: analyze_qa failed with ' + str(e))
       pass
     try:
       analyze_esc()
-    except:
+    except Exception as e:
+      print('ERROR: analyze_esc failed with ' + str(e))
       pass
     try:
       analyze_myfunc()
-    except:
+    except Exception as e:
+      print('ERROR: analyze_myfunc failed with ' + str(e))
+      pass
+    try:
+      analyze_reports()
+    except Exception as e:
+      print('ERROR: analyze_reports failed with ' + str(e))
       pass
     try:
       analyze_final()
-    except:
+    except Exception as e:
+      print('ERROR: analyze_final failed with ' + str(e))
       pass
 
 
diff --git a/esc-reporting/esc-collect.py b/esc-reporting/esc-collect.py
index 434f24f..3a954c2 100755
--- a/esc-reporting/esc-collect.py
+++ b/esc-reporting/esc-collect.py
@@ -724,27 +724,33 @@ def runCfg(platform):
 def runBuild(cfg):
     try:
       crashData = get_crash(cfg)
-    except:
+    except Exception as e:
+      print('ERROR: get_crash failed with ' + str(e))
       pass
     try:
       openhubData = get_openhub(cfg)
-    except:
+    except Exception as e:
+      print('ERROR: get_openhub failed with ' + str(e))
       pass
     try:
       bugzillaData = get_bugzilla(cfg)
-    except:
+    except Exception as e:
+      print('ERROR: get_bugzilla failed with ' + str(e))
       pass
     try:
       ESCData = get_esc_bugzilla(cfg)
-    except:
+    except Exception as e:
+      print('ERROR: get_esc_bugzilla failed with ' + str(e))
       pass
     try:
       gerritData = get_gerrit(cfg)
-    except:
+    except Exception as e:
+      print('ERROR: get_gerrit failed with ' + str(e))
       pass
     try:
       gitData = get_git(cfg)
-    except:
+    except Exception as e:
+      print('ERROR: get_git failed with ' + str(e))
       pass
 
 
diff --git a/esc-reporting/esc-report.py b/esc-reporting/esc-report.py
index 2920470..a6620e9 100755
--- a/esc-reporting/esc-report.py
+++ b/esc-reporting/esc-report.py
@@ -142,180 +142,26 @@ def util_build_matrix(title, lineDesc, index):
 
 def report_day_mentoring():
     global statList, openhubData, gerritData, gitData, bugzillaData, cfg
-    myStatList = {'needsDevEval': [],
-                  'needsUXEval': [],
-                  'missing_ui_cc': [],
-                  'needinfo': [],
-                  'to_be_closed': [],
-                  'easyhacks_new': [],
-                  'to_unassign': [],
-                  'too_many_comments': [],
-                  'missing_cc': [],
-                  'assign_problem': [],
-                  'we_miss_you_email': [],
-                  'award_1st_email': [],
-                  'pending_license': [],
-                  'missing_license': [],
-                  'to_abandon' : [],
-                  'to_review': [],
-                  'remove_cc': []
-                  }
-    mailedDate = datetime.datetime.strptime(cfg['git']['last-mail-run'], '%Y-%m-%d') - datetime.timedelta(days=90)
-    zeroDate = datetime.datetime(year=2001, month=1, day=1)
-    for id, row in statList['people'].items():
-      entry = {'name': row['name'], 'email': id, 'license': row['licenseText']}
-      newestCommitDate = datetime.datetime.strptime(row['newestCommit'], '%Y-%m-%d')
-      if newestCommitDate > mailedDate and newestCommitDate < cfg['3monthDate']:
-        myStatList['we_miss_you_email'].append(entry)
-      x = row['commits']['1month']['owner']
-      if x != 0 and row['commits']['total'] == x and not id in cfg['award-mailed']:
-        myStatList['award_1st_email'].append(entry)
-      if row['licenseText'].startswith('PENDING'):
-        myStatList['pending_license'].append(entry)
-
-    for key,row in gerritData['patch'].items():
-      if row['status'] == 'SUBMITTED' or row['status'] == 'DRAFT':
-        row['status'] = 'NEW'
-      xDate = datetime.datetime.strptime(row['updated'], '%Y-%m-%d %H:%M:%S.%f000')
-      ownerEmail = util_check_mail(row['owner']['email'])
-      entry = {'id': key, 'name': row['owner']['name'], 'email': ownerEmail, 'title': row['subject']}
-      if row['status'] != 'ABANDONED':
-        if ownerEmail is None:
-          ownerEmail = row['owner']['email']
-          entry['email'] = ownerEmail
-          entry['license'] = 'GERRIT NO LICENSE'
-          myStatList['missing_license'].append(entry)
-        elif not statList['people'][ownerEmail]['licenseOK']:
-          entry['license'] = 'GERRIT: ' + statList['people'][ownerEmail]['licenseText']
-          myStatList['missing_license'].append(entry)
-
-      if row['status'] == 'NEW':
-        doBlock = False
-        cntReview = 0
-        for x1 in 'Code-Review', 'Verified':
-          for x in row['labels'][x1]['all']:
-            if x['value'] == -2:
-              doBlock = True
-            if x['email'] != ownerEmail and x['email'] != 'ci at libreoffice.org':
-              cntReview += 1
-        if xDate < cfg['1monthDate'] and not doBlock:
-            myStatList['to_abandon'].append(entry)
-        if cntReview == 0 and not statList['people'][ownerEmail]['isCommitter']:
-          myStatList['to_review'].append(entry)
-
-    for key,row in gitData['commits'].items():
-      for i in 'author', 'committer':
-        email = util_check_mail(row[i+'-email'])
-        entry = {'id': key, 'name': row[i], 'email': email}
-        if email is None:
-          entry['email'] = row['author-email']
-          entry['license'] = 'GIT AUTHOR NO LICENSE'
-          myStatList['missing_license'].append(entry)
-        elif not statList['people'][email]['licenseOK']:
-          entry['license'] = 'GIT: ' + statList['people'][email]['licenseText']
-          myStatList['missing_license'].append(entry)
-
-    for key, row in bugzillaData['bugs'].items():
-      if not 'cc' in row:
-        row['cc'] = []
-      if not 'keywords' in row:
-        row['keywords'] = []
-
-      if row['status'] == 'RESOLVED' or row['status'] == 'VERIFIED':
-        continue
-
-      if not 'easyHack' in row['keywords']:
-        if 'mentoring' in row['cc']:
-          myStatList['remove_cc'].append(key)
-        continue
-
-      if 'needsDevEval' in row['keywords']:
-        myStatList['needsDevEval'].append(key)
-      if 'needsUXEval' in row['keywords']:
-        myStatList['needsUXEval'].append(key)
-      if 'topicUI' in row['keywords'] and 'libreoffice-ux-advise at lists.freedesktop.org' not in row['cc']:
-        myStatList['missing_ui_cc'].append(key)
-      if row['status'] == 'NEEDINFO':
-        myStatList['needinfo'].append(key)
-      elif row['status'] == 'ASSIGNED':
-        xDate = datetime.datetime.strptime(row['last_change_time'], "%Y-%m-%dT%H:%M:%SZ")
-        if xDate < cfg['1monthDate']:
-          myStatList['to_unassign'].append(key)
-      if (row['status'] == 'ASSIGNED' and (row['assigned_to'] == '' or row['assigned_to'] == 'libreoffice-bugs at lists.freedesktop.org')) or \
-         (row['status'] != 'ASSIGNED' and row['assigned_to'] != '' and row['assigned_to'] != 'libreoffice-bugs at lists.freedesktop.org') :
-        myStatList['assign_problem'].append(key)
-      if len(row['comments']) >= 5:
-        myStatList['too_many_comments'].append(key)
-      if not 'mentoring at documentfoundation.org' in row['cc']:
-        myStatList['missing_cc'].append(key)
-      if row['comments'][-1]['creator'] == 'libreoffice-commits at lists.freedesktop.org' and not key in cfg['bugzilla']['close_except']:
-        myStatList['to_be_closed'].append(key)
-      cDate = datetime.datetime.strptime(row['creation_time'], "%Y-%m-%dT%H:%M:%SZ")
-      if cDate >= cfg['1weekDate'] or 'easyhack' in row['history'][-1]['changes'][0]['added']:
-        myStatList['easyhacks_new'].append(key)
-
 
     fp = open('/tmp/esc_day_mentoring_report.txt', 'w', encoding='utf-8')
     print('Day mentoring report, generated {} based on stats.json from {}'.format(
           datetime.datetime.now().strftime("%Y-%m-%d"), statList['addDate']), file=fp)
 
-    util_print_line(fp, myStatList['missing_license'],    'missing license statement'  )
-    util_print_line(fp, myStatList['needinfo'],           'easyhacks with NEEDINFO',   doBugzilla=True)
-    util_print_line(fp, myStatList['easyhacks_new'],      'easyhacks new',             doBugzilla=True)
-    util_print_line(fp, myStatList['to_be_closed'],       'easyhacks to be closed',    doBugzilla=True)
-    util_print_line(fp, myStatList['needsDevEval'],       'easyhacks needsDevEval',    doBugzilla=True)
-    util_print_line(fp, myStatList['needsUXEval'],        'easyhacks needsUXEval',     doBugzilla=True)
-    util_print_line(fp, myStatList['too_many_comments'],  'easyhacks reduce comments', doBugzilla=True)
-    util_print_line(fp, myStatList['pending_license'],    'pending license statement'  )
+    util_print_line(fp, statList['reportList']['missing_license'],    'missing license statement'  )
+    util_print_line(fp, statList['reportList']['needinfo'],           'easyhacks with NEEDINFO',   doBugzilla=True)
+    util_print_line(fp, statList['reportList']['easyhacks_new'],      'easyhacks new',             doBugzilla=True)
+    util_print_line(fp, statList['reportList']['to_be_closed'],       'easyhacks to be closed',    doBugzilla=True)
+    util_print_line(fp, statList['reportList']['needsDevEval'],       'easyhacks needsDevEval',    doBugzilla=True)
+    util_print_line(fp, statList['reportList']['needsUXEval'],        'easyhacks needsUXEval',     doBugzilla=True)
+    util_print_line(fp, statList['reportList']['too_many_comments'],  'easyhacks reduce comments', doBugzilla=True)
+    util_print_line(fp, statList['reportList']['pending_license'],    'pending license statement'  )
     fp.close()
-
-    del myStatList['missing_license']
-    del myStatList['needinfo']
-    del myStatList['easyhacks_new']
-    del myStatList['to_be_closed']
-    del myStatList['needsDevEval']
-    del myStatList['needsUXEval']
-    del myStatList['too_many_comments']
-    del myStatList['pending_license']
-
-    util_dump_file(cfg['homedir'] + 'automate.json', myStatList)
     return {'title': 'esc_mentoring, Daily work', 'mail': 'mentoring at documentfoundation.org', 'file': '/tmp/esc_day_mentoring_report.txt'}
 
 
 
 def report_mentoring():
     global statList, openhubData, gerritData, gitData, bugzillaData, cfg
-    myStatList = {'award_1st_email': [],
-                  'top10commit': [],
-                  'top10review': [],
-                  }
-    mailedDate = datetime.datetime.strptime(cfg['git']['last-mail-run'], '%Y-%m-%d') - datetime.timedelta(days=90)
-    zeroDate = datetime.datetime(year=2001, month=1, day=1)
-    for id, row in statList['people'].items():
-      entry = {'name': row['name'], 'email': id, 'license': row['licenseText']}
-      newestCommitDate = datetime.datetime.strptime(row['newestCommit'], '%Y-%m-%d')
-      x = row['commits']['1month']['owner']
-      if x != 0 and row['commits']['total'] == x and not id in cfg['award-mailed']:
-        myStatList['award_1st_email'].append(entry)
-
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['commits']['1month']['owner']),reverse=True)
-    for i in tmpClist:
-        if not statList['people'][i]['isCommitter']:
-            x = {'mail': i, 'name': statList['people'][i]['name'],
-                 'month': statList['people'][i]['commits']['1month']['owner'],
-                 'year': statList['people'][i]['commits']['1year']['owner']}
-            myStatList['top10commit'].append(x)
-            if len(myStatList['top10commit']) >= 10:
-                break
-    tmpRlist = sorted(statList['people'], key=lambda k: (statList['people'][k]['gerrit']['1month']['reviewer']),reverse=True)
-    for i in tmpRlist:
-        if i != 'ci at libreoffice.org':
-            x = {'mail': i, 'name': statList['people'][i]['name'],
-                 'month': statList['people'][i]['gerrit']['1month']['reviewer'],
-                 'year': statList['people'][i]['gerrit']['1year']['reviewer']}
-            myStatList['top10review'].append(x)
-            if len(myStatList['top10review']) >= 10:
-                break
 
     fp = open('/tmp/esc_mentoring_report.txt', 'w', encoding='utf-8')
     print("    + openhub statistics ({}), {} people did {} commits in 12 month in {} lines of code\n"
@@ -340,18 +186,18 @@ def report_mentoring():
     print("\n    + top 5 contributors:", file=fp)
     for i in range(0, 5):
       print('          {} made {} patches in 1 month, and {} patches in 1 year'.format(
-            myStatList['top10commit'][i]['name'],
-            myStatList['top10commit'][i]['month'],
-            myStatList['top10commit'][i]['year']), file=fp)
+          statList['reportList']['top10commit'][i]['name'],
+          statList['reportList']['top10commit'][i]['month'],
+          statList['reportList']['top10commit'][i]['year']), file=fp)
     print("    + top 5 reviewers:", file=fp)
     for i in range(0, 5):
       print('          {} made {} review comments in 1 month, and {} in 1 year'.format(
-            myStatList['top10review'][i]['name'],
-            myStatList['top10review'][i]['month'],
-            myStatList['top10review'][i]['year']), file=fp)
+          statList['reportList']['top10review'][i]['name'],
+          statList['reportList']['top10review'][i]['month'],
+          statList['reportList']['top10review'][i]['year']), file=fp)
 
     print("    + big CONGRATULATIONS to contributors who have at least 1 merged patch, since last report:", file=fp)
-    for row in myStatList['award_1st_email']:
+    for row in statList['reportList']['award_1st_email']:
         print('          {} {} {}'.format(row['name'],row['email'],row['license']), file=fp)
     fp.close()
     return
@@ -621,6 +467,7 @@ def report_bug_metrics():
     return {'title': data, 'mail': 'mentoring at documentfoundation.org', 'attach': filename, 'file' : '/tmp/esc_flatODF_body'}
 
 
+
 def report_ui():
     global statList, openhubData, gerritData, gitData, bugzillaData, cfg
     tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['ui']['1month']['history']+statList['people'][k]['ui']['1month']['commented']), reverse=True)
@@ -901,43 +748,50 @@ def runReport():
       x = report_bug_metrics()
       if not x is None:
         xMail.append(x)
-    except:
+    except Exception as e:
+      print('ERROR: report_bug_metrics failed with ' + str(e))
       pass
     try:
       x = report_day_mentoring()
       if not x is None:
         xMail.append(x)
-    except:
+    except Exception as e:
+      print('ERROR: report_day_mentoring failed with ' + str(e))
       pass
     try:
       x = report_mentoring()
       if not x is None:
         xMail.append(x)
-    except:
+    except Exception as e:
+      print('ERROR: report_mentoring failed with ' + str(e))
       pass
     try:
       x = report_ui()
       if not x is None:
         xMail.append(x)
-    except:
+    except Exception as e:
+      print('ERROR: report_ui failed with ' + str(e))
       pass
     try:
       x = report_qa()
       if not x is None:
         xMail.append(x)
-    except:
+    except Exception as e:
+      print('ERROR: report_qa failed with ' + str(e))
       pass
     try:
       x = report_myfunc()
       if not x is None:
         xMail.append(x)
-    except:
+    except Exception as e:
+      print('ERROR: report_myfunc failed with ' + str(e))
       pass
     try:
       x = report_esc_prototype()
       if not x is None:
         xMail.append(x)
-    except:
+    except Exception as e:
+      print('ERROR: report_esc_prototype failed with ' + str(e))
       pass
 
     fp = open('/tmp/runMail', 'w', encoding='utf-8')


More information about the Libreoffice-commits mailing list