in cid/common.py [0:0]
def update(self, dashboard_id, **kwargs):
"""Update Dashboard"""
if not dashboard_id:
dashboard_id = self.qs.select_dashboard(force=kwargs.get('force'))
if not dashboard_id:
exit()
dashboard = self.qs.dashboards.get(dashboard_id)
if not dashboard:
click.echo(f'Dashboard "{dashboard_id}" is not deployed')
return
print(f'\nChecking for updates...')
click.echo(f'Deployed template: {dashboard.deployed_arn}')
click.echo(
f"Latest template: {dashboard.sourceTemplate.get('Arn')}/version/{dashboard.latest_version}")
if dashboard.status == 'legacy':
click.confirm(
"\nDashboard template changed, update it anyway?", abort=True)
elif dashboard.latest:
click.confirm(
"\nNo updates available, should I update it anyway?", abort=True)
kwargs = dict()
local_overrides = f'work/{self.awsIdentity.get("Account")}/{dashboard.id}.json'
print(
f'Looking for local overrides file "{local_overrides}"...', end='')
try:
with open(local_overrides, 'r', encoding='utf-8') as r:
try:
print('found')
if click.confirm(f'Use local overrides from {local_overrides}?'):
kwargs = json.load(r)
print('loaded')
except Exception as e:
# Catch exception and dump a reason
click.echo('failed to load, dumping error message')
print(json.dumps(e, indent=4, sort_keys=True, default=str))
except FileNotFoundError:
print('not found')
# Update dashboard
click.echo('\nUpdating...', nl=False)
try:
self.qs.update_dashboard(dashboard, **kwargs)
click.echo('completed')
dashboard.display_url(self.qs_url, launch=True, **self.qs_url_params)
except Exception as e:
# Catch exception and dump a reason
click.echo('failed, dumping error message')
print(json.dumps(e, indent=4, sort_keys=True, default=str))
return dashboard_id