Skip to content

Commit

Permalink
Merge pull request #342 from riptideio/dev
Browse files Browse the repository at this point in the history
v2.0.1
  • Loading branch information
dhoomakethu authored Sep 27, 2018
2 parents 65c3baf + 7980f08 commit fa724ab
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 2.0.1
-----------------------------------------------------------
* Fix unicode decoder error with BinaryPayloadDecoder in some platforms
* Avoid unnecessary import of deprecated modules with dependencies on twisted

Version 2.0.0
-----------------------------------------------------------
**Note This is a Major release and might affect your existing Async client implementation. Refer examples on how to use the latest async clients.**
Expand Down
12 changes: 11 additions & 1 deletion pymodbus/client/async/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@
# For asyncio the actual client is returned and event loop is asyncio loop
"""
from pymodbus.client.async.deprecated.async import *
from pymodbus.compat import is_installed

installed = is_installed('twisted')
if installed:
# Import deprecated async client only if twisted is installed #338
from pymodbus.client.async.deprecated.async import *
else:
import logging
logger = logging.getLogger(__name__)
logger.warning("Not Importing deprecated clients. "
"Dependency Twisted is not Installed")
2 changes: 1 addition & 1 deletion pymodbus/client/async/deprecated/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
"""


def deprecated(name): # pragma: no cover
def deprecated(name): # pragma: no cover
warnings.warn(WARNING.format(name), DeprecationWarning)
18 changes: 18 additions & 0 deletions pymodbus/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
implements_to_string = lambda x: x

byte2int = lambda b: b
if PYTHON_VERSION >= (3, 4):
def is_installed(module):
import importlib.util
found = importlib.util.find_spec(module)
return found
else:
def is_installed(module):
import importlib
found = importlib.find_loader(module)
return found
# --------------------------------------------------------------------------- #
# python > 2.5 compatability layer
# --------------------------------------------------------------------------- #
Expand All @@ -76,3 +86,11 @@ def implements_to_string(klass):
klass.__unicode__ = klass.__str__
klass.__str__ = lambda x: x.__unicode__().encode('utf-8')
return klass

def is_installed(module):
import imp
try:
imp.find_module(module)
return True
except ImportError:
return False
4 changes: 2 additions & 2 deletions pymodbus/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _unpack_words(self, fstring, handle):
:return:
"""
handle = make_byte_string(handle)
wc = WC.get(fstring.lower())//2
wc = WC.get(fstring.lower()) // 2
up = "!{}H".format(wc)
handle = unpack(up, handle)
if self._wordorder == Endian.Little:
Expand All @@ -340,8 +340,8 @@ def _unpack_words(self, fstring, handle):
# Repack as unsigned Integer
pk = self._byteorder + 'H'
handle = [pack(pk, p) for p in handle]
_logger.debug(handle)
handle = b''.join(handle)
_logger.debug(unicode_string(handle))
return handle

def reset(self):
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __str__(self):
return '[%s, version %s]' % (self.package, self.short())


version = Version('pymodbus', 2, 0, 0)
version = Version('pymodbus', 2, 0, 1)


version.__name__ = 'pymodbus' # fix epydoc error
Expand Down
2 changes: 1 addition & 1 deletion requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Python packages required to run `make docs'.
cryptography==2.1.4 # Required to parse some files
cryptography>= 2.3 # Required to parse some files
humanfriendly==4.4.1
pyasn1==0.4.2 # Required to parse some files
pyserial-asyncio==0.4.0;python_version>="3.4"
Expand Down

0 comments on commit fa724ab

Please sign in to comment.