Skip to content

Commit

Permalink
Merge pull request #5 from Naudit/develop-I3-I4
Browse files Browse the repository at this point in the history
Closes #4 and #3
  • Loading branch information
ralequi authored Nov 18, 2024
2 parents 108f84b + a6ebedf commit ccc9dae
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 215 deletions.
66 changes: 24 additions & 42 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,43 @@ jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@master
- name: Checkout code
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v1

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: "3.10"

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
run: |
pip install build --user
pip install .
- name: Install pypa/pdoc
run: >-
python -m
pip install
pdoc
--user
- name: Install dependencies
run: >-
python -m
pip install
.[dev]
--user
- name: Generate doc
run: >-
python -m
pdoc -o docs -n pysmart_exporter
- name: Build the test wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir distTest/
.
- name: Generate documentation with pdoc
run: python -m pdoc -o docs -n pysmart_exporter

- name: Build the binary wheel and source tarball
run: python -m build --sdist --wheel --outdir dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages_dir: distTest/
skip_existing: true
- name: Build the binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ build/
dist/
docs
venv

# local version
pysmart_exporter/version.py
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (C) 2021 Rafael Leira
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# License for more details.
#
################################################################


[build-system]
requires = ["setuptools>=61.0", "setuptools-scm", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "pysmart_exporter/version.py"
local_scheme = "no-local-version"

[project]
name = "pySMART-exporter"
description = "A Prometheus PySMART exporter"
readme = "README.md"
keywords = ["prometheus", "SMART", "exporter", "monitoring"]
license = { text = "BSD-3-Clause" }
dependencies = ["prometheus-client", "pySMART >=1.3.0"]
dynamic = ["version"]
authors = [{ name = "Rafael Leira", email = "rafael.leira@naudit.es" }]

classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]

[project.optional-dependencies]
dev = ['pytest', 'pytest-cov', 'mypy', 'types-tabulate', 'types-six', 'pdoc']

[project.urls]
homepage = "https://repo1.naudit.es/theseus/pysmart-exporter"

[project.entry-points."console_scripts"]
pysmart_exporter = "pysmart_exporter.__main__:main"
2 changes: 0 additions & 2 deletions pysmart_exporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
# License for more details.
#
################################################################

__version__ = '0.3.1'
9 changes: 3 additions & 6 deletions pysmart_exporter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# License for more details.
#
################################################################
"""The pysmart_exporter main file
"""
"""The pysmart_exporter main file"""

import prometheus_client
from pysmart_exporter.collector import PySMARTCollector
Expand All @@ -28,16 +27,14 @@ def main():

if args['listen']:
(ip, port) = args['listen'].split(':')
prometheus_client.start_http_server(port=int(port),
addr=ip, registry=registry)
prometheus_client.start_http_server(port=int(port), addr=ip, registry=registry)
while True:
time.sleep(3600)

if args['textfile_name']:
while True:
collector.collect()
prometheus_client.write_to_textfile(args['textfile_name'],
registry)
prometheus_client.write_to_textfile(args['textfile_name'], registry)
if collector.args['oneshot']:
sys.exit(0)
time.sleep(args.get('interval', 60))
Expand Down
Loading

0 comments on commit ccc9dae

Please sign in to comment.