v7.1.2: Fix launch output with latest API changes

This commit is contained in:
SporeStack 2022-11-01 04:42:29 +00:00
parent 8cd2644c0c
commit d8043414a8
3 changed files with 24 additions and 22 deletions

View File

@ -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

View File

@ -2,4 +2,4 @@
__all__ = ["api", "api_client", "exceptions"]
__version__ = "7.1.1"
__version__ = "7.1.2"

View File

@ -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: