]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - python/ovh_helper.py
Add install scripts
[perso/Immae/Projets/Puppet.git] / python / ovh_helper.py
diff --git a/python/ovh_helper.py b/python/ovh_helper.py
new file mode 100644 (file)
index 0000000..a49a245
--- /dev/null
@@ -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")