toolforge-components-cli 0.0.3__py3-none-any.whl → 0.0.5__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.
- toolforge_components_cli/cli.py +69 -12
- {toolforge_components_cli-0.0.3.dist-info → toolforge_components_cli-0.0.5.dist-info}/METADATA +1 -1
- toolforge_components_cli-0.0.5.dist-info/RECORD +9 -0
- {toolforge_components_cli-0.0.3.dist-info → toolforge_components_cli-0.0.5.dist-info}/WHEEL +1 -1
- toolforge_components_cli-0.0.3.dist-info/RECORD +0 -9
- {toolforge_components_cli-0.0.3.dist-info → toolforge_components_cli-0.0.5.dist-info}/LICENSE +0 -0
- {toolforge_components_cli-0.0.3.dist-info → toolforge_components_cli-0.0.5.dist-info}/entry_points.txt +0 -0
toolforge_components_cli/cli.py
CHANGED
|
@@ -6,9 +6,12 @@ import logging
|
|
|
6
6
|
import os
|
|
7
7
|
import subprocess
|
|
8
8
|
import sys
|
|
9
|
+
from textwrap import indent
|
|
10
|
+
from typing import Any
|
|
9
11
|
|
|
10
12
|
import click
|
|
11
13
|
import yaml
|
|
14
|
+
from tabulate import tabulate
|
|
12
15
|
from toolforge_weld.errors import (
|
|
13
16
|
ToolforgeError,
|
|
14
17
|
ToolforgeUserError,
|
|
@@ -88,12 +91,29 @@ def _display_deployment(deployment_data: dict, as_json: bool, prefix: str = "")
|
|
|
88
91
|
else:
|
|
89
92
|
if prefix:
|
|
90
93
|
click.echo(prefix)
|
|
91
|
-
click.echo(
|
|
92
|
-
|
|
94
|
+
click.echo(
|
|
95
|
+
click.style("Deployment ID: ", bold=True) + deployment_data["deploy_id"]
|
|
96
|
+
)
|
|
97
|
+
click.echo(
|
|
98
|
+
click.style("Created: ", bold=True) + deployment_data["creation_time"]
|
|
99
|
+
)
|
|
100
|
+
click.echo(
|
|
101
|
+
click.style("Status: ", bold=True)
|
|
102
|
+
+ _format_status(deployment_data.get("status", "unknown"))
|
|
103
|
+
)
|
|
104
|
+
click.echo(
|
|
105
|
+
click.style("Long status: ", bold=True)
|
|
106
|
+
+ "\n"
|
|
107
|
+
+ indent(text=deployment_data.get("long_status", "unknown"), prefix=" ")
|
|
108
|
+
)
|
|
93
109
|
if deployment_data.get("builds"):
|
|
94
|
-
click.echo(
|
|
110
|
+
click.echo(
|
|
111
|
+
"\n" + click.style("Builds:" if not prefix else "Builds:", bold=True)
|
|
112
|
+
)
|
|
95
113
|
for component, build in deployment_data["builds"].items():
|
|
96
|
-
click.echo(
|
|
114
|
+
click.echo(
|
|
115
|
+
f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
|
|
116
|
+
)
|
|
97
117
|
|
|
98
118
|
|
|
99
119
|
@click.version_option(prog_name="Toolforge Components CLI")
|
|
@@ -349,7 +369,35 @@ def deployment_create(ctx, as_json: bool) -> None:
|
|
|
349
369
|
if deployment_data.get("builds"):
|
|
350
370
|
click.echo("\nBuilds:")
|
|
351
371
|
for component, build in deployment_data["builds"].items():
|
|
352
|
-
click.echo(
|
|
372
|
+
click.echo(
|
|
373
|
+
f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def _format_headers(headers: list[str]) -> list[str]:
|
|
378
|
+
return [click.style(item, bold=True) for item in headers]
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def _format_builds(builds: dict[str, dict[str, Any]]) -> str:
|
|
382
|
+
builds_strings: list[str] = []
|
|
383
|
+
for component_name, build_info in builds.items():
|
|
384
|
+
builds_strings.append(
|
|
385
|
+
f"{component_name}({_format_status(build_info['build_status'])}): {build_info['build_id']}"
|
|
386
|
+
)
|
|
387
|
+
return "\n".join(builds_strings)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def _format_status(status: str) -> str:
|
|
391
|
+
fg_color = "yellow"
|
|
392
|
+
|
|
393
|
+
if status in ("running", "pending"):
|
|
394
|
+
fg_color = "white"
|
|
395
|
+
elif status == "failed":
|
|
396
|
+
fg_color = "red"
|
|
397
|
+
elif status == "successful":
|
|
398
|
+
fg_color = "green"
|
|
399
|
+
|
|
400
|
+
return click.style(status, fg=fg_color)
|
|
353
401
|
|
|
354
402
|
|
|
355
403
|
@deployment.command(name="list", help="List all deployments.")
|
|
@@ -371,13 +419,21 @@ def deployment_list(ctx, as_json: bool) -> None:
|
|
|
371
419
|
return
|
|
372
420
|
|
|
373
421
|
deployments = response.get("data", {}).get("deployments", [])
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
422
|
+
formatted_deployments = [
|
|
423
|
+
[
|
|
424
|
+
deployment["deploy_id"],
|
|
425
|
+
deployment["creation_time"],
|
|
426
|
+
_format_status(deployment.get("status", "unknown")),
|
|
427
|
+
_format_builds(deployment.get("builds", [])),
|
|
428
|
+
]
|
|
429
|
+
for deployment in deployments
|
|
430
|
+
]
|
|
431
|
+
click.echo(
|
|
432
|
+
tabulate(
|
|
433
|
+
formatted_deployments,
|
|
434
|
+
headers=_format_headers(["ID", "Creation time", "Status", "Builds"]),
|
|
435
|
+
)
|
|
436
|
+
)
|
|
381
437
|
|
|
382
438
|
|
|
383
439
|
@deployment.command(name="show", help="Show details of a specific deployment.")
|
|
@@ -430,6 +486,7 @@ def deployment_delete(
|
|
|
430
486
|
|
|
431
487
|
|
|
432
488
|
def main() -> int:
|
|
489
|
+
debug = False
|
|
433
490
|
try:
|
|
434
491
|
args = sys.argv[1:]
|
|
435
492
|
debug = "-d" in args or "--debug" in args
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
toolforge_components_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
toolforge_components_cli/cli.py,sha256=cV1ktOizDX6mg3heEonNsBnIyjja4zo3sHmofswVPYs,15698
|
|
3
|
+
toolforge_components_cli/components.py,sha256=ISGD-ahjp6mndIgCxU6V98X0Xcb7abJuLjc_Rk4CjZU,3128
|
|
4
|
+
toolforge_components_cli/config.py,sha256=wT8-kciiOIYcjoB9EELjc2FQARooQSBQlZv3elvMH2k,730
|
|
5
|
+
toolforge_components_cli-0.0.5.dist-info/LICENSE,sha256=4cCtcomD2KVzNeUs8QZPGv_R1FQXPYzr0-2LSnK0hwQ,35121
|
|
6
|
+
toolforge_components_cli-0.0.5.dist-info/METADATA,sha256=x4l3O7AzcVQ8bPq1yPbHcoUot93lntxl86LIK402WlQ,1523
|
|
7
|
+
toolforge_components_cli-0.0.5.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
8
|
+
toolforge_components_cli-0.0.5.dist-info/entry_points.txt,sha256=D1g7NaMicWBsSJmJXBVU9eUnVfg45d_o4Io7LQe-SWE,74
|
|
9
|
+
toolforge_components_cli-0.0.5.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
toolforge_components_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
toolforge_components_cli/cli.py,sha256=I1q8ulVDE3fw4lyR8toLLXGlv0EOXnU02lEFd6WW8so,14140
|
|
3
|
-
toolforge_components_cli/components.py,sha256=ISGD-ahjp6mndIgCxU6V98X0Xcb7abJuLjc_Rk4CjZU,3128
|
|
4
|
-
toolforge_components_cli/config.py,sha256=wT8-kciiOIYcjoB9EELjc2FQARooQSBQlZv3elvMH2k,730
|
|
5
|
-
toolforge_components_cli-0.0.3.dist-info/LICENSE,sha256=4cCtcomD2KVzNeUs8QZPGv_R1FQXPYzr0-2LSnK0hwQ,35121
|
|
6
|
-
toolforge_components_cli-0.0.3.dist-info/METADATA,sha256=DDhbjyF2SFJ9WKG-HHWunSAI2ceQ43XJGiNsZPg-Mg8,1523
|
|
7
|
-
toolforge_components_cli-0.0.3.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
8
|
-
toolforge_components_cli-0.0.3.dist-info/entry_points.txt,sha256=D1g7NaMicWBsSJmJXBVU9eUnVfg45d_o4Io7LQe-SWE,74
|
|
9
|
-
toolforge_components_cli-0.0.3.dist-info/RECORD,,
|
{toolforge_components_cli-0.0.3.dist-info → toolforge_components_cli-0.0.5.dist-info}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|