X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=python%2Fovh_helper.py;fp=python%2Fovh_helper.py;h=a49a245ae7233e93a500bdbd844906de2f18599b;hb=ec1096d8c0d897ebd1ea445d9c5404a13c33ce2e;hp=0000000000000000000000000000000000000000;hpb=548061112d2e2627317f9379d2f501fcf3f6ea54;p=perso%2FImmae%2FProjets%2FPuppet.git diff --git a/python/ovh_helper.py b/python/ovh_helper.py new file mode 100644 index 0000000..a49a245 --- /dev/null +++ b/python/ovh_helper.py @@ -0,0 +1,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")