Check the status of a deployment.
(
key: str = typer.Argument(..., help="The name of the deployment."),
loglevel: constants.LogLevel = typer.Option(
config.loglevel, help="The log level to use."
),
)
| 795 | |
| 796 | @deployments_cli.command(name="status") |
| 797 | def get_deployment_status( |
| 798 | key: str = typer.Argument(..., help="The name of the deployment."), |
| 799 | loglevel: constants.LogLevel = typer.Option( |
| 800 | config.loglevel, help="The log level to use." |
| 801 | ), |
| 802 | ): |
| 803 | """Check the status of a deployment.""" |
| 804 | from nextpy.backend.deploy import hosting |
| 805 | |
| 806 | console.set_log_level(loglevel) |
| 807 | |
| 808 | try: |
| 809 | console.print(f"Getting status for [ {key} ] ...\n") |
| 810 | status = hosting.get_deployment_status(key) |
| 811 | |
| 812 | # TODO: refactor all these tabulate calls |
| 813 | status.backend.updated_at = hosting.convert_to_local_time_str( |
| 814 | status.backend.updated_at or "N/A" |
| 815 | ) |
| 816 | backend_status = status.backend.dict(exclude_none=True) |
| 817 | headers = list(backend_status.keys()) |
| 818 | table = list(backend_status.values()) |
| 819 | console.print(tabulate([table], headers=headers)) |
| 820 | # Add a new line in console |
| 821 | console.print("\n") |
| 822 | status.frontend.updated_at = hosting.convert_to_local_time_str( |
| 823 | status.frontend.updated_at or "N/A" |
| 824 | ) |
| 825 | frontend_status = status.frontend.dict(exclude_none=True) |
| 826 | headers = list(frontend_status.keys()) |
| 827 | table = list(frontend_status.values()) |
| 828 | console.print(tabulate([table], headers=headers)) |
| 829 | except Exception as ex: |
| 830 | console.error(f"Unable to get deployment status") |
| 831 | raise typer.Exit(1) from ex |
| 832 | |
| 833 | |
| 834 | @deployments_cli.command(name="logs") |