Compare commits
23 Commits
fe29441d1d
...
0.9.8
Author | SHA1 | Date | |
---|---|---|---|
ef778c3e0a | |||
49eb1522b6 | |||
cdeeceeb55 | |||
64089ce72c | |||
7683ec29e9 | |||
285b3514a8 | |||
f32c007b3f | |||
014dc507cc | |||
cec151e564 | |||
26f1caa60e | |||
7092e69e6a | |||
b32bce956f | |||
22bb4e6bd3 | |||
49954d762b | |||
30504239e1 | |||
|
42799296a9 | ||
|
ac54b7cd0d | ||
|
1df2a42196 | ||
|
2909ea7ed4 | ||
|
f55d6c2e19 | ||
|
664b215f16 | ||
|
5fe756ce97 | ||
|
bf28862f1f |
181
.drone.yml
181
.drone.yml
@@ -1,181 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: CentOS7_test
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
variant: CentOS7
|
||||
|
||||
steps:
|
||||
- name: Run unit test
|
||||
environment:
|
||||
PYTHONPATH: ..
|
||||
commands:
|
||||
- cd src
|
||||
- python3 -m unittest -v lmwsip.tests
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: CentOS8_test
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
variant: CentOS8
|
||||
|
||||
steps:
|
||||
- name: Run unit test
|
||||
environment:
|
||||
PYTHONPATH: .
|
||||
commands:
|
||||
- cd src
|
||||
- python3 -m unittest -v lmwsip.tests
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: Ubuntu1804_test
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
variant: Ubuntu1804
|
||||
|
||||
steps:
|
||||
- name: Run unit test
|
||||
environment:
|
||||
PYTHONPATH: .
|
||||
commands:
|
||||
- cd src
|
||||
- python3 -m unittest -v lmwsip.tests
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: Fedora_test
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
variant: Fedora
|
||||
|
||||
steps:
|
||||
- name: Run unit test
|
||||
environment:
|
||||
PYTHONPATH: .
|
||||
commands:
|
||||
- tox
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: docker_python:3.6
|
||||
|
||||
steps:
|
||||
- name: Run unit test
|
||||
image: python:3.6
|
||||
environment:
|
||||
PYTHONPATH: .
|
||||
commands:
|
||||
- pip install python-dateutil
|
||||
- cd src
|
||||
- python -m unittest -v lmwsip.tests
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: docker_python:latest
|
||||
|
||||
steps:
|
||||
- name: Run unit test
|
||||
image: python:latest
|
||||
environment:
|
||||
PYTHONPATH: .
|
||||
commands:
|
||||
- pip install python-dateutil
|
||||
- python --version
|
||||
- cd src
|
||||
- python -m unittest -v lmwsip.tests
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: Build
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
variant: Fedora
|
||||
|
||||
steps:
|
||||
- name: Build package files
|
||||
commands:
|
||||
- python3 -m build
|
||||
- name: Run final test after build
|
||||
commands:
|
||||
- tox
|
||||
- name: Versie toevoegen aan download
|
||||
environment:
|
||||
DOWNLOADDIR: /usr/share/nginx/html/download/python/lmwsip
|
||||
commands:
|
||||
- mkdir -p "$${DOWNLOADDIR}"
|
||||
- cd dist
|
||||
- |
|
||||
for f in *
|
||||
do
|
||||
if [ -f "$${DOWNLOADDIR}/$${f}" ]
|
||||
then
|
||||
echo version error
|
||||
exit 1
|
||||
else
|
||||
cp "$${f}" "$${DOWNLOADDIR}";
|
||||
fi
|
||||
done
|
||||
- ls -l "$${DOWNLOADDIR}"
|
||||
- name: Versie upload naar pypi test
|
||||
environment:
|
||||
TWINE_USERNAME:
|
||||
from_secret: twine_username
|
||||
TWINE_PASSWORD:
|
||||
from_secret: twine_password
|
||||
commands:
|
||||
- python3 -m twine upload --repository testpypi dist/*
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
|
||||
depends_on:
|
||||
- CentOS7_test
|
||||
- CentOS8_test
|
||||
- Ubuntu1804_test
|
||||
- Fedora_test
|
||||
- docker_python:latest
|
||||
- docker_python:3.6
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: installCheck
|
||||
|
||||
steps:
|
||||
- name: install Check
|
||||
image: python:3.6
|
||||
# Make sure we run the pip installed version
|
||||
commands:
|
||||
- rm -rf src
|
||||
- pip install --extra-index-url https://marceln.org/download/python lmwsip
|
||||
- python -c "import lmwsip"
|
||||
- python -c "import lmwsip; print(lmwsip.__version__)"
|
||||
- >
|
||||
[ $(python -c "import lmwsip; print(lmwsip.__version__)") =
|
||||
$(python setup.py --version) ]
|
||||
- python -m unittest -v lmwsip.tests
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
|
||||
depends_on:
|
||||
- Build
|
21
.gitea/workflows/build.yml
Normal file
21
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
name: build
|
||||
on:
|
||||
- push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: fedora-builder
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Build package
|
||||
run: python3 -m build
|
||||
- name: run tox
|
||||
run: tox
|
||||
- name: Upload na pypi
|
||||
env:
|
||||
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||
if: github.ref_type == 'tag'
|
||||
run: python3 -m twine upload dist/*
|
@@ -12,12 +12,10 @@ how to use it.
|
||||
|
||||
## Installing
|
||||
|
||||
The package is not available on [PyPI](https://pypi.org/).
|
||||
At the moment the package is hosted at https://marceln.org/download/python.
|
||||
Just install the package with 'pip':
|
||||
|
||||
You can install the package with pip:
|
||||
```
|
||||
pip install --extra-index-url https://marceln.org/download/python lmwsip
|
||||
pip install lmwsip
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
set -e
|
||||
|
||||
yamllint .gitea/workflows/*yml
|
||||
|
||||
VERSION=$(grep version setup.cfg | sed 's/.*= *//')
|
||||
sed -i "s/^__version__ = .*/__version__ = '${VERSION}'/" src/lmwsip/__init__.py
|
||||
git add src/lmwsip/__init__.py
|
||||
|
||||
tox
|
||||
yamllint .drone.yml
|
||||
|
@@ -1,16 +1,17 @@
|
||||
[metadata]
|
||||
name = lmwsip
|
||||
version = 0.9.3
|
||||
version = 0.9.8
|
||||
author = Marcel Nijenhof
|
||||
author_email = pypi@marceln.org
|
||||
description = Interface for the lmw sip protocol
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
url = https://marceln.org/git/Werk/lmwsip
|
||||
url = https://git.marceln.org/Werk/lmwsip
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
License :: OSI Approved :: MIT License
|
||||
Operating System :: OS Independent
|
||||
Development Status :: 4 - Beta
|
||||
|
||||
[options]
|
||||
package_dir =
|
||||
|
@@ -12,7 +12,7 @@ from datetime import datetime, timedelta
|
||||
from dateutil import tz
|
||||
|
||||
""" Version info changed by git hook """
|
||||
__version__ = '0.9.2'
|
||||
__version__ = '0.9.7'
|
||||
|
||||
class LmwSip:
|
||||
"""Class to connect to the LMW Standard Interface prototcol (sip)
|
||||
@@ -27,7 +27,12 @@ Support for:
|
||||
ti
|
||||
cmd(wn, vw, as)
|
||||
|
||||
lmwParameters:
|
||||
- Type: WN, VW, AS
|
||||
- Array size: [1-201]
|
||||
- Periode: 1, 10
|
||||
"""
|
||||
|
||||
lmwParameters = {
|
||||
'Tm02_MV': ('VW', 1, 0),
|
||||
'xH1': ('WN', 1, 1),
|
||||
@@ -489,7 +494,12 @@ Support for:
|
||||
'xH60': ('WN', 1, 60),
|
||||
'xNI60': ('WN', 1, 60),
|
||||
'xQ60': ('WN', 1, 60),
|
||||
'xH60R': ('WN', 1, 60)
|
||||
'xH60R': ('WN', 1, 60),
|
||||
'QfQStt10': ('WN', 1, 10),
|
||||
'QfQTr10': ('WN', 1, 10),
|
||||
'QfQSt10': ('WN', 1, 10),
|
||||
'QfHYS10': ('WN', 1, 10),
|
||||
'QfQSy10': ('WN', 1, 10)
|
||||
}
|
||||
|
||||
def __init__(self, user=None, password=None,
|
||||
@@ -588,7 +598,7 @@ Opens the connection and logs in.
|
||||
"time_of_day": time.strftime("%H:%M", time.gmtime(now)) }
|
||||
|
||||
def connect(self):
|
||||
"""connect()
|
||||
"""Setup the network connection
|
||||
|
||||
connects to lmw with tcp using the values of the object creation.
|
||||
"""
|
||||
@@ -624,7 +634,7 @@ connects to lmw with tcp using the values of the object creation.
|
||||
self._socket = None
|
||||
|
||||
def send(self, sipcmd):
|
||||
"""send(sipcmd)
|
||||
"""Send a sip command to the server
|
||||
|
||||
send a sip command to the server
|
||||
"""
|
||||
@@ -654,7 +664,7 @@ send a sip command to the server
|
||||
raise LmwSipConnectError("LmwSip.telnetheader: Socket connection lost")
|
||||
|
||||
def recv(self):
|
||||
"""recv()
|
||||
"""Recieve the results
|
||||
|
||||
recieve a answer from the sip server
|
||||
"""
|
||||
@@ -697,7 +707,7 @@ recieve a answer from the sip server
|
||||
return(stringbuf)
|
||||
|
||||
def login(self):
|
||||
"""login()
|
||||
"""Login the sip server
|
||||
|
||||
Login lmw using the object creation user, password.
|
||||
Raises a LmwLoginFailure exception on failure
|
||||
@@ -721,7 +731,7 @@ Raises a LmwLoginFailure exception on failure
|
||||
self.login()
|
||||
|
||||
def reconnectcheck(self):
|
||||
"""reconnectcheck()
|
||||
"""Check if we need to reconnect.
|
||||
|
||||
Checks if a reconnect is nessecery.
|
||||
|
||||
@@ -739,7 +749,7 @@ There are two timeouts:
|
||||
self.reconnect()
|
||||
|
||||
def sendrecv(self, cmd):
|
||||
"""sendrecv(cmd)
|
||||
"""Send a a command and recieve the result.
|
||||
|
||||
send the command and recieve the answer.
|
||||
retry on socket failure.
|
||||
@@ -768,7 +778,7 @@ retry on socket failure.
|
||||
return(ret)
|
||||
|
||||
def ti(self):
|
||||
"""ti()
|
||||
"""Recieve the time from the sipserver.
|
||||
|
||||
Request the time from lmw and returns the string.
|
||||
|
||||
@@ -780,7 +790,7 @@ Raises a LmwCmdWarn of failure
|
||||
|
||||
def cmd(self, process, location, parameter, time_delta, day,
|
||||
time_of_day, cmd_type="DATA"):
|
||||
"""cmd(process, location, parameter, time_delta, day, time_of_day)
|
||||
"""Create a sip command from the paramters
|
||||
|
||||
Send a cmd to LMW and returns the lmw string
|
||||
|
||||
@@ -812,9 +822,35 @@ Returns:
|
||||
raise LmwCmdWarn(cmdstr, d)
|
||||
return (d[2:-1])
|
||||
|
||||
def cmdWrite(self, process, location, parameter, time_delta, day,
|
||||
time_of_day, values):
|
||||
"""Write data to LMW
|
||||
|
||||
process: <WNT|VWT|AST>
|
||||
location: <lmw location (e.g. HOEK)>
|
||||
parameter: <lmw parameter (e.g. H10)>
|
||||
time_delta: <Time windows (max 23:59, e.g. +01:00>
|
||||
day: <Date>
|
||||
time_of_day: <Time>
|
||||
data: Values to be writen (e.g. 33/10;35/10).
|
||||
|
||||
Example:
|
||||
lmw.cmd("WNT", "HOEK", "H10", "+00:20", "13-08-2018", "16:00", "33/10;35/10")
|
||||
|
||||
Returns:
|
||||
The LMW answer string
|
||||
"""
|
||||
cmdstr=process + " " + self.meetnet + "," + location + "," + \
|
||||
parameter + "," + time_delta + "," + day + "," + \
|
||||
time_of_day + "," + values + "\r"
|
||||
d = self.sendrecv(cmdstr)
|
||||
if (d[0] != '!'):
|
||||
raise LmwCmdWarn(cmdstr, d)
|
||||
return (d[2:-1])
|
||||
|
||||
def valueStr(self, process, location, parameter, day = None,
|
||||
time_of_day = None):
|
||||
"""value(process, location, parameter, [day], [time_of_day]):
|
||||
"""Get string of values from sip
|
||||
|
||||
Parameters:
|
||||
process: <WN|VW|AS>
|
||||
@@ -841,7 +877,7 @@ Returns a single string value with quality
|
||||
|
||||
def value(self, process, location, parameter, day = None,
|
||||
time_of_day = None):
|
||||
"""value(process, location, parameter, [day], [time_of_day]):
|
||||
"""Get one value from sip
|
||||
|
||||
Parameters:
|
||||
process: <WN|VW|AS>
|
||||
@@ -885,7 +921,7 @@ Returns a single string value or None
|
||||
|
||||
def timeSerie(self, process, location, parameter,
|
||||
startTime, endTime, cmd_type="DATB"):
|
||||
"""timeSerie(process, location, parameter, startTime, endTime, cmd_type="DATA")
|
||||
"""Get a python data structure with the results.
|
||||
|
||||
Parameters:
|
||||
process: <WN|VW|AS>
|
||||
@@ -954,7 +990,7 @@ Errors:
|
||||
return(res)
|
||||
|
||||
def logout(self):
|
||||
"""logout()
|
||||
"""Logut of the sip server,
|
||||
|
||||
Logs of
|
||||
"""
|
||||
@@ -978,7 +1014,7 @@ Note:
|
||||
"""
|
||||
|
||||
def __init__(self, start, delta, values=""):
|
||||
"""lmwTimeSerie(start, delta, values)
|
||||
"""lmwTimeSerie init
|
||||
|
||||
Create a lmwTimeSerie object with:
|
||||
start: Start time
|
||||
@@ -991,7 +1027,7 @@ Create a lmwTimeSerie object with:
|
||||
self.addvalues(start, values)
|
||||
|
||||
def addvalues(self, start, values):
|
||||
"""addvalues(start, delta, values)
|
||||
"""Add values
|
||||
|
||||
Add values to a timeserie
|
||||
start: Start time
|
||||
|
@@ -4,10 +4,10 @@ import sys
|
||||
import io
|
||||
import unittest
|
||||
import lmwsip
|
||||
import lmwsip.tests.stubSipServer
|
||||
import stubSipServer
|
||||
import logging
|
||||
|
||||
from lmwsip.tests.stubSipServer import sipServer
|
||||
from stubSipServer import sipServer
|
||||
from lmwsip.run import run
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil import tz
|
||||
@@ -77,6 +77,10 @@ class lmwsipTest(unittest.TestCase):
|
||||
with self.assertRaises(lmwsip.LmwCmdWarn):
|
||||
self.assertEqual(type(self.sip.cmd("NOP", "DUMMY", "H10", "+00:59", "2020-01-01", "00:00")), str)
|
||||
|
||||
def test_cmdWrite(self):
|
||||
self.login()
|
||||
self.assertEqual(type(self.sip.cmdWrite("WN", "DUMMY", "H10", "+00:20", "2020-01-01", "00:00", "35/10;33/10")), str)
|
||||
|
||||
def test_value(self):
|
||||
self.login()
|
||||
self.assertEqual(type(self.sip.value("WN", "DUMMY", "H10")), str)
|
Reference in New Issue
Block a user