Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
chore: update sdk (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vixtir authored Feb 10, 2023
1 parent 519e37d commit ef86094
Show file tree
Hide file tree
Showing 4 changed files with 806 additions and 816 deletions.
36 changes: 13 additions & 23 deletions odd_collector_aws/__main__.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
import asyncio
import logging
import os
import traceback
from pathlib import Path

from odd_collector_sdk.collector import Collector
from odd_collector_sdk.logger import logger

from odd_collector_aws.domain.plugin import PLUGIN_FACTORY

logging.basicConfig(
level=os.getenv("LOGLEVEL", "INFO"),
format="[%(asctime)s] %(levelname)s in %(name)s: %(message)s",
)
logger = logging.getLogger("odd-collector-aws")
from .version import print_version

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()

config_path = Path().cwd() / os.getenv("CONFIG_PATH", "collector_config.yaml")

root_package = "odd_collector_aws.adapters"

collector = Collector(str(config_path), root_package, PLUGIN_FACTORY)
print_version()

loop.run_until_complete(collector.register_data_sources())

collector.start_polling()

asyncio.get_event_loop().run_forever()
try:
collector = Collector(
config_path=Path().cwd() / "collector_config.yaml",
root_package="odd_collector_aws.adapters",
plugin_factory=PLUGIN_FACTORY,
)
collector.run()
except Exception as e:
logger.exception(e)
asyncio.get_event_loop().stop()
logger.debug(traceback.format_exc())
logger.error(e)
12 changes: 12 additions & 0 deletions odd_collector_aws/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odd_collector_sdk.logger import logger


def print_version():
import subprocess

try:
logger.info(
subprocess.run(["poetry", "version"], capture_output=True).stdout.decode()
)
except Exception as e:
logger.error("Couldn't show version. {e}")
Loading

0 comments on commit ef86094

Please sign in to comment.