From 853f0275a6a4ff175cfdd419b181304927cfcf71 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Thu, 8 Apr 2010 09:55:27 -0500 Subject: [PATCH] Update get-branches to account for changes in LP's web UI. Really, someone should update it to use the LP API, but for now, this will have to do. --- get-branches | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/get-branches b/get-branches index c7bc798..68dde7e 100755 --- a/get-branches +++ b/get-branches @@ -38,7 +38,7 @@ def main(): # Our options. optParser.add_option("-d", "--directory", action = "store", type = "string", - dest = "directory", default = ".", + dest = "directory", default = os.getcwd(), help = "Directory to download branches to.") optParser.add_option("-t", "--team", action = "store", type = "string", dest = "lpteam", help = "Launchpad team to download branches from.") @@ -92,7 +92,7 @@ def main(): branch_list_page = sock.read() sock.close() - branch_page_urls_regex = r'.*lp:.*' % team branch_page_urls = re.findall(branch_page_urls_regex, branch_list_page) # Check the team actually has branches. @@ -114,25 +114,28 @@ def main(): sock = urllib2.urlopen("https://code.launchpad.net/%s" % url) branch_page = sock.read() sock.close() - - branch_url_regex = r'bzr branch lp:~(.*)' + + branch_url_regex = r'
bzr branch lp:(.*)
' branch_url = re.findall(branch_url_regex, branch_page) - print "Downloading branch: lp:~%s." % branch_url[0] if branch_url[0]: - product = branch_url[0].split("/")[-2] - branch_nick = branch_url[0].split("/")[-1] + print "Downloading branch: lp:%s (%s)." % (branch_url[0], url) + product = url.split("/")[-2] + branch_nick = url.split("/")[-1] + else: + continue - if not os.path.exists(product): - os.makedirs(product) - os.chdir(product) + print branch_nick, product, os.getcwd() + if not os.path.exists(product): + os.makedirs(product) + os.chdir(product) if not os.path.exists(branch_nick): - subprocess.call(["bzr", operation_type, "lp:~%s" % branch_url[0]]) + subprocess.call(["bzr", operation_type, "lp:%s" % url]) else: os.chdir(branch_nick) subprocess.call(["bzr", "merge", "--pull", "--remember"]) - os.chdir(os.path.join(directory, team)) + os.chdir(os.path.join(directory, team)) os.chdir(pwd) sys.exit(0)