aboutsummaryrefslogtreecommitdiff
path: root/python/ovh_helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/ovh_helper.py')
-rw-r--r--python/ovh_helper.py19
1 files changed, 19 insertions, 0 deletions
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 @@
1import time
2
3def show_progress(client, vps, task_type):
4 running_task_id = client.get("/vps/{}/tasks?type={}".format(vps, task_type))[0]
5
6 progress = 0
7 state = "todo"
8 print(" 0 %", end='')
9 while state != "done":
10 old_progress = progress
11 task = client.get("/vps/{}/tasks/{}".format(vps, running_task_id))
12 progress = task["progress"]
13 state = task["state"]
14
15 if progress != old_progress:
16 print("\r{:>3} %".format(progress), end="")
17 time.sleep(3)
18
19 print("\rFinished")