Vervangen van {DATE} en {TIME} toegevoegd
This commit is contained in:
@@ -17,7 +17,7 @@ A small test program containing some functions to test the library.
|
|||||||
### siprun
|
### siprun
|
||||||
|
|
||||||
A prgram to run SIP command files.
|
A prgram to run SIP command files.
|
||||||
See "siprun -h" for usage information.
|
See "siprun -H" for usage information.
|
||||||
|
|
||||||
#### hoek-h10.sip
|
#### hoek-h10.sip
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
LI USER,PASS
|
LI USER,PASS
|
||||||
TI LMW
|
TI LMW
|
||||||
WN LMW,HOEK,H10,-01:00,12-02-2019,22:00,DATA
|
WN LMW,HOEK,H10,-01:00,{DATE},{TIME},DATA
|
||||||
LO
|
LO
|
||||||
|
32
siprun
32
siprun
@@ -5,8 +5,12 @@ import getopt
|
|||||||
from lmwsip import LmwSip
|
from lmwsip import LmwSip
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print("siprun [-s] [-h <host>] [-p <port>] [<files>]")
|
print("siprun [-H] [-s] [-d <date>] [-t <time>] [-h <host>] [-p <port>] [<files>]")
|
||||||
|
print("\t-H: Show usage")
|
||||||
print("\t-s: SSL connection")
|
print("\t-s: SSL connection")
|
||||||
|
print("\t-d <date>: Date replacement string (2019-02-14)")
|
||||||
|
print("\t-t <time>: Time replacement string (17:00)")
|
||||||
|
print("\t-h <host>: Connect to host")
|
||||||
print("\t-h <host>: Connect to host")
|
print("\t-h <host>: Connect to host")
|
||||||
print("\t-p <port>: Connect to port")
|
print("\t-p <port>: Connect to port")
|
||||||
print("\t-<files>: LMW commando files")
|
print("\t-<files>: LMW commando files")
|
||||||
@@ -20,11 +24,20 @@ def main():
|
|||||||
usage()
|
usage()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
ssl=False
|
ssl=False
|
||||||
|
time=None
|
||||||
|
date=None
|
||||||
host=None
|
host=None
|
||||||
port=None
|
port=None
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o == "-s":
|
if o == "-H":
|
||||||
|
usage()
|
||||||
|
sys.exit(0)
|
||||||
|
elif o == "-s":
|
||||||
ssl=True
|
ssl=True
|
||||||
|
elif o == "-d":
|
||||||
|
date=a
|
||||||
|
elif o == "-t":
|
||||||
|
time=a
|
||||||
elif o == "-h":
|
elif o == "-h":
|
||||||
host=a
|
host=a
|
||||||
elif o == "-p":
|
elif o == "-p":
|
||||||
@@ -34,11 +47,22 @@ def main():
|
|||||||
usage()
|
usage()
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
lmwsip = LmwSip(ssl=ssl, host=host, port=port)
|
lmwsip = LmwSip(ssl=ssl, host=host, port=port)
|
||||||
|
if (date == None or time == None):
|
||||||
|
# We assume a 10 minut interval so we use H10
|
||||||
|
r = lmwsip.lasttime("H10")
|
||||||
|
print(r)
|
||||||
|
if (date == None):
|
||||||
|
date = r["day"]
|
||||||
|
if (time == None):
|
||||||
|
time = r["time_of_day"]
|
||||||
for cmdfile in args:
|
for cmdfile in args:
|
||||||
with open(cmdfile, "r") as f:
|
with open(cmdfile, "r") as f:
|
||||||
for cmd in f:
|
for cmd in f:
|
||||||
print("> [%s]" % (cmd.strip('\n')))
|
cmd = cmd.replace('{DATE}', date)
|
||||||
lmwsip.send(cmd.replace('\n', '\r'))
|
cmd = cmd.replace('{TIME}', time)
|
||||||
|
cmd = cmd.replace('\n', '\r')
|
||||||
|
print("> [%s]" % (cmd.strip('\r')))
|
||||||
|
lmwsip.send(cmd)
|
||||||
print("< [%s]" % (lmwsip.recv().decode('utf-8').strip('\r')))
|
print("< [%s]" % (lmwsip.recv().decode('utf-8').strip('\r')))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user