blob: a49a245ae7233e93a500bdbd844906de2f18599b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import time
def show_progress(client, vps, task_type):
running_task_id = client.get("/vps/{}/tasks?type={}".format(vps, task_type))[0]
progress = 0
state = "todo"
print(" 0 %", end='')
while state != "done":
old_progress = progress
task = client.get("/vps/{}/tasks/{}".format(vps, running_task_id))
progress = task["progress"]
state = task["state"]
if progress != old_progress:
print("\r{:>3} %".format(progress), end="")
time.sleep(3)
print("\rFinished")
|