nox running!
This commit is contained in:
parent
d489d2c5b9
commit
a833069eb5
5 changed files with 40 additions and 11 deletions
15
noxfile.py
15
noxfile.py
|
@ -1,12 +1,27 @@
|
|||
import nox
|
||||
import os
|
||||
|
||||
@nox.session
|
||||
def lint(session):
|
||||
session.install('ruff')
|
||||
session.run('ruff', 'check', '--exclude', 'examples')
|
||||
|
||||
@nox.session
|
||||
def build_and_check_dists(session):
|
||||
session.install("build", "check-manifest >= 0.42", "twine")
|
||||
# session.run("check-manifest", "--ignore", "noxfile.py,tests/**,examples/**")
|
||||
session.run("python", "-m", "build")
|
||||
session.run("python", "-m", "twine", "check", "dist/*")
|
||||
|
||||
@nox.session
|
||||
def tests(session):
|
||||
session.install('pytest')
|
||||
build_and_check_dists(session)
|
||||
|
||||
generated_files = os.listdir("dist/")
|
||||
generated_sdist = os.path.join("dist/", generated_files[1])
|
||||
|
||||
session.install(generated_sdist)
|
||||
|
||||
session.run('pytest')
|
||||
|
||||
|
|
|
@ -1,18 +1,31 @@
|
|||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/pyfroniusreg"]
|
||||
|
||||
[project]
|
||||
name = "Python Fronius Registers"
|
||||
name = "pyFroniusReg"
|
||||
version = "0.0.1"
|
||||
authors = [
|
||||
{ name = "Paul Warren", email="pwarren@pwarren.id.au" }
|
||||
]
|
||||
description = "A library to make interacting with Fronius Inverters and Charging systems simpler"
|
||||
description = "A library to make interacting with Fronius inverters and storage systems simpler"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: AGPL License",
|
||||
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
|
||||
"Operating System :: OS Independent",
|
||||
"Development Status :: 1 - Planning",
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
"pymodbus"
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://git.pwarren.id.au/pwarren/PyFroniusReg/"
|
||||
Issues = "https://git.pwarren.id.au/pwarren/PyFroniusReg/issues"
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from froniusreg import froniusreg
|
||||
|
||||
#from PyFroniusReg import froniusreg
|
||||
#import src.froniusreg
|
||||
import src.pyfroniusreg.froniusreg as froniusreg
|
||||
from pymodbus.client.tcp import ModbusTcpClient
|
||||
|
||||
fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10)
|
||||
|
|
|
@ -42,7 +42,7 @@ class DataType(Enum):
|
|||
return int(2)
|
||||
|
||||
def decode(self, value):
|
||||
decoder = BinaryPayloadDecoder.fromRegisters(value.registers, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||
decoder = BinaryPayloadDecoder.fromRegisters(value.registers, byteorder=Endian.BIG, wordorder=Endian.BIG)
|
||||
|
||||
if (self == DataType.String8) or (self == DataType.String16) or (self == DataType.String32):
|
||||
return str(decoder.decode_string(16).decode('utf-8'))
|
||||
|
@ -66,7 +66,7 @@ class DataType(Enum):
|
|||
return str(decoder.decode_bits())
|
||||
|
||||
def encode(self, value):
|
||||
encoder = BinaryPayloadBuilder(byteorder=Endian.Big, wordorder=Endian.Big)
|
||||
encoder = BinaryPayloadBuilder(byteorder=Endian.BIG, wordorder=Endian.BIG)
|
||||
|
||||
if (self == DataType.String8) or (self == DataType.String16) or (self == DataType.String32):
|
||||
return encoder.add_string(value).build()
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
|
||||
import pyFroniusReg.froniusreg as froniusreg
|
||||
import pyfroniusreg.froniusreg as froniusreg
|
||||
|
||||
class TestDataTypes(unittest.testCase):
|
||||
class TestDataTypes(unittest.TestCase):
|
||||
|
||||
def test_int16(self):
|
||||
assert froniusreg.int16.decode(froniusreg.int16.encode(65536)) == 65535
|
||||
assert froniusreg.int16.decode(froniusreg.int16.encode(1024)) == 1024
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue