LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / bin / compare-crashreport-stats.py
blob26db30c248850868afbcad4f98156f538ba19afc
1 #!/usr/bin/env python3
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # Use this script to compare the crashreport stats of two different versions of LibreOffice.
10 # Usage sample: ./compare-crashreport-stats.py --old 7.2.0.4 --new 7.2.1.2
12 import requests
13 from bs4 import BeautifulSoup
14 import argparse
15 import sys
17 def parse_url(url):
18 crashReports = {}
19 html_text = requests.get(url).text
20 soup = BeautifulSoup(html_text, 'html.parser')
22 table = soup.find("table", {"id": "data-table"}).tbody
23 for tr in table.find_all("tr"):
24 td_list = tr.find_all("td")
25 crashName = td_list[0].a.text.strip()
26 crashNumber = int(td_list[1].text.strip())
27 crashReports[crashName] = crashNumber
29 return crashReports
31 if __name__ == '__main__':
32 parser = argparse.ArgumentParser()
34 parser.add_argument('--old', action='store', dest="old", required=True)
35 parser.add_argument('--new', action="store", dest="new", required=True)
37 results = parser.parse_args()
39 oldVersion = parse_url(
40 "https://crashreport.libreoffice.org/stats/version/" + results.old + "?limit=1000&days=30")
41 newVersion = parse_url(
42 "https://crashreport.libreoffice.org/stats/version/" + results.new + "?limit=1000&days=30")
44 print(str(len(oldVersion)) + " crash reports in version " + results.old)
45 print(str(len(newVersion)) + " crash reports in version " + results.new)
46 print()
48 print("===== Fixed Reports =====")
49 fixedReports = set(oldVersion.keys()) - set(newVersion.keys())
50 for k, v in sorted(oldVersion.items(), key=lambda item: item[1], reverse=True):
51 # Ignore rare reports
52 if v >= 20 and k in fixedReports:
53 print(str(v) + " " + k)
55 print()
56 print("===== Newly introduced Reports =====")
57 newReports = set(newVersion.keys()) - set(oldVersion.keys())
58 for k, v in sorted(newVersion.items(), key=lambda item: item[1], reverse=True):
59 # Ignore rare reports
60 if v >= 20 and k in newReports:
61 print(str(v) + " " + k)
62 print()