def list_locations(ctx, raw):
with Spinner('Fetching locations: '):
locations = newrelic.get_locations(ctx.obj['ACCOUNT'])
if raw:
print(json.dumps(locations))
return
data = [[
'#',
'City',
'Continent',
'Code',
'Availability',
'Accessibility',
]]
for number, location in enumerate(locations.values()):
available = click.style(u'?', fg='green')
if not location['available']:
click.style(u'?', fg='red')
private = 'Private' if location['private'] else 'Public'
data.append([
number,
location['label'],
location['continent'],
location['name'],
available,
private,
])
table = SingleTable(data)
table.title = click.style('Locations', fg='black')
for i in [0, 4, 5]:
table.justify_columns[i] = 'right'
print(table.table)
评论列表
文章目录