From 2fdca24514a7c8bafee0b6aa5a5dfd721ed04438 Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Sat, 22 Jun 2024 14:06:46 +0200 Subject: [PATCH 1/5] Updated pyproject.toml to fix the changes made in pypa/setuptools#4159 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1d618a2..755701b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "prologix_gpib_async" +name = "prologix-gpib-async" authors = [ { name="Patrick Baus", email="patrick.baus@physik.tu-darmstadt.de" }, ] From ae769e0cb2d751b0c3f2c6e6de8c7b19a333964c Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Sat, 22 Jun 2024 14:09:11 +0200 Subject: [PATCH 2/5] Run pre-commit only with Python 3.12 --- .github/workflows/pre-commit.yml | 2 +- prologix_gpib_async/_version.py | 1 + prologix_gpib_async/ip_connection.py | 1 + prologix_gpib_async/prologix_gpib_async.py | 1 + prologix_gpib_async/prologix_gpib_base.py | 1 + prologix_gpib_async/prologix_gpib_ethernet.py | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index ce42d37..44048ab 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - python-version: [ "3.10", "3.11", "3.12" ] + python-version: [ "3.12" ] steps: - name: Checkout source repository diff --git a/prologix_gpib_async/_version.py b/prologix_gpib_async/_version.py index 3ae46aa..3a2bfac 100644 --- a/prologix_gpib_async/_version.py +++ b/prologix_gpib_async/_version.py @@ -1,4 +1,5 @@ """ Version information. """ + __version__ = "1.4.13" diff --git a/prologix_gpib_async/ip_connection.py b/prologix_gpib_async/ip_connection.py index 6bc643e..3801ed7 100644 --- a/prologix_gpib_async/ip_connection.py +++ b/prologix_gpib_async/ip_connection.py @@ -3,6 +3,7 @@ version uses a connection pool to reduce the number of individual connections made to the host. This is useful for embedded devices, that can only manage a limited number of connections like the prologix adapters. """ + from __future__ import annotations import asyncio diff --git a/prologix_gpib_async/prologix_gpib_async.py b/prologix_gpib_async/prologix_gpib_async.py index 693b4ee..4b1a578 100644 --- a/prologix_gpib_async/prologix_gpib_async.py +++ b/prologix_gpib_async/prologix_gpib_async.py @@ -1,6 +1,7 @@ """ This file implements the API used by the Prologix GPIB adapters in pure python using AsyncIO. """ + from __future__ import annotations import asyncio diff --git a/prologix_gpib_async/prologix_gpib_base.py b/prologix_gpib_async/prologix_gpib_base.py index a88fe37..a5c9f9b 100644 --- a/prologix_gpib_async/prologix_gpib_base.py +++ b/prologix_gpib_async/prologix_gpib_base.py @@ -1,6 +1,7 @@ """ This file contains the base classes of a GPIB controller or device. """ + from __future__ import annotations from .ip_connection import AsyncSharedIPConnection diff --git a/prologix_gpib_async/prologix_gpib_ethernet.py b/prologix_gpib_async/prologix_gpib_ethernet.py index 5ae69c9..e0e1fc8 100644 --- a/prologix_gpib_async/prologix_gpib_ethernet.py +++ b/prologix_gpib_async/prologix_gpib_ethernet.py @@ -2,6 +2,7 @@ This file contains classes for the Prologix GPIB Ethernet adapter. The manual can be found here: http://prologix.biz/downloads/PrologixGpibEthernetManual.pdf """ + from .ip_connection import AsyncSharedIPConnection from .prologix_gpib_async import EosMode from .prologix_gpib_base import AsyncPrologixGpibController, AsyncPrologixGpibDevice From e10d25db3bd89f86d0b3e7143d5af436ee0ee901 Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Sat, 22 Jun 2024 14:18:33 +0200 Subject: [PATCH 3/5] Added missing dependecy --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 755701b..c8debfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dev = [ ] test = [ - "asyncio_mqtt", "mypy", "pylint", "simplejson", + "asyncio_mqtt", "mypy", "pylint", "setuptools", "simplejson", ] [tool.pylint.'MESSAGES CONTROL'] From ae0f611832c863f4fbabf9a528e4967e1e8c7bae Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Sat, 22 Jun 2024 14:23:44 +0200 Subject: [PATCH 4/5] Updated example to properly cache the MQTT payload and not recreate it to preserver the timestamp --- examples/advanced_mqtt/push_to_mqtt.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/advanced_mqtt/push_to_mqtt.py b/examples/advanced_mqtt/push_to_mqtt.py index 1df3882..dda229e 100755 --- a/examples/advanced_mqtt/push_to_mqtt.py +++ b/examples/advanced_mqtt/push_to_mqtt.py @@ -119,16 +119,16 @@ async def data_consumer(input_queue: asyncio.Queue[Decimal], reconnect_interval: # Only get a new value from the queue, if we have successfully sent it to the network if payload is None: value = await input_queue.get() - # convert payload to JSON - # Typically sensors return data as decimals or ints to preserve the precision - payload = json.dumps( - { - "timestamp": time.time(), # The current timestamp - "uuid": str(DEVICE_UUID), # The unique device id to identify the sender on the network - "value": value, - }, - use_decimal=True, - ) + # convert payload to JSON + # Typically sensors return data as decimals or ints to preserve the precision + payload = json.dumps( + { + "timestamp": time.time(), # The current timestamp + "uuid": str(DEVICE_UUID), # The unique device id to identify the sender on the network + "value": value, + }, + use_decimal=True, + ) await mqtt_client.publish(MQTT_TOPIC, payload=payload, qos=2) payload = None input_queue.task_done() # finally mark the job as done From 49d85c876f5e6b15aaccf9f6ba3ae6aabc965ca8 Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Sat, 22 Jun 2024 14:35:50 +0200 Subject: [PATCH 5/5] Added more pre-commit hooks --- .pre-commit-config.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11730e3..6e4bb77 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,15 +4,19 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: + - id: check-executables-have-shebangs # Check for invalid files - id: check-toml # Check Python files + - id: end-of-file-fixer - id: fix-encoding-pragma args: [--remove] - - id: end-of-file-fixer - id: mixed-line-ending args: [--fix=lf] - id: check-executables-have-shebangs + - id: requirements-txt-fixer + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] - repo: https://github.com/psf/black rev: 24.4.2 hooks: