Mercurial > p > roundup > code
diff scripts/import_sf.py @ 3537:d819ff1b3116
*** empty log message ***
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 03 Feb 2006 05:09:33 +0000 |
| parents | 00a7983b4666 |
| children | 7f7902af7864 |
line wrap: on
line diff
--- a/scripts/import_sf.py Fri Feb 03 04:12:36 2006 +0000 +++ b/scripts/import_sf.py Fri Feb 03 05:09:33 2006 +0000 @@ -21,11 +21,13 @@ And you're done! ''' -import sys, sets, os, csv, time, urllib2, httplib, mimetypes +import sys, sets, os, csv, time, urllib2, httplib, mimetypes, urlparse from elementtree import ElementTree from roundup import instance, hyperdb, date, support, password +DL_URL = 'http://sourceforge.net/tracker/download.php?group_id=%(group_id)s&atid=%(atid)s&aid=%(aid)s' + def get_url(aid): """ so basically we have to jump through hoops, given an artifact id, to figure what the URL should be to access that artifact, and hence any @@ -34,7 +36,10 @@ conn.request("GET", "/support/tracker.php?aid=%s"%aid) response = conn.getresponse() assert response.status == 302, 'response code was %s'%response.status - return 'http://sourceforge.net' + response.getheader('location') + location = response.getheader('location') + query = urlparse.urlparse(response.getheader('location'))[-2] + info = dict([param.split('=') for param in query.split('&')]) + return DOWNLOAD_TEMPLATE%info def fetch_files(xml_file, file_dir): """ Fetch files referenced in the xml_file into the dir file_dir. """
