Skip to content

Commit 83b7331

Browse files
committed
Merge branch 'v3.2.1_pick'
2 parents 8e6c753 + a804262 commit 83b7331

File tree

8 files changed

+32
-41
lines changed

8 files changed

+32
-41
lines changed

CHANGELOG.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
version 3.2.1 (picked from dev, only bugfixes)
2+
----------------------------------------------------------
3+
* add missing server.start(). (#1443)
4+
* Don't publish univeral (Python2 / Python 3) wheels (#1423)
5+
* Remove unneccesary custom LOG_LEVEL check (#1424)
6+
* Include py.typed in package (#1422)
7+
8+
Thanks to:
9+
Alex,
10+
jan iversen,
11+
Thijs W
12+
113
version 3.2.0
214
----------------------------------------------------------
315
* Add value <-> registers converter helpers. (#1413)

MAKE_RELEASE.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Prepare/make release on dev.
2828
* on local repo
2929
* git pull, check release tag is pulled
3030
* git checkout v3.0.0dev0
31-
* python3 setup.py sdist bdist_wheel --universal
31+
* python3 setup.py sdist bdist_wheel
3232
* twine upload dist/* (upload to pypi)
3333
* Double check Read me docs are updated
3434
* trigger build https://readthedocs.org/projects/pymodbus/builds/

pymodbus/logging.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class Log:
3535
:meta private:
3636
"""
3737

38-
LOG_LEVEL = logging.NOTSET
3938
_logger = logging.getLogger(__name__)
4039

4140
@classmethod
@@ -59,7 +58,6 @@ def apply_logging_config(cls, level, log_file_name):
5958
def setLevel(cls, level):
6059
"""Apply basic logging level"""
6160
cls._logger.setLevel(level)
62-
cls.LOG_LEVEL = level
6361

6462
@classmethod
6563
def build_msg(cls, txt, *args):
@@ -90,39 +88,29 @@ def build_msg(cls, txt, *args):
9088
@classmethod
9189
def info(cls, txt, *args):
9290
"""Log info messagees."""
93-
if cls.LOG_LEVEL == logging.NOTSET:
94-
cls.LOG_LEVEL = cls._logger.getEffectiveLevel()
95-
if logging.INFO >= cls.LOG_LEVEL:
91+
if cls._logger.isEnabledFor(logging.INFO):
9692
cls._logger.info(cls.build_msg(txt, *args))
9793

9894
@classmethod
9995
def debug(cls, txt, *args):
10096
"""Log debug messagees."""
101-
if cls.LOG_LEVEL == logging.NOTSET:
102-
cls.LOG_LEVEL = cls._logger.getEffectiveLevel()
103-
if logging.DEBUG >= cls.LOG_LEVEL:
97+
if cls._logger.isEnabledFor(logging.DEBUG):
10498
cls._logger.debug(cls.build_msg(txt, *args))
10599

106100
@classmethod
107101
def warning(cls, txt, *args):
108102
"""Log warning messagees."""
109-
if cls.LOG_LEVEL == logging.NOTSET:
110-
cls.LOG_LEVEL = cls._logger.getEffectiveLevel()
111-
if logging.WARNING >= cls.LOG_LEVEL:
103+
if cls._logger.isEnabledFor(logging.WARNING):
112104
cls._logger.warning(cls.build_msg(txt, *args))
113105

114106
@classmethod
115107
def error(cls, txt, *args):
116108
"""Log error messagees."""
117-
if cls.LOG_LEVEL == logging.NOTSET:
118-
cls.LOG_LEVEL = cls._logger.getEffectiveLevel()
119-
if logging.ERROR >= cls.LOG_LEVEL:
109+
if cls._logger.isEnabledFor(logging.ERROR):
120110
cls._logger.error(cls.build_msg(txt, *args))
121111

122112
@classmethod
123113
def critical(cls, txt, *args):
124114
"""Log critical messagees."""
125-
if cls.LOG_LEVEL == logging.NOTSET:
126-
cls.LOG_LEVEL = cls._logger.getEffectiveLevel()
127-
if logging.CRITICAL >= cls.LOG_LEVEL:
115+
if cls._logger.isEnabledFor(logging.CRITICAL):
128116
cls._logger.critical(cls.build_msg(txt, *args))

pymodbus/server/async_io.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,7 @@ async def StartAsyncSerialServer( # pylint: disable=invalid-name,dangerous-defa
12211221
server = ModbusSerialServer(
12221222
context, kwargs.pop("framer", ModbusAsciiFramer), identity=identity, **kwargs
12231223
)
1224+
server.start()
12241225
await _serverList.run(server, custom_functions)
12251226

12261227

pymodbus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ def __str__(self) -> str:
3737
return f"[{self.package}, version {self.short()}]"
3838

3939

40-
version = Version("pymodbus", 3, 2, 0, "")
40+
version = Version("pymodbus", 3, 2, 1, "")

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ upload_dir = build/sphinx/html
543543

544544

545545
[bdist_wheel]
546-
universal=1
547546

548547

549548
[tool:pytest]

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@
3030
setup(
3131
install_requires=install_req,
3232
extras_require=dependencies,
33+
package_data={"pymodbus": ["py.typed"]},
3334
)

test/test_logging.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
"""Test datastore."""
22
import logging
3+
from unittest.mock import patch
34

45
import pytest
56

6-
from pymodbus import pymodbus_apply_logging_config
77
from pymodbus.logging import Log
88

99

1010
class TestLogging:
1111
"""Tests of pymodbus logging."""
1212

13-
def test_log_our_default(self):
14-
"""Test default logging"""
15-
logging.getLogger().setLevel(logging.WARNING)
16-
Log.setLevel(logging.NOTSET)
17-
Log.info("test")
18-
assert Log.LOG_LEVEL == logging.WARNING
19-
Log.setLevel(logging.NOTSET)
20-
logging.getLogger().setLevel(logging.INFO)
21-
Log.info("test")
22-
assert Log.LOG_LEVEL == logging.INFO
23-
Log.setLevel(logging.NOTSET)
24-
pymodbus_apply_logging_config()
25-
assert Log.LOG_LEVEL == logging.DEBUG
26-
27-
def test_log_set_level(self):
28-
"""Test default logging"""
29-
pymodbus_apply_logging_config(logging.DEBUG)
30-
assert Log.LOG_LEVEL == logging.DEBUG
31-
pymodbus_apply_logging_config(logging.INFO)
32-
assert Log.LOG_LEVEL == logging.INFO
13+
def test_log_dont_call_build_msg(self):
14+
"""Verify that build_msg is not called unnecessary"""
15+
with patch("pymodbus.logging.Log.build_msg") as build_msg_mock:
16+
Log.setLevel(logging.INFO)
17+
Log.debug("test")
18+
build_msg_mock.assert_not_called()
19+
20+
Log.setLevel(logging.DEBUG)
21+
Log.debug("test2")
22+
build_msg_mock.assert_called_once()
3323

3424
def test_log_simple(self):
3525
"""Test simple string"""

0 commit comments

Comments
 (0)