Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error if example is run without support files #2189

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion examples/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion examples/client_async_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 10 additions & 1 deletion examples/client_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
10 changes: 9 additions & 1 deletion examples/client_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/client_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/modbus_forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/server_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
10 changes: 9 additions & 1 deletion examples/server_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion examples/server_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
12 changes: 10 additions & 2 deletions examples/server_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/server_updating.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down