From d8043414a886def8ee9e7e0aeafec96714e7ef9b Mon Sep 17 00:00:00 2001 From: SporeStack Date: Tue, 1 Nov 2022 04:42:29 +0000 Subject: [PATCH] v7.1.2: Fix launch output with latest API changes --- CHANGELOG.md | 6 ++++++ src/sporestack/__init__.py | 2 +- src/sporestack/cli.py | 38 +++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e652486..7eab1fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.1.2 - 2022-11-01] + +### Changed + +- Fixed launch output with recent API changes. + ## [7.1.1 - 2022-09-29] ### Changed diff --git a/src/sporestack/__init__.py b/src/sporestack/__init__.py index 75bb105..eab2838 100644 --- a/src/sporestack/__init__.py +++ b/src/sporestack/__init__.py @@ -2,4 +2,4 @@ __all__ = ["api", "api_client", "exceptions"] -__version__ = "7.1.1" +__version__ = "7.1.2" diff --git a/src/sporestack/cli.py b/src/sporestack/cli.py index 7f7f153..0a6aad9 100644 --- a/src/sporestack/cli.py +++ b/src/sporestack/cli.py @@ -192,9 +192,13 @@ def launch( typer.echo("Server creation failed, tries exceeded.", err=True) raise typer.Exit(code=1) - created_dict = response.dict() - typer.echo(pretty_machine_info(created_dict), err=True) - typer.echo(json.dumps(created_dict, indent=4)) + typer.echo( + pretty_machine_info( + api_client.info( + machine_id=machine_id, api_endpoint=get_api_endpoint() + ).dict() + ) + ) @server_cli.command() @@ -203,7 +207,6 @@ def topup( machine_id: str = "", days: int = typer.Option(...), token: str = DEFAULT_TOKEN, - quote: bool = typer.Option(True, help="Require manual price confirmation."), ) -> None: """ Extend an existing SporeStack server's lifetime. @@ -213,19 +216,6 @@ def topup( _token = load_token(token) - if quote: - response = api_client.topup( - machine_id=machine_id, - days=days, - api_endpoint=get_api_endpoint(), - token=_token, - retry=True, - quote=True, - ) - - typer.echo(f"Is {response.payment.usd} for {days} day(s) okay?", err=True) - input("[Press ctrl+c to cancel, or enter to accept.]") - response = api_client.topup( machine_id=machine_id, days=days, @@ -290,10 +280,16 @@ def pretty_machine_info(info: Dict[str, Any]) -> str: elif "hostname" in info: msg += "Hostname: {}\n".format(info["hostname"]) - if "ipv6" in info["network_interfaces"][0]: - msg += "IPv6: {}\n".format(info["network_interfaces"][0]["ipv6"]) - if "ipv4" in info["network_interfaces"][0]: - msg += "IPv4: {}\n".format(info["network_interfaces"][0]["ipv4"]) + if "network_interfaces" in info: + if "ipv6" in info["network_interfaces"][0]: + msg += "IPv6: {}\n".format(info["network_interfaces"][0]["ipv6"]) + if "ipv4" in info["network_interfaces"][0]: + msg += "IPv4: {}\n".format(info["network_interfaces"][0]["ipv4"]) + else: + if "ipv6" in info: + msg += "IPv6: {}\n".format(info["ipv6"]) + if "ipv4" in info: + msg += "IPv4: {}\n".format(info["ipv4"]) expiration = info["expiration"] human_expiration = time.strftime("%Y-%m-%d %H:%M:%S %z", time.localtime(expiration)) if "running" in info: