diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-06-16 13:16:13 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-06-16 13:26:36 +0200 |
commit | 970f03cb9ed68d249fe04cff7d4aa15b0f2c6c35 (patch) | |
tree | 06d7e4307c1b917d3df2d3cb037a403e1f5eb78e /bin | |
parent | fcdfd309345afaf88fac587e837e51e741c60400 (diff) |
crashreportScraper: use argparse to parse the arguments
Change-Id: Idc1d32683c5113042fe4e7ec97357b6d76c5217e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135973
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/crashreportScraper.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/crashreportScraper.py b/bin/crashreportScraper.py index aec3e5e9cffb..513f5ec7b75d 100755 --- a/bin/crashreportScraper.py +++ b/bin/crashreportScraper.py @@ -8,8 +8,9 @@ # Use this script to retrieve information from https://crashreport.libreoffice.org # about a specific version of LibreOffice -# Usage sample: ./crashreportScraper.py 7.2.0.4 +# Usage sample: ./crashreportScraper.py --version 7.2.0.4 --repository /path/to/libreoffice/repository/ +import argparse import requests from bs4 import BeautifulSoup import sys @@ -160,17 +161,20 @@ def parse_details_and_get_info(url, gitRepo): if __name__ == '__main__': - version = sys.argv[1] + parser = argparse.ArgumentParser() - crashes = parse_version_url( - "https://crashreport.libreoffice.org/stats/version/" + version + "?limit=1000&days=30") + parser.add_argument('--version', action='store', dest="version", required=True) + parser.add_argument('--repository', action="store", dest="repository", required=True) + + args = parser.parse_args() - gitRepo = os.path.dirname(os.path.realpath(__file__)) + "/../" + crashes = parse_version_url( + "https://crashreport.libreoffice.org/stats/version/" + args.version + "?limit=1000&days=30") - print(str(len(crashes)) + " crash reports in version " + version) + print(str(len(crashes)) + " crash reports in version " + args.version) crashesInFile = [] - fileName = "crashes_" + version.replace(".", "_") + ".csv" + fileName = "crashes_" + args.version.replace(".", "_") + ".csv" print("Using " + fileName) bInsertHeader = False @@ -196,7 +200,7 @@ if __name__ == '__main__': crashCount, crashID, crashVersion, crashOS = parse_reports_and_get_most_recent_report_from_last_page( "https://crashreport.libreoffice.org/stats/signature/" + k) crashReason, crashStack, codeLine = parse_details_and_get_info( - "https://crashreport.libreoffice.org/stats/crash_details/" + crashID, gitRepo) + "https://crashreport.libreoffice.org/stats/crash_details/" + crashID, args.repository) line = '\t'.join([k, str(crashCount), lDate[1], lDate[2], crashID, crashVersion, crashReason, crashOS, crashStack, codeLine, '\n']) f.write(line) |