From 63508b6ee926f0c81f5384f03f47cd10d0732124 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 18 May 2021 16:25:13 +0200 Subject: [PATCH 1/4] Add tzinfo to uptime value --- brother/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brother/__init__.py b/brother/__init__.py index 8b9061a..0991b7b 100644 --- a/brother/__init__.py +++ b/brother/__init__.py @@ -4,7 +4,7 @@ """ import logging import re -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from typing import Any, Dict, Generator, Iterable, cast import pysnmp.hlapi.asyncio as hlapi @@ -130,10 +130,10 @@ async def async_update(self) -> DictToObj: if not self._last_uptime: data[ATTR_UPTIME] = self._last_uptime = ( # type: ignore[assignment] datetime.utcnow() - timedelta(seconds=uptime) - ).replace(microsecond=0) + ).replace(microsecond=0, tzinfo=timezone.utc) else: new_uptime = (datetime.utcnow() - timedelta(seconds=uptime)).replace( - microsecond=0 + microsecond=0, tzinfo=timezone.utc ) if abs((new_uptime - self._last_uptime).total_seconds()) > 5: data[ATTR_UPTIME] = self._last_uptime = new_uptime From 4043ede38de7c9092dfdd0fed364c9c410bb882f Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 18 May 2021 16:27:39 +0200 Subject: [PATCH 2/4] Add py.typed file --- brother/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 brother/py.typed diff --git a/brother/py.typed b/brother/py.typed new file mode 100644 index 0000000..e69de29 From c2fedc5e72399ae8374ac9dd031be7c470ebc688 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 18 May 2021 16:28:06 +0200 Subject: [PATCH 3/4] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 924084a..0b4ad00 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="brother", - version="1.0.1", + version="1.0.2", author="Maciej Bieniek", description="Python wrapper for getting data from Brother laser and inkjet \ printers via SNMP.", From fea011d936ac16bbad8f5692f5e46d056b488fd9 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 18 May 2021 21:46:35 +0200 Subject: [PATCH 4/4] Fix tests --- tests/test_init.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_init.py b/tests/test_init.py index b309990..3e7aa53 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -37,7 +37,7 @@ async def test_hl_l2340dw_model(): assert getattr(sensors, "status") == "oczekiwanie" assert getattr(sensors, "black_toner") == 80 assert getattr(sensors, "page_counter") == 986 - assert getattr(sensors, "uptime").isoformat() == "2019-09-24T12:14:56" + assert getattr(sensors, "uptime").isoformat() == "2019-09-24T12:14:56+00:00" @pytest.mark.asyncio @@ -107,7 +107,7 @@ async def test_mfc_5490cn_model(): assert brother.serial == "serial_number" assert getattr(sensors, "status") == "sleep mode" assert getattr(sensors, "page_counter") == 8989 - assert getattr(sensors, "uptime").isoformat() == "2019-11-02T23:44:02" + assert getattr(sensors, "uptime").isoformat() == "2019-11-02T23:44:02+00:00" @pytest.mark.asyncio @@ -153,7 +153,7 @@ async def test_dcp_7070dw_model(): assert getattr(sensors, "drum_counter") == 1603 assert getattr(sensors, "drum_remaining_life") == 88 assert getattr(sensors, "drum_remaining_pages") == 10397 - assert getattr(sensors, "uptime").isoformat() == "2018-11-30T13:43:26" + assert getattr(sensors, "uptime").isoformat() == "2018-11-30T13:43:26+00:00" # test uptime logic, uptime increased by 10 minutes data["1.3.6.1.2.1.1.3.0"] = "2987742561" @@ -164,7 +164,7 @@ async def test_dcp_7070dw_model(): brother.shutdown() - assert getattr(sensors, "uptime").isoformat() == "2018-11-30T13:53:26" + assert getattr(sensors, "uptime").isoformat() == "2018-11-30T13:53:26+00:00" @pytest.mark.asyncio