aboutsummaryrefslogblamecommitdiff
path: root/python/ovh_helper.py
blob: a49a245ae7233e93a500bdbd844906de2f18599b (plain) (tree)


















                                                                                   
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")