(name, urlString, tmpDir, quiet=False, force_clean=True)
| 183 | |
| 184 | |
| 185 | def download(name, urlString, tmpDir, quiet=False, force_clean=True): |
| 186 | if not quiet: |
| 187 | print("Downloading %s" % urlString) |
| 188 | startTime = time.time() |
| 189 | fileName = '%s/%s' % (tmpDir, name) |
| 190 | if not force_clean and os.path.exists(fileName): |
| 191 | if not quiet and fileName.find('.asc') == -1: |
| 192 | print(' already done: %.1f MB' % (os.path.getsize(fileName)/1024./1024.)) |
| 193 | return |
| 194 | try: |
| 195 | attemptDownload(urlString, fileName) |
| 196 | except Exception as e: |
| 197 | print('Retrying download of url %s after exception: %s' % (urlString, e)) |
| 198 | try: |
| 199 | attemptDownload(urlString, fileName) |
| 200 | except Exception as e: |
| 201 | raise RuntimeError('failed to download url "%s"' % urlString) from e |
| 202 | if not quiet and fileName.find('.asc') == -1: |
| 203 | t = time.time()-startTime |
| 204 | sizeMB = os.path.getsize(fileName)/1024./1024. |
| 205 | print(' %.1f MB in %.2f sec (%.1f MB/sec)' % (sizeMB, t, sizeMB/t)) |
| 206 | |
| 207 | |
| 208 | def attemptDownload(urlString, fileName): |
no test coverage detected
searching dependent graphs…