mirror of
https://github.com/acedanger/shell.git
synced 2026-03-24 19:11:48 -07:00
feat: Update README and add requirements.txt for rich library installation instructions
This commit is contained in:
@@ -18,10 +18,11 @@ A Python command-line application to manage Docker containers defined in subdire
|
||||
|
||||
- Python 3
|
||||
- Docker and Docker Compose (plugin) installed.
|
||||
- The `rich` Python library:
|
||||
- Python dependencies:
|
||||
```bash
|
||||
pip install rich
|
||||
pip install -r ~/shell/docker-manager/requirements.txt
|
||||
```
|
||||
*Or manually:* `pip install rich`
|
||||
- A `~/docker/` directory containing subdirectories for each of your projects.
|
||||
- Each project subdirectory must contain a `docker-compose.yml`, `docker-compose.yaml`, `compose.yml`, or `compose.yaml` file.
|
||||
|
||||
|
||||
@@ -37,11 +37,17 @@ import argparse
|
||||
import subprocess
|
||||
import json
|
||||
from pathlib import Path
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from rich.panel import Panel
|
||||
from rich.text import Text
|
||||
from rich import box
|
||||
|
||||
try:
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from rich.panel import Panel
|
||||
from rich import box
|
||||
except ImportError:
|
||||
print("Error: The 'rich' library is required but not installed.")
|
||||
print("Please install it using: pip install -r ~/shell/docker-manager/requirements.txt")
|
||||
print("Or directly: pip install rich")
|
||||
exit(1)
|
||||
|
||||
# Configuration
|
||||
DOCKER_ROOT = Path(os.path.expanduser("~/docker"))
|
||||
@@ -261,15 +267,15 @@ def list_containers(projects):
|
||||
update_status = "[dim]Not Monitored[/dim]"
|
||||
|
||||
# If version is still unknown, try to get from running container labels
|
||||
if version == "latest" or version == "unknown":
|
||||
inspect_cmd = ["docker", "inspect", c_name, "--format", "{{json .Config.Labels}}"]
|
||||
inspect_res = run_command(inspect_cmd, path, capture_output=True)
|
||||
if inspect_res and inspect_res.returncode == 0:
|
||||
try:
|
||||
labels = json.loads(inspect_res.stdout)
|
||||
version = get_image_version(labels)
|
||||
except:
|
||||
pass
|
||||
if version in ("latest", "unknown"):
|
||||
inspect_cmd = ["docker", "inspect", c_name, "--format", "{{json .Config.Labels}}"]
|
||||
inspect_res = run_command(inspect_cmd, path, capture_output=True)
|
||||
if inspect_res and inspect_res.returncode == 0:
|
||||
try:
|
||||
labels = json.loads(inspect_res.stdout)
|
||||
version = get_image_version(labels)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
table.add_row(name, c_name, state, image, version, update_status)
|
||||
|
||||
@@ -367,7 +373,7 @@ def describe_project(projects, target):
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
else:
|
||||
console.print(Panel(table, title=f"[bold]{name}[/bold]", border_style="green"))
|
||||
console.print(Panel(table, title=f"[bold]{name}[/bold]", border_style="green"))
|
||||
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
1
docker-manager/requirements.txt
Normal file
1
docker-manager/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
rich>=13.0.0
|
||||
Reference in New Issue
Block a user