afws_client: improve compatibility with older versions of prettytable. Closes #2264

This commit is contained in:
Sebastien Bourdeauducq 2023-11-07 14:06:31 +08:00
parent 6640bf0e82
commit c0a6252e77
1 changed files with 5 additions and 3 deletions

View File

@ -146,7 +146,8 @@ class Client:
print(error_msg) print(error_msg)
table = PrettyTable() table = PrettyTable()
table.field_names = ["Variant", "Expiry date"] table.field_names = ["Variant", "Expiry date"]
table.add_rows(variants) for variant in variants:
table.add_row(variant)
print(table) print(table)
sys.exit(1) sys.exit(1)
return variants[0][0] return variants[0][0]
@ -244,10 +245,11 @@ def main():
sys.exit(1) sys.exit(1)
zip_unarchive(contents, args.directory) zip_unarchive(contents, args.directory)
elif args.action == "get_variants": elif args.action == "get_variants":
data = client.get_variants() variants = client.get_variants()
table = PrettyTable() table = PrettyTable()
table.field_names = ["Variant", "Expiry date"] table.field_names = ["Variant", "Expiry date"]
table.add_rows(data) for variant in variants:
table.add_row(variant)
print(table) print(table)
elif args.action == "get_json": elif args.action == "get_json":
if args.variant: if args.variant: