-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
43 lines (32 loc) · 799 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from loguru import logger
from halo import Halo
import time
# Initialize the logger
logger.remove()
logger.add("app.log", format="{time} {level} {message}", level="INFO", diagnose=False)
plan = [
'step 1',
'step 2',
'step 3'
]
def execute_step(step: str):
time.sleep(2)
if step == 'step 3':
return False
return True
for i, step in enumerate(plan, start=1):
# Initialize the spinner
spinner = Halo(text=step, spinner='dots')
spinner.start()
try:
result = execute_step(step)
if result:
spinner.succeed(step)
logger.info(step)
else:
spinner.fail(step)
logger.error(step)
except Exception as e:
spinner.fail(step)
logger.error(step)
spinner.stop()