Created
February 4, 2012 10:49
-
-
Save lqc/1737050 to your computer and use it in GitHub Desktop.
Simple script to fetch patches from Django tracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import with_statement | |
from xmlrpclib import ServerProxy | |
import sys | |
USER = "" | |
PASS = "" | |
def get_number(prompt): | |
while True: | |
v = raw_input(prompt) | |
try: | |
v = int(v) | |
except Exception: | |
print "Invalid value" | |
continue | |
return v | |
if len(sys.argv) > 1: | |
tnum = int(sys.argv[1]) | |
else: | |
print "No ticket number given" | |
sys.exit(1) | |
p = ServerProxy('https://%s:%[email protected]/login/rpc' % (USER, PASS)) | |
attachments = p.ticket.listAttachments(tnum) | |
if not attachments: | |
print "No patched for ticket %d" % tnum | |
sys.exit(1) | |
print "Available patches:" | |
for i, (name, desc, _size, _time, author) in enumerate(attachments): | |
print "%d) %s by %s (%s)" % (i+1, name, author, desc) | |
selection = get_number("Choose a number (0 to abort):") | |
if not selection: | |
print "Aborted" | |
sys.exit(1) | |
name = attachments[int(selection)-1][0] | |
with open(name, "w+") as f: | |
data = p.ticket.getAttachment(tnum, name) | |
f.write(str(data)) | |
print "Patch downloaded as %r" % name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment