mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 16:11:15 +00:00
ported grab-attachment from launchpadbugs to launchpadlib
This commit is contained in:
parent
920971eaa7
commit
2e367cdeee
@ -20,8 +20,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import urllib
|
from common import get_launchpad
|
||||||
import launchpadbugs.connector as Connector
|
|
||||||
|
|
||||||
USAGE = "grab-attachments <bug numbers>"
|
USAGE = "grab-attachments <bug numbers>"
|
||||||
|
|
||||||
@ -33,17 +32,21 @@ def main():
|
|||||||
if sys.argv[1] in ["--help", "-h"]:
|
if sys.argv[1] in ["--help", "-h"]:
|
||||||
print USAGE
|
print USAGE
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
Bug = Connector.ConnectBug(method="Text")
|
launchpad = get_launchpad("ubuntu-dev-tools")
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
try:
|
try:
|
||||||
number = int(arg)
|
number = int(arg)
|
||||||
except:
|
except:
|
||||||
print >> sys.stderr, "'%s' is not a valid bug number." % arg
|
print >> sys.stderr, "'%s' is not a valid bug number." % arg
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
b = Bug(number)
|
b = launchpad.bugs[number]
|
||||||
for a in b.attachments:
|
for a in b.attachments:
|
||||||
filename = os.path.join(os.getcwd(), a.url.split("/")[-1])
|
f = a.data.open()
|
||||||
urllib.urlretrieve(a.url, filename)
|
filename = os.path.join(os.getcwd(), f.filename)
|
||||||
|
local_file = open(filename, "w")
|
||||||
|
local_file.write(f.read())
|
||||||
|
f.close()
|
||||||
|
local_file.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user