Compare commits

..

No commits in common. "d9f951f3164d6b9a21a0ce1d33d8b6a2934dfec3" and "ca25bbf3884da68cbefc547ddb7455b9e404e136" have entirely different histories.

View File

@ -8,7 +8,7 @@ import typer
import os import os
import configparser import configparser
import base64 import base64
from prettytable import PrettyTable import prettytable
app = typer.Typer() app = typer.Typer()
servers_app = typer.Typer() servers_app = typer.Typer()
@ -59,11 +59,9 @@ def get_balance():
print(typer.style("Error", fg=typer.colors.RED)) print(typer.style("Error", fg=typer.colors.RED))
sys.exit(1) sys.exit(1)
else: else:
x = PrettyTable()
x.field_names = ["Balance", "Monthly cost"]
response = response.json() response = response.json()
x.add_row([response['finances']['balance'], response['finances']['monthly_cost']]) print('{0:6} {1:}'.format('balance', 'monthly_cost'))
print(x) print('{0:6} {1:}'.format(response['finances']['balance'], response['finances']['monthly_cost']))
@servers_app.command("start") @servers_app.command("start")
@ -89,8 +87,7 @@ def vds_stop(vds_id: int = typer.Argument(...)):
@servers_app.command("list") @servers_app.command("list")
def vds_list(): def vds_list():
list_of_servers = Server.get_list() list_of_servers = Server.get_list()
x = PrettyTable() # print('{0:7} {1:17} {5:16} {2:2} {3:5} {4:4}'.format('state', 'name', 'vcpus', 'memory', 'disk', 'ip'))
x.field_names = ['id', 'state', 'name', 'ip', 'cpus', 'ram', 'disk']
if list_of_servers is None: if list_of_servers is None:
print(typer.style("Error", fg=typer.colors.RED)) print(typer.style("Error", fg=typer.colors.RED))
sys.exit(1) sys.exit(1)
@ -101,8 +98,7 @@ def vds_list():
state = typer.style('Stopped', fg=typer.colors.RED) state = typer.style('Stopped', fg=typer.colors.RED)
else: else:
state = i['status'] state = i['status']
x.add_row([i['id'], state, i['name'], i['ip'], i['configuration']['cpu'], i['configuration']['ram'], i['configuration']['disk_size']]) print('{0:6} {1:15} {2:20} {3:16} {4:2} {5:5} {6:4} '.format(i['id'], state, i['name'], i['ip'], i['configuration']['cpu'], i['configuration']['ram'], i['configuration']['disk_size']))
print(x)
def auth(based): def auth(based):