use unix paths for dir tests and prefer PathFormat…
[LibreOffice.git] / bin / compare-crashreport-stats.py
blob437b047eadcfda9fff40327f1153d1f23e863e89
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
16 def parse_url(url):
17 crashReports = {}
18 html_text = requests.get(url).text
19 soup = BeautifulSoup(html_text, 'html.parser')
21 table = soup.find("table", {"id": "data-table"}).tbody
22 for tr in table.find_all("tr"):
23 td_list = tr.find_all("td")
24 crashName = td_list[0].a.text.strip()
25 crashNumber = int(td_list[1].text.strip())
26 crashReports[crashName] = crashNumber
28 return crashReports
30 if __name__ == '__main__':
31 parser = argparse.ArgumentParser()
33 parser.add_argument('--old', action='store', dest="old", required=True)
34 parser.add_argument('--new', action="store", dest="new", required=True)
36 results = parser.parse_args()
38 oldVersion = parse_url(
39 "https://crashreport.libreoffice.org/stats/version/" + results.old + "?limit=1000&days=30")
40 newVersion = parse_url(
41 "https://crashreport.libreoffice.org/stats/version/" + results.new + "?limit=1000&days=30")
43 print(str(len(oldVersion)) + " crash reports in version " + results.old)
44 print(str(len(newVersion)) + " crash reports in version " + results.new)
45 print()
47 print("===== Fixed Reports =====")
48 fixedReports = set(oldVersion.keys()) - set(newVersion.keys())
49 for k, v in sorted(oldVersion.items(), key=lambda item: item[1], reverse=True):
50 # Ignore rare reports
51 if v >= 20 and k in fixedReports:
52 print(str(v) + " " + k)
54 print()
55 print("===== Newly introduced Reports =====")
56 newReports = set(newVersion.keys()) - set(oldVersion.keys())
57 for k, v in sorted(newVersion.items(), key=lambda item: item[1], reverse=True):
58 # Ignore rare reports
59 if v >= 20 and k in newReports:
60 print(str(v) + " " + k)
61 print()