equal
deleted
inserted
replaced
224 jsurl = "http://pypi.python.org/pypi/%s/json" % name |
224 jsurl = "http://pypi.python.org/pypi/%s/json" % name |
225 else: |
225 else: |
226 jsurl = "http://%s/pypi/%s/json" % (host, name) |
226 jsurl = "http://%s/pypi/%s/json" % (host, name) |
227 |
227 |
228 try: |
228 try: |
229 f = urlopen(jsurl) |
229 # Don't wait very long for the connection |
|
230 f = urlopen(jsurl, None, 2) |
230 except HTTPError as e: |
231 except HTTPError as e: |
231 if e.getcode() == 404: |
232 if e.getcode() == 404: |
232 print "Unknown component '%s'" % name |
233 print "Unknown component '%s'" % name |
233 else: |
234 else: |
234 printIOError(e, "Can't open PyPI JSON url %s" % url) |
235 printIOError(e, "Can't open PyPI JSON url %s" % url) |
279 urls.remove(filename) |
280 urls.remove(filename) |
280 urls.insert(0, filename) |
281 urls.insert(0, filename) |
281 |
282 |
282 # command line url is a fallback, so it's last |
283 # command line url is a fallback, so it's last |
283 if url != None and url not in urls: |
284 if url != None and url not in urls: |
284 scheme, path = splittype(url) |
285 urls.append(url) |
285 if scheme == "pypi": |
|
286 url = pypi_url(url, filename) |
|
287 if url != None and url not in urls: |
|
288 urls.append(url) |
|
289 |
286 |
290 return urls |
287 return urls |
291 |
288 |
292 def download_from_paths(search_list, file_arg, url, timeout_arg, link_arg, quiet=False): |
289 def download_from_paths(search_list, file_arg, url, timeout_arg, link_arg, quiet=False): |
293 """Attempts to download a file from a number of possible locations. |
290 """Attempts to download a file from a number of possible locations. |
323 elif scheme in [ 'http', 'https', 'ftp' ]: |
320 elif scheme in [ 'http', 'https', 'ftp' ]: |
324 if not quiet: |
321 if not quiet: |
325 print "\n downloading...", |
322 print "\n downloading...", |
326 name = download(url, timeout_arg, file_arg, quiet) |
323 name = download(url, timeout_arg, file_arg, quiet) |
327 if name == None: |
324 if name == None: |
|
325 if not quiet: |
|
326 print "failed" |
|
327 continue |
|
328 elif scheme == "pypi": |
|
329 nurl = pypi_url(url, file_arg) |
|
330 if nurl: |
|
331 if not quiet: |
|
332 print "\n translated %s to %s..." % ( |
|
333 url, nurl), |
|
334 print "\n downloading...", |
|
335 else: |
|
336 if not quiet: |
|
337 print "\n unable to contact PyPI", |
|
338 continue |
|
339 name = download(nurl, timeout_arg, file_arg, quiet) |
|
340 if name is None: |
328 if not quiet: |
341 if not quiet: |
329 print "failed" |
342 print "failed" |
330 continue |
343 continue |
331 |
344 |
332 yield name |
345 yield name |