Skip to content

Commit

Permalink
Update asset Id text
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed May 10, 2023
1 parent 12f3de6 commit 2c45589
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions bin/infrasonar
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from dataclasses import dataclass
from setproctitle import setproctitle
from typing import Any, Optional, Dict, List, Tuple

__version__ = '0.1.7' # Update version in setup as well
__version__ = '0.1.8' # Update version in setup as well


_labels_example = """
Expand Down Expand Up @@ -124,6 +124,11 @@ def _json_headers(token: str):
}


def _assetstr(name: str, asset_id: Optional[int]):
return \
f'asset "{name}" (assetId: {"new" if asset_id is None else asset_id})'


_yaml_keys = {
'container',
'token',
Expand Down Expand Up @@ -583,7 +588,7 @@ async def apply_asset(aa: ApplyAssets, dest: dict):
if not silent:
print(
f'Change {prop} to "{val}" '
f'for asset "{name}" ({asset_id})')
f'for {_assetstr(name, asset_id)}')

if not dry_run:
await asyncio.sleep(0.5)
Expand All @@ -608,7 +613,7 @@ async def apply_asset(aa: ApplyAssets, dest: dict):
changes = make_changes(changes)
if not silent:
prefix = 'Update collector' if oc else 'Add collector'
print(f'{prefix} "{key}" on asset "{name}" ({asset_id})')
print(f'{prefix} "{key}" on {_assetstr(name, asset_id)}')

if not dry_run:
await asyncio.sleep(0.5)
Expand Down Expand Up @@ -636,7 +641,7 @@ async def apply_asset(aa: ApplyAssets, dest: dict):
changes = make_changes(changes)
if not silent:
prefix = 'Remove collector'
print(f'{prefix} "{key}" from asset "{name}" ({asset_id})')
print(f'{prefix} "{key}" from {_assetstr(name, asset_id)}')
if not dry_run:
await asyncio.sleep(0.5)
url = _join(api, f'asset/{asset_id}/collector/{key}')
Expand All @@ -655,7 +660,7 @@ async def apply_asset(aa: ApplyAssets, dest: dict):

changes = make_changes(changes)
if not silent:
print(f'Add label {lid} on asset "{name}" ({asset_id})')
print(f'Add label {lid} on {_assetstr(name, asset_id)}')

if not dry_run:
await asyncio.sleep(0.5)
Expand All @@ -671,7 +676,7 @@ async def apply_asset(aa: ApplyAssets, dest: dict):
for lid in rlabels:
changes = make_changes(changes)
if not silent:
print(f'Remove label {lid} on asset "{name}" ({asset_id})')
print(f'Remove label {lid} on {_assetstr(name, asset_id)}')

if not dry_run:
await asyncio.sleep(0.5)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='infrasonar',
version='0.1.7', # Update version in infrasonar as well
version='0.1.8', # Update version in infrasonar as well
description='InfraSonar Toolkit',
url='https://github.com/infrasonar/toolkit',
long_description=long_description,
Expand Down

0 comments on commit 2c45589

Please sign in to comment.