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

jan Iversen jani at libreoffice.org
Sat May 6 16:47:48 UTC 2017


 esc-reporting/esc-analyze.py |   22 +++++++++++++++-------
 esc-reporting/esc-collect.py |    9 +++++++--
 2 files changed, 22 insertions(+), 9 deletions(-)

New commits:
commit fbce6e22f443bd9aae97df43bdbaf951eaa544ca
Author: jan Iversen <jani at libreoffice.org>
Date:   Sat May 6 18:45:32 2017 +0200

    esc-report, solved problem with openhub down

diff --git a/esc-reporting/esc-analyze.py b/esc-reporting/esc-analyze.py
index 2e93b6f..dd7a457 100755
--- a/esc-reporting/esc-analyze.py
+++ b/esc-reporting/esc-analyze.py
@@ -262,13 +262,21 @@ def analyze_mentoring():
     global cfg, statList, openhubData, bugzillaData, gerritData, gitData
 
     print("mentoring: analyze openhub", end="", flush=True)
-    statList['data']['openhub']['lines_of_code'] = int(openhubData['project']['analysis']['total_code_lines'])
-    statList['data']['openhub']['total_commits'] = int(openhubData['project']['analysis']['total_commit_count'])
-    statList['data']['openhub']['total_contributors'] = int(openhubData['project']['analysis']['total_contributor_count'])
-    statList['data']['openhub']['year_commits'] = int(openhubData['project']['analysis']['twelve_month_commit_count'])
-    statList['data']['openhub']['year_contributors'] = int(openhubData['project']['analysis']['twelve_month_contributor_count'])
-    xDate = datetime.datetime.strptime(openhubData['project']['analysis']['updated_at'], "%Y-%m-%dT%H:%M:%SZ")
-    statList['stat']['openhub_last_analyse'] = xDate.strftime('%Y-%m-%d')
+    if 'analysis' in openhubData['project']:
+      statList['data']['openhub']['lines_of_code'] = int(openhubData['project']['analysis']['total_code_lines'])
+      statList['data']['openhub']['total_commits'] = int(openhubData['project']['analysis']['total_commit_count'])
+      statList['data']['openhub']['total_contributors'] = int(openhubData['project']['analysis']['total_contributor_count'])
+      statList['data']['openhub']['year_commits'] = int(openhubData['project']['analysis']['twelve_month_commit_count'])
+      statList['data']['openhub']['year_contributors'] = int(openhubData['project']['analysis']['twelve_month_contributor_count'])
+      xDate = datetime.datetime.strptime(openhubData['project']['analysis']['updated_at'], "%Y-%m-%dT%H:%M:%SZ")
+      statList['stat']['openhub_last_analyse'] = xDate.strftime('%Y-%m-%d')
+    else:
+      statList['data']['openhub']['lines_of_code'] = -1
+      statList['data']['openhub']['total_commits'] = -1
+      statList['data']['openhub']['total_contributors'] = -1
+      statList['data']['openhub']['year_commits'] = -1
+      statList['data']['openhub']['year_contributors'] = -1
+      statList['stat']['openhub_last_analyse'] = '2001-01-01'
 
     print(" to " + statList['stat']['openhub_last_analyse'])
     print("mentoring: analyze gerrit", end="", flush=True)
commit ebad5bb8fd174741fb5a5e1b9648db3f86d01706
Author: jan Iversen <jani at libreoffice.org>
Date:   Sat May 6 18:38:45 2017 +0200

    esc-reporting, solved openhub down problem

diff --git a/esc-reporting/esc-collect.py b/esc-reporting/esc-collect.py
index 4541ed3..280ff21 100755
--- a/esc-reporting/esc-collect.py
+++ b/esc-reporting/esc-collect.py
@@ -59,8 +59,11 @@ def util_load_url(url, useDict=False, useRaw=False, uUser=None, uPass=None):
       if uUser is None:
         r = requests.get(url)
         if useDict:
-          x = r.text.replace('<br>', '').replace('<img.*>', '')
-          rawData = xmltodict.parse(x)
+          try:
+            rawData = xmltodict.parse(x)
+          except Exception as e:
+            rawData = {'response': {'result': {'project': {},
+                                    'contributor_fact': {}}}}
         elif useRaw:
           rawData = r.text
         else:
@@ -116,6 +119,8 @@ def get_openhub(cfg):
       idList = util_load_url(url + str(pageId), useDict=True)['response']['result']['contributor_fact']
       for row in idList:
         rawList['people'][row['contributor_id']] = row
+      if len(idList) == 0:
+        break
       xDate = datetime.datetime.strptime(idList[-1]['last_commit_time'], "%Y-%m-%dT%H:%M:%SZ")
       if xDate < searchDate:
         break


More information about the Libreoffice-commits mailing list