Aanpassing siprun naar lmwsip.run module
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Splitsing losse run functie - Aanpassing documentatie
This commit is contained in:
25
README.md
25
README.md
@@ -3,12 +3,22 @@
|
|||||||
|
|
||||||
lmwsip is a python library for the lmw sip protocol.
|
lmwsip is a python library for the lmw sip protocol.
|
||||||
|
|
||||||
## Library
|
## Package
|
||||||
|
|
||||||
The lmwsip.py library contains the class LmwSip to connect to the
|
The lmwsip package contains the class LmwSip to connect to the
|
||||||
LMW meetnet using de SIP protocol. The library contains documentation
|
LMW meetnet using de SIP protocol. The library contains documentation
|
||||||
how to use it.
|
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.
|
||||||
|
|
||||||
|
You can install the package with pip:
|
||||||
|
```
|
||||||
|
pip install -i https://marceln.org/download/python lmwsip
|
||||||
|
```
|
||||||
|
|
||||||
## Tools
|
## Tools
|
||||||
### lmwsip-test
|
### lmwsip-test
|
||||||
|
|
||||||
@@ -71,16 +81,15 @@ sip = LmwSip("USER", "PASS")
|
|||||||
pprint(sip.timeSerie("WN", "HOEK", "H10", start, end).ts)
|
pprint(sip.timeSerie("WN", "HOEK", "H10", start, end).ts)
|
||||||
```
|
```
|
||||||
|
|
||||||
### siprun
|
### lmwsip.run
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ./siprun -h sip-lmw.ad.rws.nl -s -p 443 hoek-h10.sip
|
$ python -m lmwsip.run /tmp/hoek-h10.sip
|
||||||
> [LI USER,PASS]
|
> [LI USER,PASS]
|
||||||
< [! ]
|
< [! ]
|
||||||
> [TI LMW]
|
> [TI LMW]
|
||||||
< [! 05-SEP-19 08:24:43]
|
< [! 08-SEP-20 12:03:27]
|
||||||
> [WN LMW,HOEK,H10,-25:00,05-09-2019,08:10,DATA]
|
> [WN LMW,HOEK,H10,-01:00,08-09-2020,11:50,DATA]
|
||||||
< [? 0211 Waarnemingen vallen buiten opslag range]
|
< [! -17/50;-21/50;-24/50;-26/50;-27/50;-28/50;-28/50]
|
||||||
> [LO]
|
> [LO]
|
||||||
< [! ]
|
< [! ]
|
||||||
```
|
```
|
||||||
|
51
lmwsip/run.py
Executable file
51
lmwsip/run.py
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import getopt
|
||||||
|
import argparse
|
||||||
|
from lmwsip import LmwSip
|
||||||
|
|
||||||
|
def run(args):
|
||||||
|
try:
|
||||||
|
lmwsip = LmwSip(host=args.host, port=args.port,
|
||||||
|
ssl=not args.unencrypted,
|
||||||
|
cleartelnet=args.cleartelnet)
|
||||||
|
except Exception as e:
|
||||||
|
print("Connect to lmw failed: %s" % e)
|
||||||
|
exit(1)
|
||||||
|
for f in args.files:
|
||||||
|
for cmd in f:
|
||||||
|
cmd = cmd.replace('{DATE}', args.date)
|
||||||
|
cmd = cmd.replace('{TIME}', args.time)
|
||||||
|
cmd = cmd.replace('\n', '\r')
|
||||||
|
print("> [%s]" % (cmd.strip('\r')))
|
||||||
|
try:
|
||||||
|
lmwsip.send(cmd)
|
||||||
|
print("< [%s]" % (lmwsip.recv().strip('\r')))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def main():
|
||||||
|
lastTime=LmwSip.lasttime(None, "H10")
|
||||||
|
parser = argparse.ArgumentParser(description="Run a sip file.")
|
||||||
|
parser.add_argument("-u", "--unencrypted", action="store_true",
|
||||||
|
help="Run a sip connection without ssl")
|
||||||
|
parser.add_argument("-c", "--cleartelnet", action="store_true",
|
||||||
|
help="Clear telnet protocol in tcp session")
|
||||||
|
parser.add_argument("-H", "--host", action='store',
|
||||||
|
default="sip-lmw.rws.nl",
|
||||||
|
help="Host to connect to")
|
||||||
|
parser.add_argument("-p", "--port", action='store', type=int, default=443,
|
||||||
|
help="Port to connect to")
|
||||||
|
parser.add_argument("-d", "--date", action='store',
|
||||||
|
default=lastTime["day"],
|
||||||
|
help="Date replacement string [DD-MM-YYYY]")
|
||||||
|
parser.add_argument("-t", "--time", action='store',
|
||||||
|
default=lastTime["time_of_day"],
|
||||||
|
help="Time replacement string [HH:MM]")
|
||||||
|
parser.add_argument("files", type=argparse.FileType('r'), nargs="+",
|
||||||
|
help="Sip files to run")
|
||||||
|
run(parser.parse_args())
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Reference in New Issue
Block a user