diff --git a/.black b/.black deleted file mode 100644 index e7ff765..0000000 --- a/.black +++ /dev/null @@ -1,7 +0,0 @@ -[tool.black] -include = '\.pyi?$' -exclude = ''' -/( -\.git -)/ -''' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6f3fbef --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,54 @@ +[tool.black] +include = '\.pyi?$' +exclude = ''' +/( +\.git +)/ +''' + +[build-system] +requires = ["setuptools>=40.8.0"] +build-backend = "setuptools.build_meta" + +[project] +name="pydrs" +classifiers=[ + "Intended Audience :: Science/Research", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering", + "Operating System :: OS Independent" +] +description="" +dependencies = [ + "matplotlib", + "numpy", + "pyserial==3.5" +] +license = {text = "MIT License"} +requires-python=">=3.6" +dynamic=["version", "readme"] + +[tool.setuptools] +zip-safe=false +include-package-data=true + +[tool.setuptools.dynamic] +version = {attr = "pydrs.__version__"} +readme = {file = ["README.md"]} + +[tool.setuptools.packages.find] +where = ["src"] + +[project.optional-dependencies] +dev = [ + "bandit==1.7.0", + "black==21.10b0", + "flake8==4.0.1", + "flake8-bandit==2.1.2", + "flake8-bugbear==21.9.2", + "flake8-implicit-str-concat==0.2.0", + "mypy==0.812", + "mypy-extensions==0.4.3", + "pyflakes==2.3.1", + "types-setuptools" +] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 2c0bea2..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -matplotlib -numpy -pyserial==3.5 diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index f659dd4..0000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,10 +0,0 @@ -bandit==1.7.0 -black==21.10b0 -flake8==4.0.1 -flake8-bandit==2.1.2 -flake8-bugbear==21.9.2 -flake8-implicit-str-concat==0.2.0 -mypy==0.812 -mypy-extensions==0.4.3 -pyflakes==2.3.1 -types-setuptools diff --git a/setup.py b/setup.py index 1a24a96..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,57 +1,3 @@ -#!/usr/bin/env python3 -import pkg_resources -from setuptools import find_packages, setup +from setuptools import setup -from src.pydrs import __author__, __version__ - - -def get_abs_path(relative): - return pkg_resources.resource_filename(__name__, relative) - - -def get_long_description() -> str: - desc = "" - with open(get_abs_path("README.md"), "r") as _f: - desc += _f.read().strip() - - desc += "\n\n" - - with open(get_abs_path("CHANGES.md"), "r") as _f: - desc += _f.read().strip() - - return desc - - -long_description = get_long_description() - - -with open(get_abs_path("requirements.txt"), "r") as _f: - _requirements = _f.read().strip().split("\n") - -setup( - author=__author__, - classifiers=[ - "Intended Audience :: Science/Research", - "Programming Language :: Python :: 3", - "Topic :: Scientific/Engineering", - "Operating System :: OS Independent", - ], - description="", - download_url="https://github.com/lnls-sirius/pydrs", - include_package_data=True, - install_requires=_requirements, - license="MIT License", - long_description=long_description, - long_description_content_type="text/markdown", - name="pydrs", - url="https://github.com/lnls-sirius/pydrs", - version=__version__, - packages=find_packages( - where="src", - include=["pydrs*"], - ), - package_dir={"": "src"}, - python_requires=">=3.6", - test_suite="tests", - zip_safe=False, -) +setup() diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/pydrs/__init__.py b/src/pydrs/__init__.py index 6a4525d..151b920 100644 --- a/src/pydrs/__init__.py +++ b/src/pydrs/__init__.py @@ -1,4 +1,2 @@ -from .info import __author__, __date__, __version__ -from .pydrs import SerialDRS - -__all__ = ["__author__", "__version__", "__date__", "SerialDRS"] +__version__ = "1.2.1" +__date__ = "25/07/2022" diff --git a/src/pydrs/base.py b/src/pydrs/base.py index f4305be..12b4f10 100644 --- a/src/pydrs/base.py +++ b/src/pydrs/base.py @@ -466,7 +466,7 @@ def save_param_bank(self, type_memory: int = 2) -> bytes: + index_to_hex(list_func.index("save_param_bank")) + hex_type ) - + # User defined timeout is temporarily changed to a "safe" value to prevent lockups old_timeout = self.timeout self.timeout = 10 diff --git a/src/pydrs/info.py b/src/pydrs/info.py deleted file mode 100644 index 05f0837..0000000 --- a/src/pydrs/info.py +++ /dev/null @@ -1,5 +0,0 @@ -__author__ = "" -__version__ = "1.2.1" -__date__ = "25/07/2022" - -__all__ = ["__author__", "__version__", "__date__"] diff --git a/src/pydrs/pydrs.py b/src/pydrs/pydrs.py index 90eec37..1b12f50 100644 --- a/src/pydrs/pydrs.py +++ b/src/pydrs/pydrs.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - import re import socket import struct @@ -140,7 +138,7 @@ def timeout(self) -> float: @timeout.setter def timeout(self, new_timeout: float): - self._serial_timeout = new_timeout*1000 + self._serial_timeout = new_timeout * 1000 self.socket.settimeout(new_timeout) def is_open(self) -> bool: diff --git a/src/pydrs/validation.py b/src/pydrs/validation.py index 42d8887..e534580 100644 --- a/src/pydrs/validation.py +++ b/src/pydrs/validation.py @@ -41,7 +41,7 @@ class SerialInvalidCmd(SerialError): def validate(func): def wrapper(*args, **kwargs): reply = func(*args, **kwargs) - if len(reply) == 1 and reply[0] == ETH_ANSWER_NOQUEUE: + if len(reply) == 0 or (len(reply) == 1 and reply[0] == ETH_ANSWER_NOQUEUE): args[0]._reset_input_buffer() raise SerialErrPckgLen( "Received empty response, check if the controller is on and connected"