From b311d49bf0135b7b8bbc4ba7d9dee75cda76a734 Mon Sep 17 00:00:00 2001 From: dices Date: Sat, 22 Sep 2018 16:51:24 -0400 Subject: [PATCH 1/3] Renamed pymodbus.client.async to pymodbus.client.asynchronous Renamed pymodbus.server.async to pymodbus.server.asynchronous Modified asyncio.async to use asyncio.ensure_future Added missing prompt_toolkit dependency to requirements-docs.txt Updated references in documentation Updated examples --- ... pymodbus.client.asynchronous.asyncio.rst} | 2 +- ... pymodbus.client.asynchronous.factory.rst} | 8 +-- ...c.rst => pymodbus.client.asynchronous.rst} | 22 +++---- ...modbus.client.asynchronous.schedulers.rst} | 2 +- ... pymodbus.client.asynchronous.tornado.rst} | 2 +- ... pymodbus.client.asynchronous.twisted.rst} | 2 +- doc/source/library/pymodbus.client.rst | 2 +- doc/source/library/pymodbus.server.rst | 4 +- examples/common/async_asyncio_client.py | 10 +-- .../common/async_asyncio_serial_client.py | 6 +- examples/common/async_tornado_client.py | 6 +- .../common/async_tornado_client_serial.py | 4 +- examples/common/async_twisted_client.py | 6 +- .../common/async_twisted_client_serial.py | 6 +- examples/common/asynchronous_processor.py | 2 +- examples/common/asynchronous_server.py | 6 +- examples/common/callback_server.py | 2 +- examples/common/custom_datablock.py | 2 +- examples/common/dbstore_update_server.py | 2 +- examples/common/synchronous_client.py | 2 +- examples/common/updating_server.py | 2 +- .../asynchronous_asyncio_serial_client.py | 4 +- examples/contrib/modbus_scraper.py | 2 +- examples/contrib/modbus_simulator.py | 2 +- .../functional/asynchronous_ascii_client.py | 2 +- .../functional/asynchronous_rtu_client.py | 2 +- .../functional/asynchronous_tcp_client.py | 2 +- examples/gui/bottle/frontend.py | 2 +- examples/gui/gtk/simulator.py | 2 +- examples/gui/gui_common.py | 2 +- examples/gui/tk/simulator.py | 2 +- examples/gui/wx/simulator.py | 2 +- examples/twisted/plugins/pymodbus_plugin.py | 2 +- .../{async => asynchronous}/__init__.py | 16 ++--- .../asyncio/__init__.py | 22 +++---- .../deprecated/__init__.py | 14 ++-- .../deprecated/asynchronous.py} | 6 +- .../factory/__init__.py | 0 .../{async => asynchronous}/factory/serial.py | 18 ++--- .../{async => asynchronous}/factory/tcp.py | 18 ++--- .../{async => asynchronous}/factory/udp.py | 14 ++-- .../client/{async => asynchronous}/mixins.py | 2 +- .../schedulers/__init__.py | 0 .../client/{async => asynchronous}/serial.py | 6 +- .../client/{async => asynchronous}/tcp.py | 6 +- .../client/{async => asynchronous}/thread.py | 0 .../tornado/__init__.py | 6 +- .../twisted/__init__.py | 6 +- .../client/{async => asynchronous}/udp.py | 6 +- pymodbus/framer/__init__.py | 2 +- pymodbus/server/{async.py => asynchronous.py} | 0 requirements-docs.txt | 2 +- test/test_client_async.py | 30 ++++----- test/test_client_async_asyncio.py | 14 ++-- test/test_client_async_tornado.py | 66 +++++++++---------- test/test_client_async_twisted.py | 6 +- test/test_server_async.py | 18 ++--- tox.ini | 4 +- 58 files changed, 204 insertions(+), 204 deletions(-) rename doc/source/library/{pymodbus.client.async.asyncio.rst => pymodbus.client.asynchronous.asyncio.rst} (72%) rename doc/source/library/{pymodbus.client.async.factory.rst => pymodbus.client.asynchronous.factory.rst} (73%) rename doc/source/library/{pymodbus.client.async.rst => pymodbus.client.asynchronous.rst} (58%) rename doc/source/library/{pymodbus.client.async.schedulers.rst => pymodbus.client.asynchronous.schedulers.rst} (72%) rename doc/source/library/{pymodbus.client.async.tornado.rst => pymodbus.client.asynchronous.tornado.rst} (72%) rename doc/source/library/{pymodbus.client.async.twisted.rst => pymodbus.client.asynchronous.twisted.rst} (72%) rename pymodbus/client/{async => asynchronous}/__init__.py (60%) rename pymodbus/client/{async => asynchronous}/asyncio/__init__.py (96%) rename pymodbus/client/{async => asynchronous}/deprecated/__init__.py (74%) rename pymodbus/client/{async/deprecated/async.py => asynchronous/deprecated/asynchronous.py} (97%) rename pymodbus/client/{async => asynchronous}/factory/__init__.py (100%) rename pymodbus/client/{async => asynchronous}/factory/serial.py (85%) rename pymodbus/client/{async => asynchronous}/factory/tcp.py (85%) rename pymodbus/client/{async => asynchronous}/factory/udp.py (85%) rename pymodbus/client/{async => asynchronous}/mixins.py (97%) rename pymodbus/client/{async => asynchronous}/schedulers/__init__.py (100%) rename pymodbus/client/{async => asynchronous}/serial.py (92%) rename pymodbus/client/{async => asynchronous}/tcp.py (88%) rename pymodbus/client/{async => asynchronous}/thread.py (100%) rename pymodbus/client/{async => asynchronous}/tornado/__init__.py (97%) rename pymodbus/client/{async => asynchronous}/twisted/__init__.py (97%) rename pymodbus/client/{async => asynchronous}/udp.py (88%) rename pymodbus/server/{async.py => asynchronous.py} (100%) diff --git a/doc/source/library/pymodbus.client.async.asyncio.rst b/doc/source/library/pymodbus.client.asynchronous.asyncio.rst similarity index 72% rename from doc/source/library/pymodbus.client.async.asyncio.rst rename to doc/source/library/pymodbus.client.asynchronous.asyncio.rst index 0d5ea5fff..3c620c291 100644 --- a/doc/source/library/pymodbus.client.async.asyncio.rst +++ b/doc/source/library/pymodbus.client.asynchronous.asyncio.rst @@ -1,7 +1,7 @@ pymodbus\.client\.async\.asyncio package ======================================== -.. automodule:: pymodbus.client.async.asyncio +.. automodule:: pymodbus.client.asynchronous.asyncio :members: :undoc-members: :show-inheritance: diff --git a/doc/source/library/pymodbus.client.async.factory.rst b/doc/source/library/pymodbus.client.asynchronous.factory.rst similarity index 73% rename from doc/source/library/pymodbus.client.async.factory.rst rename to doc/source/library/pymodbus.client.asynchronous.factory.rst index 3eeecc212..c7068ce26 100644 --- a/doc/source/library/pymodbus.client.async.factory.rst +++ b/doc/source/library/pymodbus.client.asynchronous.factory.rst @@ -1,7 +1,7 @@ pymodbus\.client\.async\.factory package ======================================== -.. automodule:: pymodbus.client.async.factory +.. automodule:: pymodbus.client.asynchronous.factory :members: :undoc-members: :show-inheritance: @@ -12,7 +12,7 @@ Submodules pymodbus\.client\.async\.factory\.serial module ----------------------------------------------- -.. automodule:: pymodbus.client.async.factory.serial +.. automodule:: pymodbus.client.asynchronous.factory.serial :members: :undoc-members: :show-inheritance: @@ -20,7 +20,7 @@ pymodbus\.client\.async\.factory\.serial module pymodbus\.client\.async\.factory\.tcp module -------------------------------------------- -.. automodule:: pymodbus.client.async.factory.tcp +.. automodule:: pymodbus.client.asynchronous.factory.tcp :members: :undoc-members: :show-inheritance: @@ -28,7 +28,7 @@ pymodbus\.client\.async\.factory\.tcp module pymodbus\.client\.async\.factory\.udp module -------------------------------------------- -.. automodule:: pymodbus.client.async.factory.udp +.. automodule:: pymodbus.client.asynchronous.factory.udp :members: :undoc-members: :show-inheritance: diff --git a/doc/source/library/pymodbus.client.async.rst b/doc/source/library/pymodbus.client.asynchronous.rst similarity index 58% rename from doc/source/library/pymodbus.client.async.rst rename to doc/source/library/pymodbus.client.asynchronous.rst index 04ce81281..01b37d8fd 100644 --- a/doc/source/library/pymodbus.client.async.rst +++ b/doc/source/library/pymodbus.client.asynchronous.rst @@ -1,7 +1,7 @@ -pymodbus\.client\.async package +pymodbus\.client\.asynchronous package =============================== -.. automodule:: pymodbus.client.async +.. automodule:: pymodbus.client.asynchronous :members: :undoc-members: :show-inheritance: @@ -11,11 +11,11 @@ Subpackages .. toctree:: - pymodbus.client.async.asyncio - pymodbus.client.async.factory - pymodbus.client.async.schedulers - pymodbus.client.async.tornado - pymodbus.client.async.twisted + pymodbus.client.asynchronous.asyncio + pymodbus.client.asynchronous.factory + pymodbus.client.asynchronous.schedulers + pymodbus.client.asynchronous.tornado + pymodbus.client.asynchronous.twisted Submodules ---------- @@ -23,7 +23,7 @@ Submodules pymodbus\.client\.async\.serial module -------------------------------------- -.. automodule:: pymodbus.client.async.serial +.. automodule:: pymodbus.client.asynchronous.serial :members: :undoc-members: :show-inheritance: @@ -31,7 +31,7 @@ pymodbus\.client\.async\.serial module pymodbus\.client\.async\.tcp module ----------------------------------- -.. automodule:: pymodbus.client.async.tcp +.. automodule:: pymodbus.client.asynchronous.tcp :members: :undoc-members: :show-inheritance: @@ -39,7 +39,7 @@ pymodbus\.client\.async\.tcp module pymodbus\.client\.async\.thread module -------------------------------------- -.. automodule:: pymodbus.client.async.thread +.. automodule:: pymodbus.client.asynchronous.thread :members: :undoc-members: :show-inheritance: @@ -47,7 +47,7 @@ pymodbus\.client\.async\.thread module pymodbus\.client\.async\.udp module ----------------------------------- -.. automodule:: pymodbus.client.async.udp +.. automodule:: pymodbus.client.asynchronous.udp :members: :undoc-members: :show-inheritance: diff --git a/doc/source/library/pymodbus.client.async.schedulers.rst b/doc/source/library/pymodbus.client.asynchronous.schedulers.rst similarity index 72% rename from doc/source/library/pymodbus.client.async.schedulers.rst rename to doc/source/library/pymodbus.client.asynchronous.schedulers.rst index 113aeb147..b29cb441e 100644 --- a/doc/source/library/pymodbus.client.async.schedulers.rst +++ b/doc/source/library/pymodbus.client.asynchronous.schedulers.rst @@ -1,7 +1,7 @@ pymodbus\.client\.async\.schedulers package =========================================== -.. automodule:: pymodbus.client.async.schedulers +.. automodule:: pymodbus.client.asynchronous.schedulers :members: :undoc-members: :show-inheritance: diff --git a/doc/source/library/pymodbus.client.async.tornado.rst b/doc/source/library/pymodbus.client.asynchronous.tornado.rst similarity index 72% rename from doc/source/library/pymodbus.client.async.tornado.rst rename to doc/source/library/pymodbus.client.asynchronous.tornado.rst index 2c895399f..2fc4aaf55 100644 --- a/doc/source/library/pymodbus.client.async.tornado.rst +++ b/doc/source/library/pymodbus.client.asynchronous.tornado.rst @@ -1,7 +1,7 @@ pymodbus\.client\.async\.tornado package ======================================== -.. automodule:: pymodbus.client.async.tornado +.. automodule:: pymodbus.client.asynchronous.tornado :members: :undoc-members: :show-inheritance: diff --git a/doc/source/library/pymodbus.client.async.twisted.rst b/doc/source/library/pymodbus.client.asynchronous.twisted.rst similarity index 72% rename from doc/source/library/pymodbus.client.async.twisted.rst rename to doc/source/library/pymodbus.client.asynchronous.twisted.rst index 8bfe9d7e7..dd6dff034 100644 --- a/doc/source/library/pymodbus.client.async.twisted.rst +++ b/doc/source/library/pymodbus.client.asynchronous.twisted.rst @@ -1,7 +1,7 @@ pymodbus\.client\.async\.twisted package ======================================== -.. automodule:: pymodbus.client.async.twisted +.. automodule:: pymodbus.client.asynchronous.twisted :members: :undoc-members: :show-inheritance: diff --git a/doc/source/library/pymodbus.client.rst b/doc/source/library/pymodbus.client.rst index 774f58a2d..cf8e1df25 100644 --- a/doc/source/library/pymodbus.client.rst +++ b/doc/source/library/pymodbus.client.rst @@ -11,7 +11,7 @@ Subpackages .. toctree:: - pymodbus.client.async + pymodbus.client.asynchronous Submodules ---------- diff --git a/doc/source/library/pymodbus.server.rst b/doc/source/library/pymodbus.server.rst index 297540973..e2d8e8b09 100644 --- a/doc/source/library/pymodbus.server.rst +++ b/doc/source/library/pymodbus.server.rst @@ -9,10 +9,10 @@ pymodbus\.server package Submodules ---------- -pymodbus\.server\.async module +pymodbus\.server\.asynchronous module ------------------------------ -.. automodule:: pymodbus.server.async +.. automodule:: pymodbus.server.asynchronous :members: :undoc-members: :show-inheritance: diff --git a/examples/common/async_asyncio_client.py b/examples/common/async_asyncio_client.py index d4dbb9774..5aefd6bd0 100644 --- a/examples/common/async_asyncio_client.py +++ b/examples/common/async_asyncio_client.py @@ -13,12 +13,12 @@ import asyncio import logging # ----------------------------------------------------------------------- # - # Import the required async client + # Import the required asynchronous client # ----------------------------------------------------------------------- # - from pymodbus.client.async.tcp import AsyncModbusTCPClient as ModbusClient - # from pymodbus.client.async.udp import ( + from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient as ModbusClient + # from pymodbus.client.asynchronous.udp import ( # AsyncModbusUDPClient as ModbusClient) - from pymodbus.client.async import schedulers + from pymodbus.client.asynchronous import schedulers else: import sys @@ -68,7 +68,7 @@ async def start_async_test(client): # are not known to these tests. Furthermore, some use the same memory # blocks for the two sets, so a change to one is a change to the other. # Keep both of these cases in mind when testing as the following will - # _only_ pass with the supplied async modbus server (script supplied). + # _only_ pass with the supplied asynchronous modbus server (script supplied). # ----------------------------------------------------------------------- # log.debug("Write to a Coil and read back") rq = await client.write_coil(0, True, unit=UNIT) diff --git a/examples/common/async_asyncio_serial_client.py b/examples/common/async_asyncio_serial_client.py index 1ac6c4c87..95d7a44d0 100755 --- a/examples/common/async_asyncio_serial_client.py +++ b/examples/common/async_asyncio_serial_client.py @@ -12,9 +12,9 @@ if IS_PYTHON3 and PYTHON_VERSION >= (3, 4): import logging import asyncio - from pymodbus.client.async.serial import ( + from pymodbus.client.asynchronous.serial import ( AsyncModbusSerialClient as ModbusClient) - from pymodbus.client.async import schedulers + from pymodbus.client.asynchronous import schedulers else: import sys sys.stderr("This example needs to be run only on python 3.4 and above") @@ -63,7 +63,7 @@ async def start_async_test(client): # Furthermore, some use the same memory blocks for the two sets, # so a change to one is a change to the other. # Keep both of these cases in mind when testing as the following will - # _only_ pass with the supplied async modbus server (script supplied). + # _only_ pass with the supplied asynchronous modbus server (script supplied). # ----------------------------------------------------------------------- # log.debug("Write to a Coil and read back") rq = await client.write_coil(0, True, unit=UNIT) diff --git a/examples/common/async_tornado_client.py b/examples/common/async_tornado_client.py index 4c3d7efd2..c35ef7cdd 100755 --- a/examples/common/async_tornado_client.py +++ b/examples/common/async_tornado_client.py @@ -9,14 +9,14 @@ import functools from tornado.ioloop import IOLoop -from pymodbus.client.async import schedulers +from pymodbus.client.asynchronous import schedulers # ---------------------------------------------------------------------------# # choose the requested modbus protocol # ---------------------------------------------------------------------------# -# from pymodbus.client.async.udp import AsyncModbusUDPClient as ModbusClient -from pymodbus.client.async.tcp import AsyncModbusTCPClient as ModbusClient +# from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient as ModbusClient +from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient as ModbusClient # ---------------------------------------------------------------------------# # configure the client logging diff --git a/examples/common/async_tornado_client_serial.py b/examples/common/async_tornado_client_serial.py index a3f4cb1fb..74ee932e8 100755 --- a/examples/common/async_tornado_client_serial.py +++ b/examples/common/async_tornado_client_serial.py @@ -12,13 +12,13 @@ import functools from tornado.ioloop import IOLoop -from pymodbus.client.async import schedulers +from pymodbus.client.asynchronous import schedulers # ---------------------------------------------------------------------------# # choose the requested modbus protocol # ---------------------------------------------------------------------------# -from pymodbus.client.async.serial import AsyncModbusSerialClient +from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient # ---------------------------------------------------------------------------# # configure the client logging diff --git a/examples/common/async_twisted_client.py b/examples/common/async_twisted_client.py index 4916f1606..d52262294 100755 --- a/examples/common/async_twisted_client.py +++ b/examples/common/async_twisted_client.py @@ -12,9 +12,9 @@ from twisted.internet import reactor -from pymodbus.client.async.tcp import AsyncModbusTCPClient -# from pymodbus.client.async.udp import AsyncModbusUDPClient -from pymodbus.client.async import schedulers +from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient +# from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient +from pymodbus.client.asynchronous import schedulers # --------------------------------------------------------------------------- # # choose the requested modbus protocol diff --git a/examples/common/async_twisted_client_serial.py b/examples/common/async_twisted_client_serial.py index 056a0e646..f7230cb93 100755 --- a/examples/common/async_twisted_client_serial.py +++ b/examples/common/async_twisted_client_serial.py @@ -8,9 +8,9 @@ """ from twisted.internet import reactor -from pymodbus.client.async import schedulers -from pymodbus.client.async.serial import AsyncModbusSerialClient -from pymodbus.client.async.twisted import ModbusClientProtocol +from pymodbus.client.asynchronous import schedulers +from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient +from pymodbus.client.asynchronous.twisted import ModbusClientProtocol import logging logging.basicConfig() diff --git a/examples/common/asynchronous_processor.py b/examples/common/asynchronous_processor.py index e193d12ee..bc74bfe80 100755 --- a/examples/common/asynchronous_processor.py +++ b/examples/common/asynchronous_processor.py @@ -12,7 +12,7 @@ from twisted.internet import serialport, reactor from twisted.internet.protocol import ClientFactory from pymodbus.factory import ClientDecoder -from pymodbus.client.async.twisted import ModbusClientProtocol +from pymodbus.client.asynchronous.twisted import ModbusClientProtocol # --------------------------------------------------------------------------- # # Choose the framer you want to use diff --git a/examples/common/asynchronous_server.py b/examples/common/asynchronous_server.py index 2186698cc..f961c62d9 100755 --- a/examples/common/asynchronous_server.py +++ b/examples/common/asynchronous_server.py @@ -10,9 +10,9 @@ # --------------------------------------------------------------------------- # # import the various server implementations # --------------------------------------------------------------------------- # -from pymodbus.server.async import StartTcpServer -from pymodbus.server.async import StartUdpServer -from pymodbus.server.async import StartSerialServer +from pymodbus.server.asynchronous import StartTcpServer +from pymodbus.server.asynchronous import StartUdpServer +from pymodbus.server.asynchronous import StartSerialServer from pymodbus.device import ModbusDeviceIdentification from pymodbus.datastore import ModbusSequentialDataBlock diff --git a/examples/common/callback_server.py b/examples/common/callback_server.py index 045ead0ef..b04110e30 100755 --- a/examples/common/callback_server.py +++ b/examples/common/callback_server.py @@ -10,7 +10,7 @@ # --------------------------------------------------------------------------- # # import the modbus libraries we need # --------------------------------------------------------------------------- # -from pymodbus.server.async import StartTcpServer +from pymodbus.server.asynchronous import StartTcpServer from pymodbus.device import ModbusDeviceIdentification from pymodbus.datastore import ModbusSparseDataBlock from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext diff --git a/examples/common/custom_datablock.py b/examples/common/custom_datablock.py index a9873bcb6..db0d715bb 100755 --- a/examples/common/custom_datablock.py +++ b/examples/common/custom_datablock.py @@ -10,7 +10,7 @@ # import the modbus libraries we need # --------------------------------------------------------------------------- # from __future__ import print_function -from pymodbus.server.async import StartTcpServer +from pymodbus.server.asynchronous import StartTcpServer from pymodbus.device import ModbusDeviceIdentification from pymodbus.datastore import ModbusSparseDataBlock from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext diff --git a/examples/common/dbstore_update_server.py b/examples/common/dbstore_update_server.py index 7119a31b2..5de74c31d 100644 --- a/examples/common/dbstore_update_server.py +++ b/examples/common/dbstore_update_server.py @@ -16,7 +16,7 @@ # --------------------------------------------------------------------------- # # import the modbus libraries we need # --------------------------------------------------------------------------- # -from pymodbus.server.async import StartTcpServer +from pymodbus.server.asynchronous import StartTcpServer from pymodbus.device import ModbusDeviceIdentification from pymodbus.datastore import ModbusSequentialDataBlock from pymodbus.datastore import ModbusServerContext diff --git a/examples/common/synchronous_client.py b/examples/common/synchronous_client.py index b21f4f77a..f6ad09c56 100755 --- a/examples/common/synchronous_client.py +++ b/examples/common/synchronous_client.py @@ -92,7 +92,7 @@ def run_sync_client(): # are not known to these tests. Furthermore, some use the same memory # blocks for the two sets, so a change to one is a change to the other. # Keep both of these cases in mind when testing as the following will - # _only_ pass with the supplied async modbus server (script supplied). + # _only_ pass with the supplied asynchronous modbus server (script supplied). # ----------------------------------------------------------------------- # log.debug("Write to a Coil and read back") rq = client.write_coil(0, True, unit=UNIT) diff --git a/examples/common/updating_server.py b/examples/common/updating_server.py index 7b7b6be98..99fc33b8c 100755 --- a/examples/common/updating_server.py +++ b/examples/common/updating_server.py @@ -15,7 +15,7 @@ # --------------------------------------------------------------------------- # # import the modbus libraries we need # --------------------------------------------------------------------------- # -from pymodbus.server.async import StartTcpServer +from pymodbus.server.asynchronous import StartTcpServer from pymodbus.device import ModbusDeviceIdentification from pymodbus.datastore import ModbusSequentialDataBlock from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext diff --git a/examples/contrib/asynchronous_asyncio_serial_client.py b/examples/contrib/asynchronous_asyncio_serial_client.py index e4b02f50c..ec48cf35b 100755 --- a/examples/contrib/asynchronous_asyncio_serial_client.py +++ b/examples/contrib/asynchronous_asyncio_serial_client.py @@ -2,7 +2,7 @@ if IS_PYTHON3 and PYTHON_VERSION >= (3, 4): import asyncio from serial_asyncio import create_serial_connection - from pymodbus.client.async.asyncio import ModbusClientProtocol + from pymodbus.client.asynchronous.asyncio import ModbusClientProtocol from pymodbus.transaction import ModbusAsciiFramer, ModbusRtuFramer from pymodbus.factory import ClientDecoder else: @@ -43,7 +43,7 @@ async def start_async_test(client): # are not known to these tests. Furthermore, some use the same memory # blocks for the two sets, so a change to one is a change to the other. # Keep both of these cases in mind when testing as the following will - # _only_ pass with the supplied async modbus server (script supplied). + # _only_ pass with the supplied asynchronous modbus server (script supplied). # ----------------------------------------------------------------------- # log.debug("Write to a Coil and read back") rq = await client.write_coil(0, True, unit=UNIT) diff --git a/examples/contrib/modbus_scraper.py b/examples/contrib/modbus_scraper.py index ac656222d..ea12368b0 100755 --- a/examples/contrib/modbus_scraper.py +++ b/examples/contrib/modbus_scraper.py @@ -11,7 +11,7 @@ from pymodbus.datastore import ModbusSequentialDataBlock from pymodbus.datastore import ModbusSlaveContext from pymodbus.factory import ClientDecoder -from pymodbus.client.async.twisted import ModbusClientProtocol +from pymodbus.client.asynchronous.twisted import ModbusClientProtocol # -------------------------------------------------------------------------- # # Configure the client logging diff --git a/examples/contrib/modbus_simulator.py b/examples/contrib/modbus_simulator.py index 6f9e4253a..d0dc503f1 100644 --- a/examples/contrib/modbus_simulator.py +++ b/examples/contrib/modbus_simulator.py @@ -8,7 +8,7 @@ from optparse import OptionParser from twisted.internet import reactor -from pymodbus.server.async import StartTcpServer +from pymodbus.server.asynchronous import StartTcpServer from pymodbus.datastore import ModbusServerContext,ModbusSlaveContext # -------------------------------------------------------------------------- # diff --git a/examples/functional/asynchronous_ascii_client.py b/examples/functional/asynchronous_ascii_client.py index 2fb057450..582690a0f 100644 --- a/examples/functional/asynchronous_ascii_client.py +++ b/examples/functional/asynchronous_ascii_client.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import unittest -from pymodbus.client.async import ModbusSerialClient as ModbusClient +from pymodbus.client.asynchronous import ModbusSerialClient as ModbusClient from base_runner import Runner class AsynchronousAsciiClient(Runner, unittest.TestCase): diff --git a/examples/functional/asynchronous_rtu_client.py b/examples/functional/asynchronous_rtu_client.py index 5df8254af..a92905e59 100644 --- a/examples/functional/asynchronous_rtu_client.py +++ b/examples/functional/asynchronous_rtu_client.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import unittest -from pymodbus.client.async import ModbusSerialClient as ModbusClient +from pymodbus.client.asynchronous import ModbusSerialClient as ModbusClient from base_runner import Runner class AsynchronousRtuClient(Runner, unittest.TestCase): diff --git a/examples/functional/asynchronous_tcp_client.py b/examples/functional/asynchronous_tcp_client.py index 3cfffe0be..1b9e336b0 100644 --- a/examples/functional/asynchronous_tcp_client.py +++ b/examples/functional/asynchronous_tcp_client.py @@ -2,7 +2,7 @@ import unittest from twisted.internet import reactor, protocol from pymodbus.constants import Defaults -from pymodbus.client.async import ModbusClientProtocol +from pymodbus.client.asynchronous import ModbusClientProtocol from base_runner import Runner class AsynchronousTcpClient(Runner, unittest.TestCase): diff --git a/examples/gui/bottle/frontend.py b/examples/gui/bottle/frontend.py index 56ef04ee7..a09fb0d15 100644 --- a/examples/gui/bottle/frontend.py +++ b/examples/gui/bottle/frontend.py @@ -260,7 +260,7 @@ def RunDebugModbusFrontend(server, port=8080): # ------------------------------------------------------------ # an example server configuration # ------------------------------------------------------------ - from pymodbus.server.async import ModbusServerFactory + from pymodbus.server.asynchronous import ModbusServerFactory from pymodbus.constants import Defaults from pymodbus.device import ModbusDeviceIdentification from pymodbus.datastore import ModbusSequentialDataBlock diff --git a/examples/gui/gtk/simulator.py b/examples/gui/gtk/simulator.py index 56cd9482b..d73c89e2f 100755 --- a/examples/gui/gtk/simulator.py +++ b/examples/gui/gtk/simulator.py @@ -20,7 +20,7 @@ # --------------------------------------------------------------------------- # from twisted.internet import reactor from twisted.internet import error as twisted_error -from pymodbus.server.async import ModbusServerFactory +from pymodbus.server.asynchronous import ModbusServerFactory from pymodbus.datastore import ModbusServerContext,ModbusSlaveContext #--------------------------------------------------------------------------# diff --git a/examples/gui/gui_common.py b/examples/gui/gui_common.py index 8ac4088fa..b180115f8 100755 --- a/examples/gui/gui_common.py +++ b/examples/gui/gui_common.py @@ -12,7 +12,7 @@ # -------------------------------------------------------------------------- # from twisted.internet import reactor from twisted.internet import error as twisted_error -from pymodbus.server.async import ModbusServerFactory +from pymodbus.server.asynchronous import ModbusServerFactory from pymodbus.datastore import ModbusServerContext,ModbusSlaveContext # -------------------------------------------------------------------------- # diff --git a/examples/gui/tk/simulator.py b/examples/gui/tk/simulator.py index 316d10ad2..9598f0dfe 100755 --- a/examples/gui/tk/simulator.py +++ b/examples/gui/tk/simulator.py @@ -24,7 +24,7 @@ # --------------------------------------------------------------------------- # from twisted.internet import reactor from twisted.internet import error as twisted_error -from pymodbus.server.async import ModbusServerFactory +from pymodbus.server.asynchronous import ModbusServerFactory from pymodbus.datastore import ModbusServerContext,ModbusSlaveContext #--------------------------------------------------------------------------# diff --git a/examples/gui/wx/simulator.py b/examples/gui/wx/simulator.py index 519daa164..787de5509 100755 --- a/examples/gui/wx/simulator.py +++ b/examples/gui/wx/simulator.py @@ -22,7 +22,7 @@ # --------------------------------------------------------------------------- # from twisted.internet import reactor from twisted.internet import error as twisted_error -from pymodbus.server.async import ModbusServerFactory +from pymodbus.server.asynchronous import ModbusServerFactory from pymodbus.datastore import ModbusServerContext,ModbusSlaveContext #--------------------------------------------------------------------------# diff --git a/examples/twisted/plugins/pymodbus_plugin.py b/examples/twisted/plugins/pymodbus_plugin.py index 9625b6b1b..f6d4fcd6f 100644 --- a/examples/twisted/plugins/pymodbus_plugin.py +++ b/examples/twisted/plugins/pymodbus_plugin.py @@ -8,7 +8,7 @@ from twisted.application import internet from pymodbus.constants import Defaults -from pymodbus.server.async import ModbusServerFactory +from pymodbus.server.asynchronous import ModbusServerFactory from pymodbus.transaction import ModbusSocketFramer from pymodbus.internal.ptwisted import InstallManagementConsole diff --git a/pymodbus/client/async/__init__.py b/pymodbus/client/asynchronous/__init__.py similarity index 60% rename from pymodbus/client/async/__init__.py rename to pymodbus/client/asynchronous/__init__.py index d14d0dd32..17af1610e 100644 --- a/pymodbus/client/async/__init__.py +++ b/pymodbus/client/asynchronous/__init__.py @@ -4,21 +4,21 @@ Example run:: - from pymodbus.client.async import schedulers + from pymodbus.client.asynchronous import schedulers # Import The clients - from pymodbus.client.async.tcp import AsyncModbusTCPClient as Client - from pymodbus.client.async.serial import AsyncModbusSerialClient as Client - from pymodbus.client.async.udp import AsyncModbusUDPClient as Client + from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient as Client + from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient as Client + from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient as Client - # For tornado based async client use + # For tornado based asynchronous client use event_loop, future = Client(schedulers.IO_LOOP, port=5020) - # For twisted based async client use + # For twisted based asynchronous client use event_loop, future = Client(schedulers.REACTOR, port=5020) - # For asyncio based async client use + # For asyncio based asynchronous client use event_loop, client = Client(schedulers.ASYNC_IO, port=5020) # Here event_loop is a thread which would control the backend and future is @@ -31,4 +31,4 @@ # For asyncio the actual client is returned and event loop is asyncio loop """ -from pymodbus.client.async.deprecated.async import * +from pymodbus.client.asynchronous.deprecated.asynchronous import * diff --git a/pymodbus/client/async/asyncio/__init__.py b/pymodbus/client/asynchronous/asyncio/__init__.py similarity index 96% rename from pymodbus/client/async/asyncio/__init__.py rename to pymodbus/client/asynchronous/asyncio/__init__.py index c7bde65c1..baa9f71ec 100644 --- a/pymodbus/client/async/asyncio/__init__.py +++ b/pymodbus/client/asynchronous/asyncio/__init__.py @@ -5,7 +5,7 @@ import asyncio import functools from pymodbus.exceptions import ConnectionException -from pymodbus.client.async.mixins import AsyncModbusClientMixin +from pymodbus.client.asynchronous.mixins import AsyncModbusClientMixin from pymodbus.compat import byte2int import logging @@ -286,7 +286,7 @@ def _connect(self): self.port) except Exception as ex: _logger.warning('Failed to connect: %s' % ex) - asyncio.async(self._reconnect(), loop=self.loop) + asyncio.ensure_future(self._reconnect(), loop=self.loop) else: _logger.info('Connected to %s:%s.' % (self.host, self.port)) self.reset_delay() @@ -316,7 +316,7 @@ def protocol_lost_connection(self, protocol): self.connected = False self.protocol = None if self.host: - asyncio.async(self._reconnect(), loop=self.loop) + asyncio.ensure_future(self._reconnect(), loop=self.loop) else: _logger.error('Factory protocol disconnect callback called while not connected.') @@ -384,7 +384,7 @@ def connect(self): _logger.info('Connected to %s:%s.' % (self.host, self.port)) except Exception as ex: _logger.warning('Failed to connect: %s' % ex) - # asyncio.async(self._reconnect(), loop=self.loop) + # asyncio.asynchronous(self._reconnect(), loop=self.loop) def protocol_made_connection(self, protocol): """ @@ -411,7 +411,7 @@ def protocol_lost_connection(self, protocol): self.connected = False self.protocol = None # if self.host: - # asyncio.async(self._reconnect(), loop=self.loop) + # asyncio.asynchronous(self._reconnect(), loop=self.loop) else: _logger.error('Factory protocol disconnect' ' callback called while not connected.') @@ -456,7 +456,7 @@ def reset_delay(self): @asyncio.coroutine def start(self, host, port=502): """ - Start reconnecting async udp client + Start reconnecting asynchronous udp client :param host: Host IP to connect :param port: Host port to connect :return: @@ -513,7 +513,7 @@ def _connect(self): _logger.info('Connected to %s:%s.' % (self.host, self.port)) except Exception as ex: _logger.warning('Failed to connect: %s' % ex) - asyncio.async(self._reconnect(), loop=self.loop) + asyncio.ensure_future(self._reconnect(), loop=self.loop) def protocol_made_connection(self, protocol): """ @@ -540,7 +540,7 @@ def protocol_lost_connection(self, protocol): self.connected = False self.protocol = None if self.host: - asyncio.async(self._reconnect(), loop=self.loop) + asyncio.ensure_future(self._reconnect(), loop=self.loop) else: _logger.error('Factory protocol disconnect ' 'callback called while not connected.') @@ -619,7 +619,7 @@ def connect(self): _logger.info('Connected to %s:%s.' % (self.host, self.port)) except Exception as ex: _logger.warning('Failed to connect: %s' % ex) - # asyncio.async(self._reconnect(), loop=self.loop) + # asyncio.asynchronous(self._reconnect(), loop=self.loop) def protocol_made_connection(self, protocol): """ @@ -646,7 +646,7 @@ def protocol_lost_connection(self, protocol): self.connected = False self.protocol = None # if self.host: - # asyncio.async(self._reconnect(), loop=self.loop) + # asyncio.asynchronous(self._reconnect(), loop=self.loop) else: _logger.error('Factory protocol disconnect ' 'callback called while not connected.') @@ -745,7 +745,7 @@ def protocol_lost_connection(self, protocol): self._connected_event.clear() self.protocol = None # if self.host: - # asyncio.async(self._reconnect(), loop=self.loop) + # asyncio.asynchronous(self._reconnect(), loop=self.loop) else: _logger.error('Factory protocol disconnect callback ' 'called while not connected.') diff --git a/pymodbus/client/async/deprecated/__init__.py b/pymodbus/client/asynchronous/deprecated/__init__.py similarity index 74% rename from pymodbus/client/async/deprecated/__init__.py rename to pymodbus/client/asynchronous/deprecated/__init__.py index 902761faf..f16d649ae 100644 --- a/pymodbus/client/async/deprecated/__init__.py +++ b/pymodbus/client/asynchronous/deprecated/__init__.py @@ -9,21 +9,21 @@ Example run:: - from pymodbus.client.async import schedulers + from pymodbus.client.asynchronous import schedulers # Import The clients - from pymodbus.client.async.tcp import AsyncModbusTCPClient as Client - from pymodbus.client.async.serial import AsyncModbusSerialClient as Client - from pymodbus.client.async.udp import AsyncModbusUDPClient as Client + from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient as Client + from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient as Client + from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient as Client - # For tornado based async client use + # For tornado based asynchronous client use event_loop, future = Client(schedulers.IO_LOOP, port=5020) - # For twisted based async client use + # For twisted based asynchronous client use event_loop, deferred = Client(schedulers.REACTOR, port=5020) - # For asyncio based async client use + # For asyncio based asynchronous client use event_loop, client = Client(schedulers.ASYNC_IO, port=5020) # Here event_loop is a thread which would control the backend and future is diff --git a/pymodbus/client/async/deprecated/async.py b/pymodbus/client/asynchronous/deprecated/asynchronous.py similarity index 97% rename from pymodbus/client/async/deprecated/async.py rename to pymodbus/client/asynchronous/deprecated/asynchronous.py index 5d163a107..bd948ae73 100644 --- a/pymodbus/client/async/deprecated/async.py +++ b/pymodbus/client/asynchronous/deprecated/asynchronous.py @@ -5,7 +5,7 @@ Example run:: from twisted.internet import reactor, protocol - from pymodbus.client.async import ModbusClientProtocol + from pymodbus.client.asynchronous import ModbusClientProtocol def printResult(result): print "Result: %d" % result.bits[0] @@ -22,7 +22,7 @@ def process(client): Another example:: from twisted.internet import reactor - from pymodbus.client.async import ModbusClientFactory + from pymodbus.client.asynchronous import ModbusClientFactory def process(): factory = reactor.connectTCP("localhost", 502, ModbusClientFactory()) @@ -39,7 +39,7 @@ def process(): from pymodbus.transaction import FifoTransactionManager from pymodbus.transaction import DictTransactionManager from pymodbus.client.common import ModbusClientMixin -from pymodbus.client.async.deprecated import deprecated +from pymodbus.client.asynchronous.deprecated import deprecated from twisted.internet import defer, protocol from twisted.python.failure import Failure diff --git a/pymodbus/client/async/factory/__init__.py b/pymodbus/client/asynchronous/factory/__init__.py similarity index 100% rename from pymodbus/client/async/factory/__init__.py rename to pymodbus/client/asynchronous/factory/__init__.py diff --git a/pymodbus/client/async/factory/serial.py b/pymodbus/client/asynchronous/factory/serial.py similarity index 85% rename from pymodbus/client/async/factory/serial.py rename to pymodbus/client/asynchronous/factory/serial.py index 8a0a67b75..592de8eb1 100644 --- a/pymodbus/client/async/factory/serial.py +++ b/pymodbus/client/asynchronous/factory/serial.py @@ -1,20 +1,20 @@ """ -Factory to create async serial clients based on twisted/tornado/asyncio +Factory to create asynchronous serial clients based on twisted/tornado/asyncio """ from __future__ import unicode_literals from __future__ import absolute_import import logging -from pymodbus.client.async import schedulers -from pymodbus.client.async.thread import EventLoopThread +from pymodbus.client.asynchronous import schedulers +from pymodbus.client.asynchronous.thread import EventLoopThread LOGGER = logging.getLogger(__name__) def reactor_factory(port, framer, **kwargs): """ - Factory to create twisted serial async client + Factory to create twisted serial asynchronous client :param port: Serial port :param framer: Modbus Framer :param kwargs: @@ -58,7 +58,7 @@ def __init__(self, framer, *args, **kwargs): def io_loop_factory(port=None, framer=None, **kwargs): """ - Factory to create Tornado based async serial clients + Factory to create Tornado based asynchronous serial clients :param port: Serial port :param framer: Modbus Framer :param kwargs: @@ -66,7 +66,7 @@ def io_loop_factory(port=None, framer=None, **kwargs): """ from tornado.ioloop import IOLoop - from pymodbus.client.async.tornado import (AsyncModbusSerialClient as + from pymodbus.client.asynchronous.tornado import (AsyncModbusSerialClient as Client) ioloop = IOLoop() @@ -81,15 +81,15 @@ def io_loop_factory(port=None, framer=None, **kwargs): def async_io_factory(port=None, framer=None, **kwargs): """ - Factory to create asyncio based async serial clients + Factory to create asyncio based asynchronous serial clients :param port: Serial port :param framer: Modbus Framer :param kwargs: Serial port options :return: asyncio event loop and serial client """ import asyncio - from pymodbus.client.async.asyncio import (ModbusClientProtocol, - AsyncioModbusSerialClient) + from pymodbus.client.asynchronous.asyncio import (ModbusClientProtocol, + AsyncioModbusSerialClient) loop = kwargs.pop("loop", None) or asyncio.get_event_loop() proto_cls = kwargs.pop("proto_cls", None) or ModbusClientProtocol diff --git a/pymodbus/client/async/factory/tcp.py b/pymodbus/client/asynchronous/factory/tcp.py similarity index 85% rename from pymodbus/client/async/factory/tcp.py rename to pymodbus/client/asynchronous/factory/tcp.py index e8f425dd8..fb613785d 100644 --- a/pymodbus/client/async/factory/tcp.py +++ b/pymodbus/client/asynchronous/factory/tcp.py @@ -1,13 +1,13 @@ """ -Factory to create async tcp clients based on twisted/tornado/asyncio +Factory to create asynchronous tcp clients based on twisted/tornado/asyncio """ from __future__ import unicode_literals from __future__ import absolute_import import logging -from pymodbus.client.async import schedulers -from pymodbus.client.async.thread import EventLoopThread +from pymodbus.client.asynchronous import schedulers +from pymodbus.client.asynchronous.thread import EventLoopThread from pymodbus.constants import Defaults LOGGER = logging.getLogger(__name__) @@ -16,7 +16,7 @@ def reactor_factory(host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): """ - Factory to create twisted tcp async client + Factory to create twisted tcp asynchronous client :param host: Host IP address :param port: Port :param framer: Modbus Framer @@ -26,7 +26,7 @@ def reactor_factory(host="127.0.0.1", port=Defaults.Port, framer=None, :return: event_loop_thread and twisted_deferred """ from twisted.internet import reactor, protocol - from pymodbus.client.async.twisted import ModbusTcpClientProtocol + from pymodbus.client.asynchronous.twisted import ModbusTcpClientProtocol deferred = protocol.ClientCreator( reactor, ModbusTcpClientProtocol @@ -51,7 +51,7 @@ def reactor_factory(host="127.0.0.1", port=Defaults.Port, framer=None, def io_loop_factory(host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): """ - Factory to create Tornado based async tcp clients + Factory to create Tornado based asynchronous tcp clients :param host: Host IP address :param port: Port :param framer: Modbus Framer @@ -61,7 +61,7 @@ def io_loop_factory(host="127.0.0.1", port=Defaults.Port, framer=None, :return: event_loop_thread and tornado future """ from tornado.ioloop import IOLoop - from pymodbus.client.async.tornado import AsyncModbusTCPClient as \ + from pymodbus.client.asynchronous.tornado import AsyncModbusTCPClient as \ Client ioloop = IOLoop() @@ -80,7 +80,7 @@ def io_loop_factory(host="127.0.0.1", port=Defaults.Port, framer=None, def async_io_factory(host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): """ - Factory to create asyncio based async tcp clients + Factory to create asyncio based asynchronous tcp clients :param host: Host IP address :param port: Port :param framer: Modbus Framer @@ -90,7 +90,7 @@ def async_io_factory(host="127.0.0.1", port=Defaults.Port, framer=None, :return: asyncio event loop and tcp client """ import asyncio - from pymodbus.client.async.asyncio import init_tcp_client + from pymodbus.client.asynchronous.asyncio import init_tcp_client loop = kwargs.get("loop") or asyncio.new_event_loop() proto_cls = kwargs.get("proto_cls", None) if not loop.is_running(): diff --git a/pymodbus/client/async/factory/udp.py b/pymodbus/client/asynchronous/factory/udp.py similarity index 85% rename from pymodbus/client/async/factory/udp.py rename to pymodbus/client/asynchronous/factory/udp.py index c6896b61c..d6dc75ed5 100644 --- a/pymodbus/client/async/factory/udp.py +++ b/pymodbus/client/asynchronous/factory/udp.py @@ -3,8 +3,8 @@ import logging -from pymodbus.client.async import schedulers -from pymodbus.client.async.thread import EventLoopThread +from pymodbus.client.asynchronous import schedulers +from pymodbus.client.asynchronous.thread import EventLoopThread from pymodbus.constants import Defaults LOGGER = logging.getLogger(__name__) @@ -13,7 +13,7 @@ def reactor_factory(host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): """ - Factory to create twisted udp async client + Factory to create twisted udp asynchronous client :param host: Host IP address :param port: Port :param framer: Modbus Framer @@ -28,7 +28,7 @@ def reactor_factory(host="127.0.0.1", port=Defaults.Port, framer=None, def io_loop_factory(host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): """ - Factory to create Tornado based async udp clients + Factory to create Tornado based asynchronous udp clients :param host: Host IP address :param port: Port :param framer: Modbus Framer @@ -38,7 +38,7 @@ def io_loop_factory(host="127.0.0.1", port=Defaults.Port, framer=None, :return: event_loop_thread and tornado future """ from tornado.ioloop import IOLoop - from pymodbus.client.async.tornado import AsyncModbusUDPClient as \ + from pymodbus.client.asynchronous.tornado import AsyncModbusUDPClient as \ Client client = Client(host=host, port=port, framer=framer, @@ -55,7 +55,7 @@ def io_loop_factory(host="127.0.0.1", port=Defaults.Port, framer=None, def async_io_factory(host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): """ - Factory to create asyncio based async udp clients + Factory to create asyncio based asynchronous udp clients :param host: Host IP address :param port: Port :param framer: Modbus Framer @@ -65,7 +65,7 @@ def async_io_factory(host="127.0.0.1", port=Defaults.Port, framer=None, :return: asyncio event loop and udp client """ import asyncio - from pymodbus.client.async.asyncio import init_udp_client + from pymodbus.client.asynchronous.asyncio import init_udp_client loop = kwargs.get("loop") or asyncio.get_event_loop() proto_cls = kwargs.get("proto_cls", None) cor = init_udp_client(proto_cls, loop, host, port) diff --git a/pymodbus/client/async/mixins.py b/pymodbus/client/asynchronous/mixins.py similarity index 97% rename from pymodbus/client/async/mixins.py rename to pymodbus/client/asynchronous/mixins.py index 008cf49bf..f4cae328b 100644 --- a/pymodbus/client/async/mixins.py +++ b/pymodbus/client/asynchronous/mixins.py @@ -37,7 +37,7 @@ class AsyncModbusClientMixin(BaseAsyncModbusClient): def __init__(self, host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): """ - Initializes a Modbus TCP/UDP async client + Initializes a Modbus TCP/UDP asynchronous client :param host: Host IP address :param port: Port :param framer: Framer to use diff --git a/pymodbus/client/async/schedulers/__init__.py b/pymodbus/client/asynchronous/schedulers/__init__.py similarity index 100% rename from pymodbus/client/async/schedulers/__init__.py rename to pymodbus/client/asynchronous/schedulers/__init__.py diff --git a/pymodbus/client/async/serial.py b/pymodbus/client/asynchronous/serial.py similarity index 92% rename from pymodbus/client/async/serial.py rename to pymodbus/client/asynchronous/serial.py index 372072d23..5d2e2e817 100644 --- a/pymodbus/client/async/serial.py +++ b/pymodbus/client/asynchronous/serial.py @@ -2,12 +2,12 @@ from __future__ import absolute_import import logging -from pymodbus.client.async.factory.serial import get_factory +from pymodbus.client.asynchronous.factory.serial import get_factory from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer, ModbusBinaryFramer, ModbusSocketFramer from pymodbus.factory import ClientDecoder from pymodbus.exceptions import ParameterException from pymodbus.compat import IS_PYTHON3, PYTHON_VERSION -from pymodbus.client.async.schedulers import ASYNC_IO +from pymodbus.client.asynchronous.schedulers import ASYNC_IO logger = logging.getLogger(__name__) @@ -18,7 +18,7 @@ class AsyncModbusSerialClient(object): To use do:: - from pymodbus.client.async.serial import AsyncModbusSerialClient + from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient """ @classmethod def _framer(cls, method): diff --git a/pymodbus/client/async/tcp.py b/pymodbus/client/asynchronous/tcp.py similarity index 88% rename from pymodbus/client/async/tcp.py rename to pymodbus/client/asynchronous/tcp.py index 23470bbda..45b7cfdf4 100644 --- a/pymodbus/client/async/tcp.py +++ b/pymodbus/client/asynchronous/tcp.py @@ -2,10 +2,10 @@ from __future__ import absolute_import import logging -from pymodbus.client.async.factory.tcp import get_factory +from pymodbus.client.asynchronous.factory.tcp import get_factory from pymodbus.constants import Defaults from pymodbus.compat import IS_PYTHON3, PYTHON_VERSION -from pymodbus.client.async.schedulers import ASYNC_IO +from pymodbus.client.asynchronous.schedulers import ASYNC_IO logger = logging.getLogger(__name__) @@ -16,7 +16,7 @@ class AsyncModbusTCPClient(object): To use do:: - from pymodbus.client.async.tcp import AsyncModbusTCPClient + from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient """ def __new__(cls, scheduler, host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): diff --git a/pymodbus/client/async/thread.py b/pymodbus/client/asynchronous/thread.py similarity index 100% rename from pymodbus/client/async/thread.py rename to pymodbus/client/asynchronous/thread.py diff --git a/pymodbus/client/async/tornado/__init__.py b/pymodbus/client/asynchronous/tornado/__init__.py similarity index 97% rename from pymodbus/client/async/tornado/__init__.py rename to pymodbus/client/asynchronous/tornado/__init__.py index 5a9a67cf5..780bf5f07 100644 --- a/pymodbus/client/async/tornado/__init__.py +++ b/pymodbus/client/asynchronous/tornado/__init__.py @@ -15,8 +15,8 @@ from tornado.iostream import IOStream from tornado.iostream import BaseIOStream -from pymodbus.client.async.mixins import (AsyncModbusClientMixin, - AsyncModbusSerialClientMixin) +from pymodbus.client.asynchronous.mixins import (AsyncModbusClientMixin, + AsyncModbusSerialClientMixin) from pymodbus.exceptions import ConnectionException from pymodbus.compat import byte2int @@ -287,7 +287,7 @@ def write_to_fd(self, data): class AsyncModbusSerialClient(BaseTornadoSerialClient): """ - Tornado based async serial client + Tornado based asynchronous serial client """ def get_socket(self): """ diff --git a/pymodbus/client/async/twisted/__init__.py b/pymodbus/client/asynchronous/twisted/__init__.py similarity index 97% rename from pymodbus/client/async/twisted/__init__.py rename to pymodbus/client/asynchronous/twisted/__init__.py index 268afefb6..b1841a839 100644 --- a/pymodbus/client/async/twisted/__init__.py +++ b/pymodbus/client/asynchronous/twisted/__init__.py @@ -5,7 +5,7 @@ Example run:: from twisted.internet import reactor, protocol - from pymodbus.client.async import ModbusClientProtocol + from pymodbus.client.asynchronous import ModbusClientProtocol def printResult(result): print "Result: %d" % result.bits[0] @@ -22,7 +22,7 @@ def process(client): Another example:: from twisted.internet import reactor - from pymodbus.client.async import ModbusClientFactory + from pymodbus.client.asynchronous import ModbusClientFactory def process(): factory = reactor.connectTCP("localhost", 502, ModbusClientFactory()) @@ -37,7 +37,7 @@ def process(): from pymodbus.exceptions import ConnectionException from pymodbus.factory import ClientDecoder -from pymodbus.client.async.mixins import AsyncModbusClientMixin +from pymodbus.client.asynchronous.mixins import AsyncModbusClientMixin from pymodbus.transaction import FifoTransactionManager, DictTransactionManager from pymodbus.transaction import ModbusSocketFramer, ModbusRtuFramer from pymodbus.compat import byte2int diff --git a/pymodbus/client/async/udp.py b/pymodbus/client/asynchronous/udp.py similarity index 88% rename from pymodbus/client/async/udp.py rename to pymodbus/client/asynchronous/udp.py index b8f529a5b..a111d9624 100644 --- a/pymodbus/client/async/udp.py +++ b/pymodbus/client/asynchronous/udp.py @@ -4,8 +4,8 @@ import logging from pymodbus.constants import Defaults from pymodbus.compat import IS_PYTHON3, PYTHON_VERSION -from pymodbus.client.async.schedulers import ASYNC_IO -from pymodbus.client.async.factory.udp import get_factory +from pymodbus.client.asynchronous.schedulers import ASYNC_IO +from pymodbus.client.asynchronous.factory.udp import get_factory logger = logging.getLogger(__name__) @@ -16,7 +16,7 @@ class AsyncModbusUDPClient(object): To use do:: - from pymodbus.client.async.tcp import AsyncModbusUDPClient + from pymodbus.client.asynchronous.tcp import AsyncModbusUDPClient """ def __new__(cls, scheduler, host="127.0.0.1", port=Defaults.Port, framer=None, source_address=None, timeout=None, **kwargs): diff --git a/pymodbus/framer/__init__.py b/pymodbus/framer/__init__.py index fb0530b8c..5d84cc412 100644 --- a/pymodbus/framer/__init__.py +++ b/pymodbus/framer/__init__.py @@ -26,7 +26,7 @@ def _validate_unit_id(self, units, single): else: if 0 in units or 0xFF in units: # Handle Modbus TCP unit identifier (0x00 0r 0xFF) - # in async requests + # in asynchronous requests return True return self._header['uid'] in units diff --git a/pymodbus/server/async.py b/pymodbus/server/asynchronous.py similarity index 100% rename from pymodbus/server/async.py rename to pymodbus/server/asynchronous.py diff --git a/requirements-docs.txt b/requirements-docs.txt index 0457415a0..28b01e308 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -10,4 +10,4 @@ sphinx-rtd-theme==0.2.4 SQLAlchemy==1.1.15 # Required to parse some files tornado==4.5.2 # Required to parse some files twisted>= 12.2.0 # Required to parse some files - +prompt_toolkit>=2.0.4 diff --git a/test/test_client_async.py b/test/test_client_async.py index d16052767..337b42593 100644 --- a/test/test_client_async.py +++ b/test/test_client_async.py @@ -5,25 +5,25 @@ if IS_PYTHON3 and PYTHON_VERSION >= (3, 4): from unittest.mock import patch, Mock, MagicMock import asyncio - from pymodbus.client.async.asyncio import AsyncioModbusSerialClient + from pymodbus.client.asynchronous.asyncio import AsyncioModbusSerialClient from serial_asyncio import SerialTransport else: from mock import patch, Mock, MagicMock import platform from distutils.version import LooseVersion -from pymodbus.client.async.serial import AsyncModbusSerialClient -from pymodbus.client.async.tcp import AsyncModbusTCPClient -from pymodbus.client.async.udp import AsyncModbusUDPClient +from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient +from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient +from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient -from pymodbus.client.async.tornado import AsyncModbusSerialClient as AsyncTornadoModbusSerialClient -from pymodbus.client.async.tornado import AsyncModbusTCPClient as AsyncTornadoModbusTcpClient -from pymodbus.client.async.tornado import AsyncModbusUDPClient as AsyncTornadoModbusUdoClient -from pymodbus.client.async import schedulers +from pymodbus.client.asynchronous.tornado import AsyncModbusSerialClient as AsyncTornadoModbusSerialClient +from pymodbus.client.asynchronous.tornado import AsyncModbusTCPClient as AsyncTornadoModbusTcpClient +from pymodbus.client.asynchronous.tornado import AsyncModbusUDPClient as AsyncTornadoModbusUdoClient +from pymodbus.client.asynchronous import schedulers from pymodbus.factory import ClientDecoder from pymodbus.exceptions import ConnectionException from pymodbus.transaction import ModbusSocketFramer, ModbusRtuFramer, ModbusAsciiFramer, ModbusBinaryFramer -from pymodbus.client.async.twisted import ModbusSerClientProtocol +from pymodbus.client.asynchronous.twisted import ModbusSerClientProtocol IS_DARWIN = platform.system().lower() == "darwin" OSX_SIERRA = LooseVersion("10.12") @@ -45,7 +45,7 @@ def mock_asyncio_gather(coro): class TestAsynchronousClient(object): """ - This is the unittest for the pymodbus.client.async module + This is the unittest for the pymodbus.client.asynchronous module """ # -----------------------------------------------------------------------# @@ -68,8 +68,8 @@ def test_errback(client): callback=test_callback, errback=test_errback) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testTcpTornadoClient(self, mock_iostream, mock_ioloop): """ Test the TCP tornado client client initialize """ protocol, future = AsyncModbusTCPClient(schedulers.IO_LOOP, framer=ModbusSocketFramer(ClientDecoder())) @@ -108,8 +108,8 @@ def testTcpAsyncioClient(self, mock_gather, mock_loop): # Test UDP client # -----------------------------------------------------------------------# - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testUdpTornadoClient(self, mock_iostream, mock_ioloop): """ Test the udp tornado client client initialize """ protocol, future = AsyncModbusUDPClient(schedulers.IO_LOOP, framer=ModbusSocketFramer(ClientDecoder())) @@ -213,7 +213,7 @@ def handle_failure(failure): @pytest.mark.skipif(IS_PYTHON3 , reason="requires python2.7") def testSerialAsyncioClientPython2(self): """ - Test Serial async asyncio client exits on python2 + Test Serial asynchronous asyncio client exits on python2 :return: """ with pytest.raises(SystemExit) as pytest_wrapped_e: diff --git a/test/test_client_async_asyncio.py b/test/test_client_async_asyncio.py index 669a10205..de2de9d36 100644 --- a/test/test_client_async_asyncio.py +++ b/test/test_client_async_asyncio.py @@ -2,7 +2,7 @@ import pytest if IS_PYTHON3 and PYTHON_VERSION >= (3, 4): from unittest import mock - from pymodbus.client.async.asyncio import ( + from pymodbus.client.asynchronous.asyncio import ( ReconnectingAsyncioModbusTcpClient, ModbusClientProtocol, ModbusUdpClientProtocol) from test.asyncio_test_helper import return_as_coroutine, run_coroutine @@ -92,7 +92,7 @@ def test_factory_protocol_made_connection(self): assert client.connected assert client.protocol is mock.sentinel.PROTOCOL - @mock.patch('pymodbus.client.async.asyncio.asyncio.async') + @mock.patch('pymodbus.client.asynchronous.asyncio.asyncio.ensure_future') def test_factory_protocol_lost_connection(self, mock_async): mock_protocol_class = mock.MagicMock() mock_loop = mock.MagicMock() @@ -109,14 +109,14 @@ def test_factory_protocol_lost_connection(self, mock_async): client.port = mock.sentinel.PORT client.protocol = mock.sentinel.PROTOCOL - with mock.patch('pymodbus.client.async.asyncio.ReconnectingAsyncioModbusTcpClient._reconnect') as mock_reconnect: + with mock.patch('pymodbus.client.asynchronous.asyncio.ReconnectingAsyncioModbusTcpClient._reconnect') as mock_reconnect: mock_reconnect.return_value = mock.sentinel.RECONNECT_GENERATOR client.protocol_lost_connection(mock.sentinel.PROTOCOL) mock_async.assert_called_once_with(mock.sentinel.RECONNECT_GENERATOR, loop=mock_loop) assert not client.connected assert client.protocol is None - @mock.patch('pymodbus.client.async.asyncio.asyncio.async') + @mock.patch('pymodbus.client.asynchronous.asyncio.asyncio.ensure_future') def test_factory_start_success(self, mock_async): mock_protocol_class = mock.MagicMock() mock_loop = mock.MagicMock() @@ -126,7 +126,7 @@ def test_factory_start_success(self, mock_async): mock_loop.create_connection.assert_called_once_with(mock.ANY, mock.sentinel.HOST, mock.sentinel.PORT) assert mock_async.call_count == 0 - @mock.patch('pymodbus.client.async.asyncio.asyncio.async') + @mock.patch('pymodbus.client.asynchronous.asyncio.asyncio.ensure_future') def test_factory_start_failing_and_retried(self, mock_async): mock_protocol_class = mock.MagicMock() mock_loop = mock.MagicMock() @@ -134,13 +134,13 @@ def test_factory_start_failing_and_retried(self, mock_async): client = ReconnectingAsyncioModbusTcpClient(protocol_class=mock_protocol_class, loop=mock_loop) # check whether reconnect is called upon failed connection attempt: - with mock.patch('pymodbus.client.async.asyncio.ReconnectingAsyncioModbusTcpClient._reconnect') as mock_reconnect: + with mock.patch('pymodbus.client.asynchronous.asyncio.ReconnectingAsyncioModbusTcpClient._reconnect') as mock_reconnect: mock_reconnect.return_value = mock.sentinel.RECONNECT_GENERATOR run_coroutine(client.start(mock.sentinel.HOST, mock.sentinel.PORT)) mock_reconnect.assert_called_once_with() mock_async.assert_called_once_with(mock.sentinel.RECONNECT_GENERATOR, loop=mock_loop) - @mock.patch('pymodbus.client.async.asyncio.asyncio.sleep') + @mock.patch('pymodbus.client.asynchronous.asyncio.asyncio.sleep') def test_factory_reconnect(self, mock_sleep): mock_protocol_class = mock.MagicMock() mock_loop = mock.MagicMock() diff --git a/test/test_client_async_tornado.py b/test/test_client_async_tornado.py index 07aef8511..25d1f6081 100644 --- a/test/test_client_async_tornado.py +++ b/test/test_client_async_tornado.py @@ -5,12 +5,12 @@ from unittest.mock import patch, Mock else: # Python 2 from mock import patch, Mock -from pymodbus.client.async.tornado import (BaseTornadoClient, - AsyncModbusSerialClient, AsyncModbusUDPClient, AsyncModbusTCPClient -) -from pymodbus.client.async import schedulers +from pymodbus.client.asynchronous.tornado import (BaseTornadoClient, + AsyncModbusSerialClient, AsyncModbusUDPClient, AsyncModbusTCPClient + ) +from pymodbus.client.asynchronous import schedulers from pymodbus.factory import ClientDecoder -from pymodbus.client.async.twisted import ModbusClientFactory +from pymodbus.client.asynchronous.twisted import ModbusClientFactory from pymodbus.exceptions import ConnectionException from pymodbus.transaction import ModbusSocketFramer, ModbusRtuFramer from pymodbus.bit_read_message import ReadCoilsRequest, ReadCoilsResponse @@ -33,7 +33,7 @@ class AsynchronousClientTest(unittest.TestCase): """ - This is the unittest for the pymodbus.client.async module + This is the unittest for the pymodbus.client.asynchronous module """ # -----------------------------------------------------------------------# @@ -57,8 +57,8 @@ def testBaseClientInit(self): self.assertTrue(client.io_loop == schedulers.IO_LOOP) self.assertTrue(framer is client.framer) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testBaseClientOn_receive(self, mock_iostream, mock_ioloop): """ Test the BaseTornado client data received """ client = AsyncModbusTCPClient(port=5020) @@ -79,8 +79,8 @@ def testBaseClientOn_receive(self, mock_iostream, mock_ioloop): d.add_done_callback(lambda v: out.append(v)) self.assertFalse(out) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testBaseClientExecute(self, mock_iostream, mock_ioloop): """ Test the BaseTornado client execute method """ client = AsyncModbusTCPClient(port=5020) @@ -93,8 +93,8 @@ def testBaseClientExecute(self, mock_iostream, mock_ioloop): tid = request.transaction_id self.assertEqual(d, client.transaction.getTransaction(tid)) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testBaseClientHandleResponse(self, mock_iostream, mock_ioloop): """ Test the BaseTornado client handles responses """ client = AsyncModbusTCPClient(port=5020) @@ -113,8 +113,8 @@ def testBaseClientHandleResponse(self, mock_iostream, mock_ioloop): client._handle_response(reply) self.assertEqual(out[0].result(), reply) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testBaseClientBuildResponse(self, mock_iostream, mock_ioloop): """ Test the BaseTornado client client builds responses """ client = BaseTornadoClient() @@ -144,8 +144,8 @@ def testTcpClientInit(self): client = AsyncModbusTCPClient(framer=framer) self.assertTrue(framer is client.framer) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testTcpClientConnect(self, mock_iostream, mock_ioloop): """ Test the tornado tcp client client connect """ client = AsyncModbusTCPClient(port=5020) @@ -154,8 +154,8 @@ def testTcpClientConnect(self, mock_iostream, mock_ioloop): client.connect() self.assertTrue(client._connected) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.IOStream") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.IOStream") def testTcpClientDisconnect(self, mock_iostream, mock_ioloop): """ Test the tornado tcp client client disconnect """ client = AsyncModbusTCPClient(port=5020) @@ -185,9 +185,9 @@ def testSerialClientInit(self): client = AsyncModbusSerialClient(framer=framer) self.assertTrue(framer is client.framer) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.SerialIOStream") - @patch("pymodbus.client.async.tornado.Serial") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.SerialIOStream") + @patch("pymodbus.client.asynchronous.tornado.Serial") def testSerialClientConnect(self, mock_serial, mock_seriostream, mock_ioloop): """ Test the tornado serial client client connect """ client = AsyncModbusSerialClient(ioloop=schedulers.IO_LOOP, @@ -200,9 +200,9 @@ def testSerialClientConnect(self, mock_serial, mock_seriostream, mock_ioloop): self.assertTrue(client._connected) client.close() - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.SerialIOStream") - @patch("pymodbus.client.async.tornado.Serial") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.SerialIOStream") + @patch("pymodbus.client.asynchronous.tornado.Serial") def testSerialClientDisconnect(self, mock_serial, mock_seriostream, mock_ioloop): """ Test the tornado serial client client disconnect """ client = AsyncModbusSerialClient(ioloop=schedulers.IO_LOOP, @@ -220,9 +220,9 @@ def handle_failure(failure): client.close() self.assertFalse(client._connected) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.SerialIOStream") - @patch("pymodbus.client.async.tornado.Serial") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.SerialIOStream") + @patch("pymodbus.client.asynchronous.tornado.Serial") def testSerialClientExecute(self, mock_serial, mock_seriostream, mock_ioloop): """ Test the tornado serial client client execute method """ client = AsyncModbusSerialClient(ioloop=schedulers.IO_LOOP, @@ -238,9 +238,9 @@ def testSerialClientExecute(self, mock_serial, mock_seriostream, mock_ioloop): tid = request.transaction_id self.assertEqual(d, client.transaction.getTransaction(tid)) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.SerialIOStream") - @patch("pymodbus.client.async.tornado.Serial") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.SerialIOStream") + @patch("pymodbus.client.asynchronous.tornado.Serial") def testSerialClientHandleResponse(self, mock_serial, mock_seriostream, mock_ioloop): """ Test the tornado serial client client handles responses """ client = AsyncModbusSerialClient(ioloop=schedulers.IO_LOOP, @@ -262,9 +262,9 @@ def testSerialClientHandleResponse(self, mock_serial, mock_seriostream, mock_iol client._handle_response(reply) self.assertEqual(out[0].result(), reply) - @patch("pymodbus.client.async.tornado.IOLoop") - @patch("pymodbus.client.async.tornado.SerialIOStream") - @patch("pymodbus.client.async.tornado.Serial") + @patch("pymodbus.client.asynchronous.tornado.IOLoop") + @patch("pymodbus.client.asynchronous.tornado.SerialIOStream") + @patch("pymodbus.client.asynchronous.tornado.Serial") def testSerialClientBuildResponse(self, mock_serial, mock_seriostream, mock_ioloop): """ Test the tornado serial client client builds responses """ client = AsyncModbusSerialClient(ioloop=schedulers.IO_LOOP, diff --git a/test/test_client_async_twisted.py b/test/test_client_async_twisted.py index d2241c308..62890131a 100644 --- a/test/test_client_async_twisted.py +++ b/test/test_client_async_twisted.py @@ -5,11 +5,11 @@ from unittest.mock import patch, Mock else: # Python 2 from mock import patch, Mock -from pymodbus.client.async.twisted import ( +from pymodbus.client.asynchronous.twisted import ( ModbusClientProtocol, ModbusUdpClientProtocol, ModbusSerClientProtocol, ModbusTcpClientProtocol ) from pymodbus.factory import ClientDecoder -from pymodbus.client.async.twisted import ModbusClientFactory +from pymodbus.client.asynchronous.twisted import ModbusClientFactory from pymodbus.exceptions import ConnectionException from pymodbus.transaction import ModbusSocketFramer, ModbusRtuFramer from pymodbus.bit_read_message import ReadCoilsRequest, ReadCoilsResponse @@ -20,7 +20,7 @@ class AsynchronousClientTest(unittest.TestCase): ''' - This is the unittest for the pymodbus.client.async module + This is the unittest for the pymodbus.client.asynchronous module ''' #-----------------------------------------------------------------------# diff --git a/test/test_server_async.py b/test/test_server_async.py index 8c78a958a..447029aeb 100644 --- a/test/test_server_async.py +++ b/test/test_server_async.py @@ -6,9 +6,9 @@ else: # Python 2 from mock import patch, Mock, MagicMock from pymodbus.device import ModbusDeviceIdentification -from pymodbus.server.async import ModbusTcpProtocol, ModbusUdpProtocol -from pymodbus.server.async import ModbusServerFactory -from pymodbus.server.async import ( +from pymodbus.server.asynchronous import ModbusTcpProtocol, ModbusUdpProtocol +from pymodbus.server.asynchronous import ModbusServerFactory +from pymodbus.server.asynchronous import ( StartTcpServer, StartUdpServer, StartSerialServer, StopServer, _is_main_thread ) @@ -35,7 +35,7 @@ class AsynchronousServerTest(unittest.TestCase): ''' - This is the unittest for the pymodbus.server.async module + This is the unittest for the pymodbus.server.asynchronous module ''' #-----------------------------------------------------------------------# @@ -56,7 +56,7 @@ def tearDown(self): # Test ModbusTcpProtocol #-----------------------------------------------------------------------# def testTcpServerStartup(self): - ''' Test that the modbus tcp async server starts correctly ''' + ''' Test that the modbus tcp asynchronous server starts correctly ''' with patch('twisted.internet.reactor') as mock_reactor: if IS_PYTHON3: console = False @@ -186,7 +186,7 @@ def testUdpServerInitialize(self): def testUdpServerStartup(self): - ''' Test that the modbus udp async server starts correctly ''' + ''' Test that the modbus udp asynchronous server starts correctly ''' with patch('twisted.internet.reactor') as mock_reactor: StartUdpServer(context=None) self.assertEqual(mock_reactor.listenUDP.call_count, 1) @@ -194,7 +194,7 @@ def testUdpServerStartup(self): @patch("twisted.internet.serialport.SerialPort") def testSerialServerStartup(self, mock_sp): - ''' Test that the modbus serial async server starts correctly ''' + ''' Test that the modbus serial asynchronous server starts correctly ''' with patch('twisted.internet.reactor') as mock_reactor: StartSerialServer(context=None, port=SERIAL_PORT) self.assertEqual(mock_reactor.run.call_count, 1) @@ -202,7 +202,7 @@ def testSerialServerStartup(self, mock_sp): @patch("twisted.internet.serialport.SerialPort") def testStopServerFromMainThread(self, mock_sp): """ - Stop async server + Stop asynchronous server :return: """ with patch('twisted.internet.reactor') as mock_reactor: @@ -214,7 +214,7 @@ def testStopServerFromMainThread(self, mock_sp): @patch("twisted.internet.serialport.SerialPort") def testStopServerFromThread(self, mock_sp): """ - Stop async server from child thread + Stop asynchronous server from child thread :return: """ from threading import Thread diff --git a/tox.ini b/tox.ini index 5252c87fa..6d29c6530 100644 --- a/tox.ini +++ b/tox.ini @@ -4,10 +4,10 @@ # directory. [tox] -envlist = py27, py34, py35, py36, pypy +envlist = py27, py34, py35, py36, py37, pypy [testenv] -deps = -requirements-tests.txt +deps = -r requirements-tests.txt commands = py.test {posargs} [flake8] From 8cc66b8a5e8bb27fd15dab1ebc5654cf89f102a9 Mon Sep 17 00:00:00 2001 From: dices Date: Sat, 22 Sep 2018 16:59:37 -0400 Subject: [PATCH 2/3] Adding 3.7 to travis configuration --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9c5eedf3a..618774299 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ matrix: python: "3.5" - os: linux python: "3.6" + - os: linux + python: "3.7" - os: osx osx_image: xcode8.3 language: generic From f7020db73f56057dc9287674cf5b78c9fe572a8f Mon Sep 17 00:00:00 2001 From: dices Date: Sun, 23 Sep 2018 00:48:18 -0400 Subject: [PATCH 3/3] Updated documentation to resolve warnings introduced with the longer names Updated requirements-docs.txt to include missing modules --- CHANGELOG.rst | 9 ++++++-- doc/conf.py | 5 ++-- .../pymodbus.client.asynchronous.asyncio.rst | 4 ++-- .../pymodbus.client.asynchronous.factory.rst | 16 ++++++------- .../library/pymodbus.client.asynchronous.rst | 18 +++++++-------- ...ymodbus.client.asynchronous.schedulers.rst | 4 ++-- .../pymodbus.client.asynchronous.tornado.rst | 4 ++-- .../pymodbus.client.asynchronous.twisted.rst | 4 ++-- doc/source/library/pymodbus.server.rst | 2 +- pymodbus/framer/ascii_framer.py | 2 +- pymodbus/framer/binary_framer.py | 2 +- pymodbus/framer/rtu_framer.py | 3 ++- pymodbus/framer/socket_framer.py | 2 +- pymodbus/repl/client.py | 6 +++++ pymodbus/repl/completer.py | 18 ++++++++++++--- pymodbus/server/asynchronous.py | 23 +++++++++++-------- requirements-docs.txt | 3 +++ 17 files changed, 79 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 63f135fb0..029ec906b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -31,13 +31,18 @@ Version 1.5.1 * Added REPR statements for all syncchronous clients * Added `isError` method to exceptions, Any response received can be tested for success before proceeding. - ``` + """ + res = client.read_holding_registers(...) if not res.isError(): + # proceed + else: # handle error or raise - ``` + + """ + * Add examples for MEI read device information request Version 1.5.0 diff --git a/doc/conf.py b/doc/conf.py index fc92ce5fb..90ae81c83 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -41,7 +41,7 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.autodoc'] +extensions = ['sphinx.ext.autodoc', 'm2r'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -104,7 +104,8 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# html_static_path = ['_static'] +html_static_path = [] # Custom sidebar templates, must be a dictionary that maps document names # to template names. diff --git a/doc/source/library/pymodbus.client.asynchronous.asyncio.rst b/doc/source/library/pymodbus.client.asynchronous.asyncio.rst index 3c620c291..d19a1a28b 100644 --- a/doc/source/library/pymodbus.client.asynchronous.asyncio.rst +++ b/doc/source/library/pymodbus.client.asynchronous.asyncio.rst @@ -1,5 +1,5 @@ -pymodbus\.client\.async\.asyncio package -======================================== +pymodbus\.client\.asynchronous\.asyncio package +=============================================== .. automodule:: pymodbus.client.asynchronous.asyncio :members: diff --git a/doc/source/library/pymodbus.client.asynchronous.factory.rst b/doc/source/library/pymodbus.client.asynchronous.factory.rst index c7068ce26..74c933ecf 100644 --- a/doc/source/library/pymodbus.client.asynchronous.factory.rst +++ b/doc/source/library/pymodbus.client.asynchronous.factory.rst @@ -1,5 +1,5 @@ -pymodbus\.client\.async\.factory package -======================================== +pymodbus\.client\.asynchronous\.factory package +=============================================== .. automodule:: pymodbus.client.asynchronous.factory :members: @@ -9,24 +9,24 @@ pymodbus\.client\.async\.factory package Submodules ---------- -pymodbus\.client\.async\.factory\.serial module ------------------------------------------------ +pymodbus\.client\.asynchronous\.factory\.serial module +------------------------------------------------------ .. automodule:: pymodbus.client.asynchronous.factory.serial :members: :undoc-members: :show-inheritance: -pymodbus\.client\.async\.factory\.tcp module --------------------------------------------- +pymodbus\.client\.asynchronous\.factory\.tcp module +--------------------------------------------------- .. automodule:: pymodbus.client.asynchronous.factory.tcp :members: :undoc-members: :show-inheritance: -pymodbus\.client\.async\.factory\.udp module --------------------------------------------- +pymodbus\.client\.asynchronous\.factory\.udp module +--------------------------------------------------- .. automodule:: pymodbus.client.asynchronous.factory.udp :members: diff --git a/doc/source/library/pymodbus.client.asynchronous.rst b/doc/source/library/pymodbus.client.asynchronous.rst index 01b37d8fd..c72291a8d 100644 --- a/doc/source/library/pymodbus.client.asynchronous.rst +++ b/doc/source/library/pymodbus.client.asynchronous.rst @@ -1,5 +1,5 @@ pymodbus\.client\.asynchronous package -=============================== +====================================== .. automodule:: pymodbus.client.asynchronous :members: @@ -20,32 +20,32 @@ Subpackages Submodules ---------- -pymodbus\.client\.async\.serial module --------------------------------------- +pymodbus\.client\.asynchronous\.serial module +--------------------------------------------- .. automodule:: pymodbus.client.asynchronous.serial :members: :undoc-members: :show-inheritance: -pymodbus\.client\.async\.tcp module ------------------------------------ +pymodbus\.client\.asynchronous\.tcp module +------------------------------------------ .. automodule:: pymodbus.client.asynchronous.tcp :members: :undoc-members: :show-inheritance: -pymodbus\.client\.async\.thread module --------------------------------------- +pymodbus\.client\.asynchronous\.thread module +--------------------------------------------- .. automodule:: pymodbus.client.asynchronous.thread :members: :undoc-members: :show-inheritance: -pymodbus\.client\.async\.udp module ------------------------------------ +pymodbus\.client\.asynchronous\.udp module +------------------------------------------ .. automodule:: pymodbus.client.asynchronous.udp :members: diff --git a/doc/source/library/pymodbus.client.asynchronous.schedulers.rst b/doc/source/library/pymodbus.client.asynchronous.schedulers.rst index b29cb441e..f6956ad4d 100644 --- a/doc/source/library/pymodbus.client.asynchronous.schedulers.rst +++ b/doc/source/library/pymodbus.client.asynchronous.schedulers.rst @@ -1,5 +1,5 @@ -pymodbus\.client\.async\.schedulers package -=========================================== +pymodbus\.client\.asynchronous\.schedulers package +================================================== .. automodule:: pymodbus.client.asynchronous.schedulers :members: diff --git a/doc/source/library/pymodbus.client.asynchronous.tornado.rst b/doc/source/library/pymodbus.client.asynchronous.tornado.rst index 2fc4aaf55..c3262196c 100644 --- a/doc/source/library/pymodbus.client.asynchronous.tornado.rst +++ b/doc/source/library/pymodbus.client.asynchronous.tornado.rst @@ -1,5 +1,5 @@ -pymodbus\.client\.async\.tornado package -======================================== +pymodbus\.client\.asynchronous\.tornado package +=============================================== .. automodule:: pymodbus.client.asynchronous.tornado :members: diff --git a/doc/source/library/pymodbus.client.asynchronous.twisted.rst b/doc/source/library/pymodbus.client.asynchronous.twisted.rst index dd6dff034..537dd688b 100644 --- a/doc/source/library/pymodbus.client.asynchronous.twisted.rst +++ b/doc/source/library/pymodbus.client.asynchronous.twisted.rst @@ -1,5 +1,5 @@ -pymodbus\.client\.async\.twisted package -======================================== +pymodbus\.client\.asynchronous\.twisted package +=============================================== .. automodule:: pymodbus.client.asynchronous.twisted :members: diff --git a/doc/source/library/pymodbus.server.rst b/doc/source/library/pymodbus.server.rst index e2d8e8b09..67f492524 100644 --- a/doc/source/library/pymodbus.server.rst +++ b/doc/source/library/pymodbus.server.rst @@ -10,7 +10,7 @@ Submodules ---------- pymodbus\.server\.asynchronous module ------------------------------- +------------------------------------- .. automodule:: pymodbus.server.asynchronous :members: diff --git a/pymodbus/framer/ascii_framer.py b/pymodbus/framer/ascii_framer.py index 9c2b1afda..a883b32fc 100644 --- a/pymodbus/framer/ascii_framer.py +++ b/pymodbus/framer/ascii_framer.py @@ -163,7 +163,7 @@ def processIncomingPacket(self, data, callback, unit, **kwargs): :param data: The new packet data :param callback: The function to send results to :param unit: Process if unit id matches, ignore otherwise (could be a - list of unit ids (server) or single unit id(client/server)) + list of unit ids (server) or single unit id(client/server)) :param single: True or False (If True, ignore unit address validation) """ diff --git a/pymodbus/framer/binary_framer.py b/pymodbus/framer/binary_framer.py index b8602489f..05d53d4ec 100644 --- a/pymodbus/framer/binary_framer.py +++ b/pymodbus/framer/binary_framer.py @@ -153,7 +153,7 @@ def processIncomingPacket(self, data, callback, unit, **kwargs): :param data: The new packet data :param callback: The function to send results to :param unit: Process if unit id matches, ignore otherwise (could be a - list of unit ids (server) or single unit id(client/server) + list of unit ids (server) or single unit id(client/server) :param single: True or False (If True, ignore unit address validation) """ diff --git a/pymodbus/framer/rtu_framer.py b/pymodbus/framer/rtu_framer.py index 1a46811a1..868843835 100644 --- a/pymodbus/framer/rtu_framer.py +++ b/pymodbus/framer/rtu_framer.py @@ -206,8 +206,9 @@ def processIncomingPacket(self, data, callback, unit, **kwargs): :param data: The new packet data :param callback: The function to send results to :param unit: Process if unit id matches, ignore otherwise (could be a - list of unit ids (server) or single unit id(client/server) + list of unit ids (server) or single unit id(client/server) :param single: True or False (If True, ignore unit address validation) + """ if not isinstance(unit, (list, tuple)): unit = [unit] diff --git a/pymodbus/framer/socket_framer.py b/pymodbus/framer/socket_framer.py index 201018960..86ed73bd4 100644 --- a/pymodbus/framer/socket_framer.py +++ b/pymodbus/framer/socket_framer.py @@ -137,7 +137,7 @@ def processIncomingPacket(self, data, callback, unit, **kwargs): :param data: The new packet data :param callback: The function to send results to :param unit: Process if unit id matches, ignore otherwise (could be a - list of unit ids (server) or single unit id(client/server) + list of unit ids (server) or single unit id(client/server) :param single: True or False (If True, ignore unit address validation) """ diff --git a/pymodbus/repl/client.py b/pymodbus/repl/client.py index 8a427e014..fb8fb05e1 100644 --- a/pymodbus/repl/client.py +++ b/pymodbus/repl/client.py @@ -294,8 +294,11 @@ def report_slave_id(self, **kwargs): def read_exception_status(self, **kwargs): """ Read the contents of eight Exception Status outputs in a remote device. + :param unit: The slave unit this request is targeting + :return: + """ request = ReadExceptionStatusRequest(**kwargs) resp = self.execute(request) @@ -311,8 +314,11 @@ def get_com_event_counter(self, **kwargs): """ Read status word and an event count from the remote device's communication event counter + :param unit: The slave unit this request is targeting + :return: + """ request = GetCommEventCounterRequest(**kwargs) resp = self.execute(request) diff --git a/pymodbus/repl/completer.py b/pymodbus/repl/completer.py index bfe9cbdb6..334d0c586 100644 --- a/pymodbus/repl/completer.py +++ b/pymodbus/repl/completer.py @@ -49,14 +49,18 @@ def command_names(self): return self._commands.keys() def completing_command(self, words, word_before_cursor): - """Determine if we are currently completing the hn command. + """ + Determine if we are currently completing the hn command. + :type words: list :param words: The input text broken into word tokens. :type word_before_cursor: str :param word_before_cursor: The current word before the cursor, which might be one or more blank spaces. :rtype: bool + :return: Specifies whether we are currently completing the hn command. + """ if len(words) == 1 and word_before_cursor != '': return True @@ -64,14 +68,18 @@ def completing_command(self, words, word_before_cursor): return False def completing_arg(self, words, word_before_cursor): - """Determine if we are currently completing an arg. + """ + Determine if we are currently completing an arg. + :type words: list :param words: The input text broken into word tokens. :type word_before_cursor: str :param word_before_cursor: The current word before the cursor, which might be one or more blank spaces. :rtype: bool + :return: Specifies whether we are currently completing an arg. + """ if len(words) > 1 and word_before_cursor != '': return True @@ -79,14 +87,18 @@ def completing_arg(self, words, word_before_cursor): return False def arg_completions(self, words, word_before_cursor): - """Generates arguments completions based on the input. + """ + Generates arguments completions based on the input. + :type words: list :param words: The input text broken into word tokens. :type word_before_cursor: str :param word_before_cursor: The current word before the cursor, which might be one or more blank spaces. :rtype: list + :return: A list of completions. + """ cmd = words[0].strip() cmd = self._commands.get(cmd, None) diff --git a/pymodbus/server/asynchronous.py b/pymodbus/server/asynchronous.py index 8946ed4ee..8f1311fc8 100644 --- a/pymodbus/server/asynchronous.py +++ b/pymodbus/server/asynchronous.py @@ -231,16 +231,18 @@ def _is_main_thread(): def StartTcpServer(context, identity=None, address=None, console=False, defer_reactor_run=False, **kwargs): - """ Helper method to start the Modbus Async TCP server + """ + Helper method to start the Modbus Async TCP server :param context: The server data context :param identify: The server identity to use (default empty) :param address: An optional (interface, port) to bind to. :param console: A flag indicating if you want the debug console :param ignore_missing_slaves: True to not send errors on a request - to a missing slave + to a missing slave :param defer_reactor_run: True/False defer running reactor.run() as part - of starting server, to be explictly started by the user + of starting server, to be explictly started by the user + """ from twisted.internet import reactor @@ -258,15 +260,16 @@ def StartTcpServer(context, identity=None, address=None, def StartUdpServer(context, identity=None, address=None, defer_reactor_run=False, **kwargs): - """ Helper method to start the Modbus Async Udp server + """ + Helper method to start the Modbus Async Udp server :param context: The server data context :param identify: The server identity to use (default empty) :param address: An optional (interface, port) to bind to. :param ignore_missing_slaves: True to not send errors on a request - to a missing slave + to a missing slave :param defer_reactor_run: True/False defer running reactor.run() as part - of starting server, to be explictly started by the user + of starting server, to be explictly started by the user """ from twisted.internet import reactor @@ -284,7 +287,8 @@ def StartSerialServer(context, identity=None, framer=ModbusAsciiFramer, defer_reactor_run=False, **kwargs): - """ Helper method to start the Modbus Async Serial server + """ + Helper method to start the Modbus Async Serial server :param context: The server data context :param identify: The server identity to use (default empty) @@ -293,9 +297,10 @@ def StartSerialServer(context, identity=None, :param baudrate: The baud rate to use for the serial device :param console: A flag indicating if you want the debug console :param ignore_missing_slaves: True to not send errors on a request to a - missing slave + missing slave :param defer_reactor_run: True/False defer running reactor.run() as part - of starting server, to be explictly started by the user + of starting server, to be explictly started by the user + """ from twisted.internet import reactor from twisted.internet.serialport import SerialPort diff --git a/requirements-docs.txt b/requirements-docs.txt index 28b01e308..791ea0988 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -11,3 +11,6 @@ SQLAlchemy==1.1.15 # Required to parse some files tornado==4.5.2 # Required to parse some files twisted>= 12.2.0 # Required to parse some files prompt_toolkit>=2.0.4 +click>=6.7 +m2r>=0.2.0 +