diff --git a/examples/client_async.py b/examples/client_async.py index e5554b3b4..29bfd88f4 100755 --- a/examples/client_async.py +++ b/examples/client_async.py @@ -28,8 +28,16 @@ """ import asyncio import logging +import sys -import helper + +try: + import helper +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) import pymodbus.client as modbusClient from pymodbus import ModbusException diff --git a/examples/client_async_calls.py b/examples/client_async_calls.py index 2f84c57b0..482a9ec40 100755 --- a/examples/client_async_calls.py +++ b/examples/client_async_calls.py @@ -31,9 +31,16 @@ """ import asyncio import logging +import sys -import client_async +try: + import client_async +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) _logger = logging.getLogger(__file__) _logger.setLevel("DEBUG") diff --git a/examples/client_calls.py b/examples/client_calls.py index ab9d740d4..50a58bc3d 100755 --- a/examples/client_calls.py +++ b/examples/client_calls.py @@ -30,8 +30,17 @@ ./server_async.py """ import logging +import sys + + +try: + import client_sync +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) -import client_sync _logger = logging.getLogger(__file__) diff --git a/examples/client_payload.py b/examples/client_payload.py index c5d82b082..70eb53ac6 100755 --- a/examples/client_payload.py +++ b/examples/client_payload.py @@ -7,9 +7,17 @@ Works out of the box together with payload_server.py """ import asyncio +import sys from collections import OrderedDict -import client_async + +try: + import client_async +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) from pymodbus.constants import Endian from pymodbus.payload import BinaryPayloadBuilder, BinaryPayloadDecoder diff --git a/examples/client_sync.py b/examples/client_sync.py index ccb28ec8f..3a4230560 100755 --- a/examples/client_sync.py +++ b/examples/client_sync.py @@ -31,8 +31,16 @@ """ import logging +import sys -import helper + +try: + import helper +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) import pymodbus.client as modbusClient from pymodbus import ModbusException diff --git a/examples/modbus_forwarder.py b/examples/modbus_forwarder.py index 9ada899de..b29070f25 100755 --- a/examples/modbus_forwarder.py +++ b/examples/modbus_forwarder.py @@ -18,8 +18,16 @@ """ import asyncio import logging +import sys -import helper + +try: + import helper +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) from pymodbus.client import ModbusTcpClient from pymodbus.datastore import ModbusServerContext diff --git a/examples/server_async.py b/examples/server_async.py index 668dcad0e..07d40352b 100755 --- a/examples/server_async.py +++ b/examples/server_async.py @@ -34,8 +34,16 @@ """ import asyncio import logging +import sys -import helper + +try: + import helper +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) from pymodbus import __version__ as pymodbus_version from pymodbus.datastore import ( diff --git a/examples/server_callback.py b/examples/server_callback.py index f5cd574bd..6be7da107 100755 --- a/examples/server_callback.py +++ b/examples/server_callback.py @@ -6,8 +6,16 @@ """ import asyncio import logging +import sys -import server_async + +try: + import server_async +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) from pymodbus.datastore import ( ModbusSequentialDataBlock, diff --git a/examples/server_payload.py b/examples/server_payload.py index c56d5a035..abd0b444e 100755 --- a/examples/server_payload.py +++ b/examples/server_payload.py @@ -6,8 +6,17 @@ """ import asyncio import logging +import sys + + +try: + import server_async +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) -import server_async from pymodbus.constants import Endian from pymodbus.datastore import ( diff --git a/examples/server_sync.py b/examples/server_sync.py index 54a2a1792..bc847ec13 100755 --- a/examples/server_sync.py +++ b/examples/server_sync.py @@ -35,9 +35,17 @@ a lot slower. """ import logging +import sys -import helper -import server_async + +try: + import helper + import server_async +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) # --------------------------------------------------------------------------- # # import the various client implementations diff --git a/examples/server_updating.py b/examples/server_updating.py index 84104a9eb..10e0ce3cb 100755 --- a/examples/server_updating.py +++ b/examples/server_updating.py @@ -33,8 +33,16 @@ """ import asyncio import logging +import sys -import server_async + +try: + import server_async +except ImportError: + print("*** ERROR --> THIS EXAMPLE needs the example directory, please see \n\ + https://pymodbus.readthedocs.io/en/latest/source/examples.html\n\ + for more information.") + sys.exit(-1) from pymodbus.datastore import ( ModbusSequentialDataBlock,