#6430: display response nicely in tabular format
This commit is contained in:
parent
c3c9ba4a72
commit
0b838b0172
1 changed files with 9 additions and 1 deletions
|
@ -2,6 +2,7 @@ import urllib.request
|
|||
import json
|
||||
import sys
|
||||
from pyotp import TOTP
|
||||
from tabulate import tabulate
|
||||
|
||||
UNGLEICH_PAY_SERVER_URL = "https://pay.ungleich.ch"
|
||||
|
||||
|
@ -55,4 +56,11 @@ class ungleichPay(object):
|
|||
print(str(uerr))
|
||||
sys.exit(2)
|
||||
response_json = json.loads(response.read().decode('utf-8'))
|
||||
print(response_json["data"])
|
||||
if (response_json['response'] == 'success'):
|
||||
data = response_json["data"]
|
||||
rows = [(x['email'], x['vm_count']) for x in data]
|
||||
headers = ["email", "vm_count"]
|
||||
print(tabulate(rows, headers))
|
||||
else:
|
||||
print("An error occurred.")
|
||||
print(response_json["message"])
|
||||
|
|
Loading…
Reference in a new issue