| 145 | assert False, "Don't know how to extract " + file |
| 146 | |
| 147 | def progress_bar(label, count, total, url, width=40): |
| 148 | is_tty = sys.stdout.isatty() |
| 149 | if is_tty: |
| 150 | percent = count / total if total else 0 |
| 151 | filled = int(width * percent) |
| 152 | bar = '[%s%s]' % ('#' * filled, '.' * (width - filled)) |
| 153 | done = total and count >= total |
| 154 | suffix = " ✅" if done else "" |
| 155 | sys.stdout.write(f"\r{label} {bar} {percent:6.2%}{suffix}") |
| 156 | sys.stdout.flush() |
| 157 | if done: |
| 158 | sys.stdout.write("\n") |
| 159 | sys.stdout.flush() |
| 160 | else: |
| 161 | log('Downloading %s %.2f%%' % (url, 100 * count / float(total))) |
| 162 | |
| 163 | def download(label, url): |
| 164 | label = 'Downloading %s...' % label |