request-vm-on-golem 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- request_vm_on_golem-0.1.0.dist-info/METADATA +296 -0
- request_vm_on_golem-0.1.0.dist-info/RECORD +18 -0
- request_vm_on_golem-0.1.0.dist-info/WHEEL +4 -0
- request_vm_on_golem-0.1.0.dist-info/entry_points.txt +3 -0
- requestor/__init__.py +7 -0
- requestor/cli/__init__.py +1 -0
- requestor/cli/commands.py +642 -0
- requestor/config.py +67 -0
- requestor/db/__init__.py +5 -0
- requestor/db/sqlite.py +120 -0
- requestor/errors.py +29 -0
- requestor/provider/__init__.py +5 -0
- requestor/provider/client.py +94 -0
- requestor/run.py +51 -0
- requestor/ssh/__init__.py +4 -0
- requestor/ssh/manager.py +161 -0
- requestor/utils/logging.py +109 -0
- requestor/utils/spinner.py +72 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
import sys
|
2
|
+
import threading
|
3
|
+
import time
|
4
|
+
import itertools
|
5
|
+
|
6
|
+
class Spinner:
|
7
|
+
"""A simple spinner class for CLI progress indication."""
|
8
|
+
def __init__(self, message="", delay=0.1):
|
9
|
+
self.spinner = itertools.cycle(['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'])
|
10
|
+
self.delay = delay
|
11
|
+
self.busy = False
|
12
|
+
self.spinner_visible = False
|
13
|
+
self.message = message
|
14
|
+
sys.stdout.write('\033[?25l') # Hide cursor
|
15
|
+
|
16
|
+
def write_next(self):
|
17
|
+
"""Write the next spinner frame."""
|
18
|
+
with self._screen_lock:
|
19
|
+
if not self.spinner_visible:
|
20
|
+
sys.stdout.write(f"\r{next(self.spinner)} {self.message}")
|
21
|
+
self.spinner_visible = True
|
22
|
+
sys.stdout.flush()
|
23
|
+
|
24
|
+
def remove_spinner(self, cleanup=False):
|
25
|
+
"""Remove the spinner from the terminal."""
|
26
|
+
with self._screen_lock:
|
27
|
+
if self.spinner_visible:
|
28
|
+
sys.stdout.write('\r')
|
29
|
+
sys.stdout.write(' ' * (len(self.message) + 2))
|
30
|
+
sys.stdout.write('\r')
|
31
|
+
if cleanup:
|
32
|
+
sys.stdout.write('\033[?25h') # Show cursor
|
33
|
+
sys.stdout.flush()
|
34
|
+
self.spinner_visible = False
|
35
|
+
|
36
|
+
def spinner_task(self):
|
37
|
+
"""Animate the spinner."""
|
38
|
+
while self.busy:
|
39
|
+
self.write_next()
|
40
|
+
time.sleep(self.delay)
|
41
|
+
self.remove_spinner()
|
42
|
+
|
43
|
+
def __enter__(self):
|
44
|
+
"""Start the spinner."""
|
45
|
+
self._screen_lock = threading.Lock()
|
46
|
+
self.busy = True
|
47
|
+
self.thread = threading.Thread(target=self.spinner_task)
|
48
|
+
self.thread.daemon = True
|
49
|
+
self.thread.start()
|
50
|
+
return self
|
51
|
+
|
52
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
53
|
+
"""Stop the spinner and show completion."""
|
54
|
+
self.busy = False
|
55
|
+
time.sleep(self.delay)
|
56
|
+
self.remove_spinner(cleanup=True)
|
57
|
+
if exc_type is None:
|
58
|
+
# Show checkmark on success
|
59
|
+
sys.stdout.write(f"\r✓ {self.message}\n")
|
60
|
+
else:
|
61
|
+
# Show X on failure
|
62
|
+
sys.stdout.write(f"\r✗ {self.message}\n")
|
63
|
+
sys.stdout.flush()
|
64
|
+
|
65
|
+
def step(message):
|
66
|
+
"""Decorator to add a spinning progress indicator to a function."""
|
67
|
+
def decorator(func):
|
68
|
+
async def wrapper(*args, **kwargs):
|
69
|
+
with Spinner(message):
|
70
|
+
return await func(*args, **kwargs)
|
71
|
+
return wrapper
|
72
|
+
return decorator
|