From f7afcfe991e54950b89ed6933ef942028ba504f5 Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Mon, 31 Oct 2022 17:54:13 -0400 Subject: [PATCH] rename project to ecommerce-exporter --- .gitignore | 2 +- Dockerfile | 2 +- README.md | 2 +- ...mple.yml => ecommerce-exporter.exemple.yml | 0 .../__init__.py | 0 .../cli.py | 22 +++++++++---------- .../scrape_target.py | 0 setup.cfg | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) rename webscraping-exporter.exemple.yml => ecommerce-exporter.exemple.yml (100%) rename {webscraping_exporter => ecommerce_exporter}/__init__.py (100%) rename {webscraping_exporter => ecommerce_exporter}/cli.py (88%) rename {webscraping_exporter => ecommerce_exporter}/scrape_target.py (100%) diff --git a/.gitignore b/.gitignore index 14b95c9..a8785f6 100644 --- a/.gitignore +++ b/.gitignore @@ -202,4 +202,4 @@ tags [._]*.un~ ### Project-specific -webscraping-exporter.yml \ No newline at end of file +ecommerce-exporter.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2f59fd9..1c14901 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ FROM python:3.10 COPY . /tmp/package RUN pip install --no-cache-dir /tmp/package && \ rm -r /tmp/package -ENTRYPOINT ["webscraping-exporter"] \ No newline at end of file +ENTRYPOINT ["ecommerce-exporter"] \ No newline at end of file diff --git a/README.md b/README.md index c5666c5..4eda0cc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# webscraping-exporter +# ecommerce-exporter diff --git a/webscraping-exporter.exemple.yml b/ecommerce-exporter.exemple.yml similarity index 100% rename from webscraping-exporter.exemple.yml rename to ecommerce-exporter.exemple.yml diff --git a/webscraping_exporter/__init__.py b/ecommerce_exporter/__init__.py similarity index 100% rename from webscraping_exporter/__init__.py rename to ecommerce_exporter/__init__.py diff --git a/webscraping_exporter/cli.py b/ecommerce_exporter/cli.py similarity index 88% rename from webscraping_exporter/cli.py rename to ecommerce_exporter/cli.py index 7dcd02c..17b4d76 100644 --- a/webscraping_exporter/cli.py +++ b/ecommerce_exporter/cli.py @@ -7,20 +7,20 @@ import yaml from httpx import RequestError from prometheus_client import start_http_server, Gauge, Counter -from webscraping_exporter.scrape_target import ScrapeError, ScrapeTarget +from ecommerce_exporter.scrape_target import ScrapeError, ScrapeTarget -WEBSCRAPING_SCRAPE_TARGET_VALUE = Gauge( - 'webscraping_scrape_target_value', +ECOMMERCE_SCRAPE_TARGET_VALUE = Gauge( + 'ecommerce_scrape_target_value', 'The value scraped from a scrape target', ['product_name', 'target_name'], ) -WEBSCRAPING_SCRAPE_TARGET_SUCCESS = Counter( - 'webscraping_scrape_target_success_total', +ECOMMERCE_SCRAPE_TARGET_SUCCESS = Counter( + 'ecommerce_scrape_target_success_total', 'The number of successful scrape and parse of a scrape target', ['product_name', 'target_name'], ) -WEBSCRAPING_SCRAPE_TARGET_FAILURE = Counter( - 'webscraping_scrape_target_failure_total', +ECOMMERCE_SCRAPE_TARGET_FAILURE = Counter( + 'ecommerce_scrape_target_failure_total', 'The number of failed scrape and parse of a scrape target', ['product_name', 'target_name', 'exception'], ) @@ -31,7 +31,7 @@ def main(): '-c', '--config', help='The configuration file. (default: %(default)s)', type=str, - default='webscraping-exporter.yml', + default='ecommerce-exporter.yml', ) parser.add_argument( '-i', '--interval', @@ -77,17 +77,17 @@ def main(): try: print("Starting scrape. product: '%s', target '%s'" % (scrape_target.product_name, scrape_target.target_name)) value = scrape_target.query_target() - WEBSCRAPING_SCRAPE_TARGET_VALUE.labels( + ECOMMERCE_SCRAPE_TARGET_VALUE.labels( product_name=scrape_target.product_name, target_name=scrape_target.target_name ).set(value) - WEBSCRAPING_SCRAPE_TARGET_SUCCESS.labels( + ECOMMERCE_SCRAPE_TARGET_SUCCESS.labels( product_name=scrape_target.product_name, target_name=scrape_target.target_name, ).inc() except (RequestError, ScrapeError) as e: print("Failed to scrape! product: '%s', target: '%s', message: '%s'" % (scrape_target.product_name, scrape_target.target_name, e)) - WEBSCRAPING_SCRAPE_TARGET_FAILURE.labels( + ECOMMERCE_SCRAPE_TARGET_FAILURE.labels( product_name=scrape_target.product_name, target_name=scrape_target.target_name, exception=e.__class__.__name__, diff --git a/webscraping_exporter/scrape_target.py b/ecommerce_exporter/scrape_target.py similarity index 100% rename from webscraping_exporter/scrape_target.py rename to ecommerce_exporter/scrape_target.py diff --git a/setup.cfg b/setup.cfg index f9d5585..781e939 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [metadata] -name = webscraping-exporter +name = ecommerce-exporter author = badjware author_email = marchambault.badjware.dev platform = any @@ -18,6 +18,6 @@ install_requires= [options.entry_points] console_scripts = - webscraping-exporter = webscraping_exporter.cli:main + ecommerce-exporter = ecommerce_exporter.cli:main [tool.setuptools_scm] \ No newline at end of file