Skip to content

Commit

Permalink
Merge pull request #7 from mbugert/dev
Browse files Browse the repository at this point in the history
Integrate changes prior to v0.2.7
  • Loading branch information
mbugert authored Mar 13, 2021
2 parents d26c9d6 + 951a94c commit bba50f1
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Contributors

- Michael Bugert (mbugert) - Owner
- IndeedNotJames - Docker integration
- Dobrosław Kijowski (dobo90) - Bug fix

## Thanks to
- Ties de Kock (ties) - for the `
compal_CH7465LG_py` library
28 changes: 28 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Release Checklist
- [ ] Testing
- [ ] Update version and info in `setup.py`
- [ ] Build
```
python -m build
```
- [ ] Test pypi release
```
python -m twine upload --repository testpypi dist/*
```
- [ ] Try installing that
```
python3 -m venv tmpvenv
source tmpvenv/bin/activate
pip install -i https://test.pypi.org/simple/ --no-deps PACKAGE_NAME
deactivate
rm -rf tmpvenv
```
- [ ] Commit, merge into `master` with PR
- [ ] Proper pypi release
```
python -m twine upload dist/*
```
- [ ] Release on github with appropriate tag
## Wishlist
Automate this with https://github.com/pypa/gh-action-pypi-publish
17 changes: 15 additions & 2 deletions connectbox_exporter/connectbox_exporter.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import json
import logging
import threading
import time
from http.server import HTTPServer
from socketserver import ThreadingMixIn
from typing import Dict
import json

import click
import compal
from lxml.etree import XMLSyntaxError
from prometheus_client import CollectorRegistry, MetricsHandler
from prometheus_client.exposition import _ThreadingSimpleServer
from prometheus_client.metrics_core import GaugeMetricFamily
from requests import Timeout

Expand All @@ -25,6 +26,18 @@
from connectbox_exporter.xml2metric import get_metrics_extractor


# Taken 1:1 from prometheus-client==0.7.1, see https://github.com/prometheus/client_python/blob/3cb4c9247f3f08dfbe650b6bdf1f53aa5f6683c1/prometheus_client/exposition.py
class _ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
"""Thread per request HTTP server."""

# Make worker threads "fire and forget". Beginning with Python 3.7 this
# prevents a memory leak because ``ThreadingMixIn`` starts to gather all
# non-daemon threads in a list in order to join on them at server close.
# Enabling daemon threads virtually makes ``_ThreadingSimpleServer`` the
# same as Python 3.7's ``ThreadingHTTPServer``.
daemon_threads = True


class ConnectBoxCollector(object):
def __init__(
self,
Expand Down
6 changes: 5 additions & 1 deletion connectbox_exporter/xml2metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ def extract(self, raw_xmls: Dict[int, bytes]) -> Iterable[Metric]:
value=tuner_temperature,
)
yield GaugeMetricFamily(
"connectbox_temperature", "Temperature", unit="celsius", value=temperature,
"connectbox_temperature",
"Temperature",
unit="celsius",
value=temperature,
)


Expand All @@ -303,6 +306,7 @@ class ProvisioningStatus(Enum):
PARTIAL_SERVICE_US = "Partial Service (US only)"
PARTIAL_SERVICE_DS = "Partial Service (DS only)"
PARTIAL_SERVICE_USDS = "Partial Service (US+DS)"
MODEM_MODE = "Modem Mode"


class DeviceStatusExtractor(XmlMetricsExtractor):
Expand Down
4 changes: 3 additions & 1 deletion resources/requirements/development.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
-r production.txt
black==19.10b0
black==20.8b1
build==0.3.1.post1
twine==3.3.0
10 changes: 5 additions & 5 deletions resources/requirements/production.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
click==7.1.1
compal==0.1.1
deepmerge==0.1.0
click==7.1.2
compal==0.3.1
deepmerge==0.2.1
lxml>=4.5.0
prometheus-client==0.7.1
ruamel.yaml==0.16.10
prometheus-client==0.9.0
ruamel.yaml==0.16.13
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
RESOURCES_ROOT = Path(__file__).parent / "resources"
REQUIREMENTS_ROOT = RESOURCES_ROOT / "requirements"
PRODUCTION_REQUIREMENTS = REQUIREMENTS_ROOT / "production.txt"
print(PRODUCTION_REQUIREMENTS)

with PRODUCTION_REQUIREMENTS.open() as f:
install_requires = [s.strip() for s in f.readlines()]

setup(
name="connectbox-prometheus",
version="0.2.6",
version="0.2.7",
author="Michael Bugert",
author_email="[email protected]",
description='Prometheus exporter for Compal CH7465LG cable modems, commonly sold as "Connect Box"',
Expand All @@ -37,6 +36,7 @@
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: System :: Networking :: Monitoring",
],
)

0 comments on commit bba50f1

Please sign in to comment.