File tree Expand file tree Collapse file tree 4 files changed +13
-11
lines changed Expand file tree Collapse file tree 4 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 11"""Modbus client async serial communication."""
22import asyncio
33import time
4- from contextlib import suppress
54from functools import partial
65from typing import Any , Type
76
1413from pymodbus .utilities import ModbusTransactionState
1514
1615
17- with suppress ( ImportError ) :
16+ try :
1817 import serial
18+ except ImportError :
19+ raise ImportError ( # pylint: disable=raise-missing-from
20+ "Serial client requires pyserial "
21+ 'Please install with "pip install pyserial" and try again.'
22+ )
1923
2024
2125class AsyncModbusSerialClient (ModbusBaseClient , asyncio .Protocol ):
Original file line number Diff line number Diff line change 2323from pymodbus .transport import CommParams , CommType , ModbusProtocol
2424
2525
26- with suppress (ImportError ):
27- pass
28-
29-
3026# --------------------------------------------------------------------------- #
3127# Protocol Handlers
3228# --------------------------------------------------------------------------- #
Original file line number Diff line number Diff line change 1515try :
1616 from aiohttp import web
1717except ImportError :
18- print (
18+ raise ImportError ( # pylint: disable=raise-missing-from
1919 "Reactive server requires aiohttp. "
2020 'Please install with "pip install aiohttp" and try again.'
2121 )
22- sys .exit (1 )
2322
2423from pymodbus import __version__ as pymodbus_version
2524from pymodbus .datastore import ModbusServerContext , ModbusSlaveContext
Original file line number Diff line number Diff line change 99from typing import List
1010
1111
12- with contextlib . suppress ( ImportError ) :
12+ try :
1313 from aiohttp import web
14+ except ImportError :
15+ raise ImportError ( # pylint: disable=raise-missing-from
16+ "Simulator server requires aiohttp. "
17+ 'Please install with "pip install aiohttp" and try again.'
18+ )
1419
1520from pymodbus .datastore import ModbusServerContext , ModbusSimulatorContext
1621from pymodbus .datastore .simulator import Label
@@ -124,8 +129,6 @@ def __init__(
124129 custom_actions_module : str = None ,
125130 ):
126131 """Initialize http interface."""
127- if not web :
128- raise RuntimeError ("aiohttp not installed!" )
129132 with open (json_file , encoding = "utf-8" ) as file :
130133 setup = json .load (file )
131134
You can’t perform that action at this time.
0 commit comments