Skip to content

Instantly share code, notes, and snippets.

@moshekaplan
Created August 11, 2020 02:39
Show Gist options
  • Save moshekaplan/ec1b56a13e02cda8e5e2edb463a0ed67 to your computer and use it in GitHub Desktop.
Save moshekaplan/ec1b56a13e02cda8e5e2edb463a0ed67 to your computer and use it in GitHub Desktop.
# Download launchpad bugs
import sys
import subprocess
import requests
from launchpadlib.launchpad import Launchpad
cachedir = '.'
launchpad = Launchpad.login_anonymously('just testing', 'production', cachedir, version='devel')
project = launchpad.projects['ubuntu/+source/imagemagick']
# list out all types to get all bugs
bugs = project.searchTasks(status = ['New', 'Opinion', 'Invalid', 'Won\'t Fix', 'Expired', 'Confirmed', 'Triaged', 'In Progress', 'Fix Committed', 'Fix Released', 'Incomplete (with response)', 'Incomplete (without response)'])
print (len(bugs))
for bug in bugs:
# Beyond ugly approach
bug_id=bug.bug_link.rsplit('/',1)[1]
myj = requests.get(f"https://api.launchpad.net/1.0/bugs/{bug_id}/attachments").json()
i = 0
for attachment in myj['entries']:
data_link_url = attachment['data_link']
r = requests.get(data_link_url)
with open(f'bug_id_{bug_id}_{i}', 'wb') as fh:
fh.write(r.content)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment