Skip to content

Commit 1b241ac

Browse files
authored
Clean __init_ and update log module. (#1411)
1 parent cd563f8 commit 1b241ac

File tree

19 files changed

+117
-92
lines changed

19 files changed

+117
-92
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ Before opening a new issue, make sure you do the following:
2828
# code and logs here.
2929

3030
# please use the following to format logs when posting them here
31-
import logging
3231
import pymodbus
3332

34-
pymodbus.pymodbus_apply_logging_config(logging.DEBUG)
33+
pymodbus.pymodbus_apply_logging_config()
3534
```

API_changes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ PyModbus - API changes.
55
-------------
66
Version 3.2.0
77
-------------
8+
- import pymodbus.version -> from pymodbus import __version__, __version_full__
9+
- pymodbus.pymodbus_apply_logging_config(log_file_name="pymodbus.log") to enable file pymodbus_apply_logging_config
10+
- pymodbus.pymodbus_apply_logging_config have default DEBUG, it not called root settings will be used.
811
- pymodbus/interfaces/IModbusDecoder removed.
912
- pymodbus/interfaces/IModbusFramer removed.
1013
- pymodbus/interfaces/IModbusSlaveContext -> pymodbus/datastore/ModbusBaseSlaveContext.

doc/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from recommonmark.transform import AutoStructify
1313

14-
from pymodbus import __version__
14+
from pymodbus import __version__ as pymodbus_version
1515

1616

1717
parent_dir = os.path.abspath(os.pardir)
@@ -26,8 +26,8 @@
2626
project = "PyModbus"
2727
copyright = "See license"
2828
author = "Open Source volunteers"
29-
version = __version__
30-
release = __version__
29+
version = pymodbus_version
30+
release = pymodbus_version
3131
language = "en"
3232
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
3333
pygments_style = "sphinx"

doc/source/library/pymodbus.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,3 @@ Extra functions
8787
:members:
8888
:undoc-members:
8989
:show-inheritance:
90-
91-
.. automodule:: pymodbus.version
92-
:members:
93-
:undoc-members:
94-
:show-inheritance:

examples/server_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import os
3333

3434
from examples.helper import get_commandline
35+
from pymodbus import __version__ as pymodbus_version
3536
from pymodbus.datastore import (
3637
ModbusSequentialDataBlock,
3738
ModbusServerContext,
@@ -49,7 +50,6 @@
4950
StartAsyncTlsServer,
5051
StartAsyncUdpServer,
5152
)
52-
from pymodbus.version import version
5353

5454

5555
_logger = logging.getLogger()
@@ -130,7 +130,7 @@ def setup_server(args):
130130
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
131131
"ProductName": "Pymodbus Server",
132132
"ModelName": "Pymodbus Server",
133-
"MajorMinorRevision": version.short(),
133+
"MajorMinorRevision": pymodbus_version,
134134
}
135135
)
136136
return args

examples/v2.5.3/callback_server.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from multiprocessing import Queue
1111
from threading import Thread
1212

13+
# --------------------------------------------------------------------------- #
14+
# import the modbus libraries we need
15+
# --------------------------------------------------------------------------- #
16+
from pymodbus import __version__ as pymodbus_version
1317
from pymodbus.datastore import (
1418
ModbusServerContext,
1519
ModbusSlaveContext,
@@ -18,11 +22,6 @@
1822
from pymodbus.device import ModbusDeviceIdentification
1923
from pymodbus.server import StartTcpServer
2024

21-
# --------------------------------------------------------------------------- #
22-
# import the modbus libraries we need
23-
# --------------------------------------------------------------------------- #
24-
from pymodbus.version import version
25-
2625

2726
# from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer
2827

@@ -137,7 +136,7 @@ def run_callback_server():
137136
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
138137
"ProductName": "pymodbus Server",
139138
"ModelName": "pymodbus Server",
140-
"MajorMinorRevision": version.short(),
139+
"MajorMinorRevision": pymodbus_version,
141140
}
142141
)
143142

examples/v2.5.3/custom_datablock.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"""
88
import logging
99

10+
# --------------------------------------------------------------------------- #
11+
# import the modbus libraries we need
12+
# --------------------------------------------------------------------------- #
13+
from pymodbus import __version__ as pymodbus_version
1014
from pymodbus.datastore import (
1115
ModbusServerContext,
1216
ModbusSlaveContext,
@@ -15,11 +19,6 @@
1519
from pymodbus.device import ModbusDeviceIdentification
1620
from pymodbus.server import StartTcpServer
1721

18-
# --------------------------------------------------------------------------- #
19-
# import the modbus libraries we need
20-
# --------------------------------------------------------------------------- #
21-
from pymodbus.version import version
22-
2322

2423
# from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer
2524

@@ -75,7 +74,7 @@ def run_custom_db_server():
7574
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
7675
"ProductName": "pymodbus Server",
7776
"ModelName": "pymodbus Server",
78-
"MajorMinorRevision": version.short(),
77+
"MajorMinorRevision": pymodbus_version,
7978
}
8079
)
8180

examples/v2.5.3/custom_synchronous_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ def decode(self, data):
5757
"""
5858
import logging
5959

60+
from pymodbus import __version__ as pymodbus_version
6061
from pymodbus.datastore import (
6162
ModbusSequentialDataBlock,
6263
ModbusServerContext,
6364
ModbusSlaveContext,
6465
)
6566
from pymodbus.device import ModbusDeviceIdentification
6667
from pymodbus.server import StartTcpServer
67-
from pymodbus.version import version
6868

6969
from .custom_message import ( # pylint: disable=relative-beyond-top-level
7070
CustomModbusRequest,
@@ -112,7 +112,7 @@ def run_server():
112112
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
113113
"ProductName": "Pymodbus Server",
114114
"ModelName": "Pymodbus Server",
115-
"MajorMinorRevision": version.short(),
115+
"MajorMinorRevision": pymodbus_version,
116116
}
117117
)
118118

examples/v2.5.3/dbstore_update_server.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
import logging
1818
import random
1919

20+
# --------------------------------------------------------------------------- #
21+
# import the modbus libraries we need
22+
# --------------------------------------------------------------------------- #
23+
from pymodbus import __version__ as pymodbus_version
2024
from pymodbus.datastore import ModbusSequentialDataBlock, ModbusServerContext
2125
from pymodbus.datastore.database import SqlSlaveContext
2226
from pymodbus.device import ModbusDeviceIdentification
2327
from pymodbus.server import StartAsyncTcpServer
2428

25-
# --------------------------------------------------------------------------- #
26-
# import the modbus libraries we need
27-
# --------------------------------------------------------------------------- #
28-
from pymodbus.version import version
29-
3029

3130
# from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer
3231

@@ -89,7 +88,7 @@ async def run_dbstore_update_server():
8988
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
9089
"ProductName": "pymodbus Server",
9190
"ModelName": "pymodbus Server",
92-
"MajorMinorRevision": version.short(),
91+
"MajorMinorRevision": pymodbus_version,
9392
}
9493
)
9594

examples/v2.5.3/deviceinfo_showcase_server.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
from pymodbus.device import ModbusDeviceIdentification
2020
from pymodbus.server import StartTcpServer
2121

22-
# --------------------------------------------------------------------------- #
23-
# import the various server implementations
24-
# --------------------------------------------------------------------------- #
25-
from pymodbus.version import version
26-
2722

2823
# --------------------------------------------------------------------------- #
2924
# configure the service logging
@@ -57,7 +52,7 @@ def run_server():
5752
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
5853
"ProductName": "Pymodbus Server",
5954
"ModelName": "Pymodbus Server",
60-
"MajorMinorRevision": version.short(),
55+
"MajorMinorRevision": pymodbus_version,
6156
}
6257
)
6358

0 commit comments

Comments
 (0)