Skip to content

Commit

Permalink
Merge pull request #12 from dbrennand/1.2.0
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
dbrennand committed Sep 3, 2024
2 parents 1e9dc09 + ee665e1 commit 3eb087a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- 'v*'
- '*'

env:
REGISTRY: ghcr.io
Expand All @@ -19,25 +19,32 @@ jobs:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 dbrennand
Copyright (c) 2024 dbrennand

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 7 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
certifi==2023.7.22
influxdb-client==1.37.0
loguru==0.7.0
python-dateutil==2.8.2
certifi==2024.7.4
influxdb-client==1.45.0
loguru==0.7.2
python-dateutil==2.9.0.post0
reactivex==4.0.4
setuptools==73.0.1
six==1.16.0
typing_extensions==4.7.1
urllib3==2.0.4
typing_extensions==4.12.2
urllib3==2.2.2
16 changes: 11 additions & 5 deletions speeder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2023 dbrennand
Copyright (c) 2024 dbrennand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,6 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from influxdb_client.client.write_api import SYNCHRONOUS
from influxdb_client import InfluxDBClient
from loguru import logger
Expand Down Expand Up @@ -54,7 +55,7 @@
exit(1)
else:
# Create list from comma separated string of server IDs
SPEEDER_SPEEDTEST_SERVER_ID = SPEEDER_SPEEDTEST_SERVER_ID.split(",")
SPEEDER_SPEEDTEST_SERVER_IDs = SPEEDER_SPEEDTEST_SERVER_ID.split(",")

# Connect to InfluxDB
logger.debug(
Expand All @@ -67,7 +68,7 @@
) as client:
# Run the speedtest using the librespeed/speedtest-cli on an interval
while True:
for server_id in SPEEDER_SPEEDTEST_SERVER_ID:
for server_id in SPEEDER_SPEEDTEST_SERVER_IDs:
logger.debug(f"Running speedtest for server ID: {server_id}.")
result = subprocess.run(
[
Expand All @@ -84,15 +85,20 @@
# Check if the speedtest failed
if result.returncode != 0:
# CLI errors go to stdout
logger.debug(
logger.error(
f"Speedtest for server ID: {server_id} failed with exit code: {result.returncode}.\nError: {result.stdout}"
)
else:
logger.debug(f"Speedtest for server ID: {server_id} succeeded.")
try:
json_result = json.loads(result.stdout)
# Check if the JSON result is empty
if not json_result:
raise json.decoder.JSONDecodeError(
"JSON result is empty.", json_result, 0
)
except json.decoder.JSONDecodeError as err:
logger.debug(
logger.error(
f"Failed to parse JSON results for server ID: {server_id}.\nError: {err}"
)
continue
Expand Down

0 comments on commit 3eb087a

Please sign in to comment.