diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-05-23 13:14:55 +0200 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-05-23 13:14:55 +0200 |
| commit | fac715cd71675861766732fb84741e4e25c6995b (patch) | |
| tree | 55c660d01943446a477cfdeae8df2e443a0d0a2b /mailinglist | |
| parent | 3659cb789577fd6fa18487744a289b764889ba6b (diff) | |
| download | emulator-bug-study-fac715cd71675861766732fb84741e4e25c6995b.tar.gz emulator-bug-study-fac715cd71675861766732fb84741e4e25c6995b.zip | |
check json for launchpad bugs
Diffstat (limited to 'mailinglist')
| -rwxr-xr-x | mailinglist/downloader.py | 3 | ||||
| -rwxr-xr-x | mailinglist/launchpad.py | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/mailinglist/downloader.py b/mailinglist/downloader.py index 0b8a4277..38d37305 100755 --- a/mailinglist/downloader.py +++ b/mailinglist/downloader.py @@ -55,7 +55,8 @@ def main(): re_match = search(r'\[Bug\s(\d+)\]', text) # matches [Bug <number>] if bug is issued in launchpad if re_match: - process_launchpad_bug(re_match.group(1).strip()) + if not process_launchpad_bug(re_match.group(1).strip()): + print(f"Could not parse launchpad bug with id: {re_match.group(1).strip()}") continue re_match = match(r'(?i)^re:\s*(.*)', text) # matches 'Re:', meaning it's not a new thread diff --git a/mailinglist/launchpad.py b/mailinglist/launchpad.py index 91d6cd8b..a5a57d7c 100755 --- a/mailinglist/launchpad.py +++ b/mailinglist/launchpad.py @@ -1,14 +1,17 @@ from requests import get from os import makedirs, path -def process_launchpad_bug(bug_id): +def process_launchpad_bug(bug_id) -> bool: if path.exists(f"output_launchpad/{bug_id}"): - return + return false bug_url = f"https://api.launchpad.net/1.0/bugs/{bug_id}" bug_response = get(url = bug_url) + if not 'application/json' in bug_response.headers.get('Content-Type', ''): + return false + bug_data = bug_response.json() messages_response = get(url = bug_data['messages_collection_link']) @@ -21,7 +24,4 @@ def process_launchpad_bug(bug_id): for entry in messages_data['entries']: file.write(f"{entry['content']}\n\n") - -if __name__ == "__main__": - process_launchpad_bug(1629282) - process_launchpad_bug(1915063) + return true |