Skip to content

Commit 522c7bf

Browse files
committed
asset id direct of file location
1 parent f3184a5 commit 522c7bf

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pip install pylibagent
1616
Variable | Default | Description
1717
----------------------------|-------------------------------|-------------------
1818
`TOKEN` | _required_ | Token to connect to.
19-
`ASSET_ID_FILE` | _required_ | File where the Agent asset Id is stored _(e.g `/var/infrasonar/asset_id.json`)_.
19+
`ASSET_ID` | _required_ | Asset Id or file location where the Agent asset Id is stored _(e.g `123` or `/var/infrasonar/asset_id.json`)_.
2020
`API_URI` | https://api.infrasonar.com | InfraSonar API.
2121
`VERIFY_SSL` | `1` | Verify SSL certificate, 0 _(=disabled)_ or 1 _(=enabled)_.
2222
`LOG_LEVEL` | `warning` | Log level _(error, warning, info, debug)_.

pylibagent/agent.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def __init__(self, key: str, version: str):
5555
logging.error(f'invalid agent version: `{version}`')
5656
exit(1)
5757

58-
self.asset_id_file: str = os.getenv('ASSET_ID_FILE', None)
58+
self.asset_id_file: str = os.getenv('ASSET_ID', None)
5959
if self.asset_id_file is None:
60-
logging.error('missing environment variable `ASSET_ID_FILE`')
60+
logging.error('missing environment variable `ASSET_ID`')
6161
exit(1)
6262

6363
token = os.getenv('TOKEN', None)
@@ -73,7 +73,10 @@ def __init__(self, key: str, version: str):
7373
self.asset_id: Optional[int] = None
7474
self.api_uri: str = os.getenv('API_URI', 'https://api.infrasonar.com')
7575
self.verify_ssl = _convert_verify_ssl(os.getenv('VERIFY_SSL', '1'))
76-
self._read_json()
76+
if str.isdigit(self.asset_id_file):
77+
self.asset_id = int(self.asset_id_file)
78+
else:
79+
self._read_json()
7780

7881
async def announce(self, asset_name: Optional[str] = None,
7982
asset_kind: Optional[str] = None):

pylibagent/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.7'
1+
__version__ = '0.1.8'

0 commit comments

Comments
 (0)