Mercurial > hg > graal-compiler
diff mxtool/mx.py @ 4188:148fa38782e8
Downloads are attempted via Java first since it shows a progress counter.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 03 Jan 2012 15:49:22 +0100 |
parents | 71a2cd79c375 |
children | a2caa019ba3a |
line wrap: on
line diff
--- a/mxtool/mx.py Tue Jan 03 13:54:11 2012 +0100 +++ b/mxtool/mx.py Tue Jan 03 15:49:22 2012 +0100 @@ -710,6 +710,16 @@ if d != '' and not exists(d): os.makedirs(d) + # Try it with the Java tool first since it can show a progress counter + myDir = dirname(__file__) + + javaSource = join(myDir, 'URLConnectionDownload.java') + javaClass = join(myDir, 'URLConnectionDownload.class') + if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): + subprocess.check_call([java().javac, '-d', myDir, javaSource]) + if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls) == 0: + return + def url_open(url): userAgent = 'Mozilla/5.0 (compatible)' headers = { 'User-Agent' : userAgent } @@ -744,17 +754,9 @@ except zipfile.BadZipfile as e: log('Error in zip file downloaded from ' + url + ': ' + str(e)) - # now try it with Java - urllib2 does not handle meta refreshes which are used by Sourceforge - myDir = dirname(__file__) - - javaSource = join(myDir, 'URLConnectionDownload.java') - javaClass = join(myDir, 'URLConnectionDownload.class') - if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): - subprocess.check_call([java().javac, '-d', myDir, javaSource]) - if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls) != 0: - abort('Could not download to ' + path + ' from any of the following URLs:\n\n ' + - '\n '.join(urls) + '\n\nPlease use a web browser to do the download manually') - + abort('Could not download to ' + path + ' from any of the following URLs:\n\n ' + + '\n '.join(urls) + '\n\nPlease use a web browser to do the download manually') + def update_file(path, content): """ Updates a file with some given content if the content differs from what's in