mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
62 lines
1.7 KiB
Python
Executable File
62 lines
1.7 KiB
Python
Executable File
#!/usr/bin/python
|
|
#
|
|
# Copyright (C) 2007, Canonical Ltd.
|
|
# Written by Daniel Holbach
|
|
#
|
|
# ##################################################################
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation; version 3.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# See file /usr/share/common-licenses/GPL-3 for more details.
|
|
#
|
|
# ##################################################################
|
|
|
|
from optparse import OptionParser
|
|
import os
|
|
import sys
|
|
|
|
from ubuntutools.lp.libsupport import get_launchpad
|
|
|
|
USAGE = "grab-attachments <bug numbers>"
|
|
|
|
def main():
|
|
p = OptionParser('Usage: %prog [options] <bug numbers>')
|
|
opts, args = p.parse_args()
|
|
if len(args) < 1:
|
|
p.error('No bug numbers provided')
|
|
|
|
try:
|
|
launchpad = get_launchpad("ubuntu-dev-tools")
|
|
|
|
for arg in args:
|
|
try:
|
|
number = int(arg)
|
|
except:
|
|
p.error("'%s' is not a valid bug number." % arg)
|
|
|
|
b = launchpad.bugs[number]
|
|
|
|
for a in b.attachments:
|
|
f = a.data.open()
|
|
filename = os.path.join(os.getcwd(), f.filename)
|
|
local_file = open(filename, "w")
|
|
local_file.write(f.read())
|
|
f.close()
|
|
local_file.close()
|
|
|
|
# no LP credentials
|
|
except IOError, e:
|
|
print e
|
|
sys.exit(1)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|