1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-30 00:00:11 +01:00

tests: fix python example

This commit is contained in:
Steffen Vogel 2018-12-04 13:27:42 +01:00
parent 3f74b2ad96
commit c090b0bc76
7 changed files with 23 additions and 17 deletions

View file

@ -134,6 +134,7 @@ add_subdirectory(etc)
add_subdirectory(lib)
add_subdirectory(web)
add_subdirectory(packaging)
add_subdirectory(python)
if(WITH_SRC)
add_subdirectory(src)

View file

@ -20,6 +20,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###################################################################################
add_subdirectory(python)
add_subdirectory(opal)
add_subdirectory(shmem)

View file

@ -1 +0,0 @@
../python/villas/client/

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import villas_pb2
import time, socket, errno, sys, os, os.path
import time, socket, errno, sys, os, signal
layer = sys.argv[1] if len(sys.argv) == 2 else 'udp'
@ -44,20 +44,25 @@ print('Ready. Ctrl-C to quit.')
msg = villas_pb2.Message()
while True:
try:
dgram = skt.recv(1024)
if not dgram:
break
else:
msg.ParseFromString(dgram)
print(msg)
skt.send(msg.SerializeToString())
except KeyboardInterrupt:
print('Shutting down.')
# Gracefully shutdown
def sighandler(signum, frame):
running = False
signal.signal(signal.SIGINT, sighandler)
signal.signal(signal.SIGTERM, sighandler)
running = True
while running:
dgram = skt.recv(1024)
if not dgram:
break
else:
msg.ParseFromString(dgram)
print(msg)
skt.send(msg.SerializeToString())
skt.close()

View file

@ -71,10 +71,10 @@ cat > ${CONFIG_FILE} << EOF
}
EOF
export PYTHONPATH=${BUILDDIR}/clients/python
export PYTHONPATH=${BUILDDIR}/python:${SRCDIR}/python
# Start Python client in background
python ${SRCDIR}/clients/python/villas.py unix &
python ${SRCDIR}/clients/python/client.py unix &
CPID=$!
# Wait for client to be ready
@ -83,11 +83,13 @@ if [ "${LAYER}" = "unix" ]; then
sleep 1
done
fi
sleep 1
villas-pipe -l ${NUM_SAMPLES} ${CONFIG_FILE} py-client > ${OUTPUT_FILE} < ${INPUT_FILE}
kill ${CPID}
wait ${CPID}
# Compare data
villas-test-cmp ${CMPFLAGS} ${INPUT_FILE} ${OUTPUT_FILE}