Last active
November 12, 2021 02:01
-
-
Save matthewpoer/10183d4ac7b75e8bf0fc48a8c7d0a759 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
barList = ["|","/","-","\\"] | |
barListIter = iter(barList) | |
ten_seconds_away = int(time.time()) + 10 | |
while int(time.time()) < ten_seconds_away: | |
remaining = ten_seconds_away - int(time.time()) | |
bar = next(barListIter, None) | |
if not bar: | |
barListIter = iter(barList) | |
bar = next(barListIter) | |
message=f"{bar} {remaining} seconds remaining".ljust(80) | |
print(message, end='\r', flush=True) | |
time.sleep(.25) | |
print(message, flush=True) | |
print("Job complete") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related: https://gist.github.com/matthewpoer/65eff844150cc8b51537010ec12cad64