-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from cased/rick/cas-1697-branch-deploy-from-cli…
…-commands Call to get actual data
- Loading branch information
Showing
7 changed files
with
163 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# .gitignore | ||
_pycache_/ | ||
__pycache__/ | ||
.egg-info/ | ||
env/ | ||
.env/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import time | ||
from rich.console import Console | ||
from rich.progress import Progress | ||
from concurrent.futures import ThreadPoolExecutor, TimeoutError | ||
from typing import Callable, Any | ||
|
||
|
||
def run_process_with_status_bar( | ||
process_func: Callable[[], Any], | ||
description: str = "Processing...", | ||
timeout: int = 10, | ||
*args, | ||
**kwargs, | ||
) -> Any: | ||
console = Console() | ||
result = None | ||
|
||
def update_progress(progress, task): | ||
start_time = time.time() | ||
while time.time() - start_time < timeout: | ||
elapsed = int(time.time() - start_time) | ||
progress.update(task, completed=min(elapsed, timeout)) | ||
time.sleep(1) # Update every second | ||
|
||
with Progress() as progress: | ||
task = progress.add_task(f"[green]{description}", total=timeout) | ||
|
||
with ThreadPoolExecutor(max_workers=2) as executor: | ||
# Submit the main process | ||
future = executor.submit(process_func, *args, **kwargs) | ||
start_time = time.time() | ||
while not future.done() and time.time() - start_time < timeout: | ||
elapsed = int(time.time() - start_time) | ||
progress.update(task, completed=min(elapsed, timeout)) | ||
time.sleep(0.1) # Update frequently for responsiveness | ||
|
||
try: | ||
result = future.result(timeout=timeout) | ||
progress.update( | ||
task, completed=timeout, description="[bold green]Done!" | ||
) | ||
except TimeoutError: | ||
progress.update(task, description="[bold red]Timeout!") | ||
console.print( | ||
f"\n[bold red]Process timed out after {timeout} seconds. Please try again later." | ||
) | ||
except Exception as e: | ||
progress.update(task, description="[bold red]Error!") | ||
console.print(f"\n[bold red]Error: {e}") | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
click==8.1.3 | ||
rich==13.3.5 | ||
questionary==1.10.0 | ||
python-dateutil==2.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
"requests", | ||
"rich", | ||
"questionary", | ||
"python-dateutil", | ||
], | ||
entry_points={ | ||
"console_scripts": [ | ||
|