Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d7bf007
python: rdm string handling py3 compat picked from sdbbs pr#1615 9f3…
brucelowekamp Jul 18, 2020
cb60274
python: minor py3 print fix
brucelowekamp Jul 18, 2020
611365c
python: additional py3 case from sdbbs and cleanup comment
brucelowekamp Jul 22, 2020
fe9a0a6
python: add compile test
brucelowekamp Jul 24, 2020
d4acc28
python: add debug logging of messages
brucelowekamp Jul 30, 2020
721cf91
python: clientwrappertest test with message check
brucelowekamp Jul 30, 2020
bd19b88
python: add RDMTest with mocked olad
brucelowekamp Jul 31, 2020
4c63cd2
python: vpath fixes for RDMTest
brucelowekamp Jul 31, 2020
d1802a9
Merge branch '0.10' into sd-ola-py3-patch
brucelowekamp Aug 8, 2020
8704119
remove config logging to find mac error with tests
brucelowekamp Aug 8, 2020
3728c87
python: minor fixes for rdmtest
brucelowekamp Aug 8, 2020
eae77f7
python: switch linux clang build to python 3.8
brucelowekamp Aug 8, 2020
2c06f62
python: do not recompile files that are up to date to avoid race cond…
brucelowekamp Aug 8, 2020
7a36c7f
python: cleanup protocol regression test logging
brucelowekamp Nov 8, 2020
a63857e
Merge branch '0.10' into sd-ola-py3-patch
brucelowekamp Nov 8, 2020
b07fee1
python: refactor rdm pack/unpack with tests for 2/3 byte arrays
brucelowekamp Nov 9, 2020
1d5a880
python: clean up rdm tests a bit more
brucelowekamp Nov 9, 2020
17adb77
python: experimental python3 travis build
brucelowekamp Nov 9, 2020
c8dcc92
python: extra space
brucelowekamp Nov 9, 2020
df542e7
python: use pyenv to set py3 as global default
brucelowekamp Nov 9, 2020
de18f13
python: remove __pycache__ pyc files on clean
brucelowekamp Nov 10, 2020
032ded5
python: fix test to match comment 256
brucelowekamp Nov 11, 2020
95962ae
switch codespell build to use pyenv for py3
brucelowekamp Nov 11, 2020
bf5e002
Merge branch '0.10' into sd-ola-py3-patch
peternewman Nov 14, 2020
ea5ae31
set build log flags back to normal
brucelowekamp Nov 15, 2020
206dd77
python: nack test and general cleanup
brucelowekamp Nov 15, 2020
f178c63
change travis logs to always output test-suite.log
brucelowekamp Nov 15, 2020
03a141e
python: add make variable for opting into python compile test
brucelowekamp Nov 15, 2020
f636029
random build fixes
brucelowekamp Nov 15, 2020
c4ce2f8
python: check specific type of nack in response
brucelowekamp Nov 15, 2020
6d6fed7
python: simpler RDMNack syntax and add comment
brucelowekamp Nov 16, 2020
1eff5f2
python: add encoding check of RTC and comments
brucelowekamp Nov 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ protoc/ola_protoc
protoc/ola_protoc.exe
protoc/ola_protoc_plugin
protoc/ola_protoc_plugin.exe
python/PyCompileTest.sh
python/examples/ola_rdm_set.py
python/ola/ClientWrapperTest.sh
python/ola/OlaClientTest.sh
python/ola/PidStoreLocation.py
python/ola/PidStoreTest.sh
python/ola/RDMTest.sh
python/ola/Version.py
python/ola/rpc/SimpleRpcControllerTest.sh
slp/slp_client
Expand Down
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ matrix:
- os: linux
dist: xenial
compiler: clang
env: TASK='compile'
python: '2.7'
env:
- TASK='compile'
- PYTHON='python3'
addons:
apt:
packages:
Expand All @@ -104,7 +105,6 @@ matrix:
dist: xenial
compiler: gcc
env: TASK='compile'
python: '2.7'
addons:
apt:
packages:
Expand Down Expand Up @@ -178,7 +178,7 @@ matrix:
dist: xenial
env:
- TASK='codespell'
- PATH=/opt/python/3.7.1/bin:$PATH
- PYTHON='python3'
addons:
apt:
packages:
Expand Down Expand Up @@ -314,10 +314,11 @@ install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then pip install --user numpy; fi
- if [ "$TASK" = "coverage" ]; then pip install --user cpp-coveralls; fi
- if [ "$TASK" = "flake8" ]; then pip install --user flake8; fi
- if [ "$TASK" = "codespell" ]; then pip3 install --user git+https://github.com/codespell-project/codespell.git; fi
- if [ "$TASK" = "codespell" ]; then pip install --user git+https://github.com/codespell-project/codespell.git; fi
- if [ "$TASK" = "jshint" ]; then npm install -g grunt-cli; fi

before_install:
- if [ "$PYTHON" == "python3" ]; then pyenv global 3.7.1 ; fi
#Fix permissions for unbound (and possibly others)
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then if [ ! -d /usr/local/sbin ]; then sudo mkdir -p /usr/local/sbin && sudo chown -R $(whoami) /usr/local/sbin; fi; fi
#Add a missing gnupg folder
Expand Down Expand Up @@ -355,12 +356,11 @@ before_install:
- if [ "$TASK" == "spellintian" -o "$TASK" == "spellintian-duplicates" ]; then wget "http://old-releases.ubuntu.com/ubuntu/pool/main/l/lintian/lintian_2.5.104_all.deb"; sudo dpkg -i lintian_*.deb; sudo apt-get install -f -y; fi # Install a later lintian

after_failure:
# Disabled as otherwise the logfile is too big
# - if [ -f ${TRAVIS_BUILD_DIR}/config.log ]; then cat ${TRAVIS_BUILD_DIR}/config.log; fi
- if [ -f ${TRAVIS_BUILD_DIR}/ola-*/_build/config.log ]; then cat ${TRAVIS_BUILD_DIR}/ola-*/_build/config.log; fi
- if [ -f ${TRAVIS_BUILD_DIR}/ola-*/_build/sub/config.log ]; then cat ${TRAVIS_BUILD_DIR}/ola-*/_build/sub/config.log; fi
- if [ -f ${TRAVIS_BUILD_DIR}/ola-*/_build/test-suite.log ]; then cat ${TRAVIS_BUILD_DIR}/ola-*/_build/test-suite.log; fi
- if [ -f ${TRAVIS_BUILD_DIR}/ola-*/_build/sub/test-suite.log ]; then cat ${TRAVIS_BUILD_DIR}/ola-*/_build/sub/test-suite.log; fi
- if [ -f ${TRAVIS_BUILD_DIR}/config.log ]; then cat ${TRAVIS_BUILD_DIR}/config.log; fi
- if [ -f ${TRAVIS_BUILD_DIR}/ola-*/_build/config.log ]; then cat ${TRAVIS_BUILD_DIR}/ola-*/_build/config.log; fi
- if [ -f ${TRAVIS_BUILD_DIR}/ola-*/_build/sub/config.log ]; then cat ${TRAVIS_BUILD_DIR}/ola-*/_build/sub/config.log; fi

after_success:
- if [ "$TASK" = "coverage" ]; then coveralls --gcov /usr/bin/gcov-8 -b . -E '.*Test\.cpp$' -E '.*\.pb\.cc$' -E '.*\.pb\.cpp$' -E '.*\.pb\.h$' -E '.*\.yy\.cpp$' -E '.*\.tab\.cpp$' -E '.*\.tab\.h$' -E '.*/doxygen/examples.*$' --gcov-options '\-lp' > /dev/null; fi
Expand Down
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ built_sources =
# Test scripts are run if BUILD_TESTS is true.
test_scripts =

# directories with python code that should be test compiled during the build
PYTHON_BUILD_DIRS =

# The includes
# -----------------------------------------------------------------------------

Expand All @@ -172,6 +175,7 @@ include plugins/Makefile.mk
include olad/Makefile.mk
include protoc/Makefile.mk
include python/Makefile.mk
include scripts/Makefile.mk
include tools/Makefile.mk

# -----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ AC_CONFIG_LINKS([python/ola/__init__.py:python/ola/__init__.py
python/ola/MACAddress.py:python/ola/MACAddress.py
python/ola/OlaClient.py:python/ola/OlaClient.py
python/ola/PidStore.py:python/ola/PidStore.py
python/ola/RDMAPI.py:python/ola/RDMAPI.py
python/ola/RDMConstants.py:python/ola/RDMConstants.py
python/ola/TestUtils.py:python/ola/TestUtils.py
python/ola/UID.py:python/ola/UID.py
Expand Down
2 changes: 2 additions & 0 deletions data/Makefile.mk
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
include data/rdm/Makefile.mk

PYTHON_BUILD_DIRS += data
4 changes: 4 additions & 0 deletions include/Makefile.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
include include/ola/Makefile.mk
include include/olad/Makefile.mk

# uncomment when include is py3 compatible
# PYTHON_BUILD_DIRS += include

15 changes: 15 additions & 0 deletions python/Makefile.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
include python/examples/Makefile.mk
include python/ola/Makefile.mk

python/PyCompileTest.sh: python/Makefile.mk
mkdir -p $(top_builddir)/python
echo "$(PYTHON) -m compileall $(PYTHON_BUILD_DIRS); exit \$$?" > $(top_builddir)/python/PyCompileTest.sh
chmod +x $(top_builddir)/python/PyCompileTest.sh

PYTHON_BUILD_DIRS += python

if BUILD_PYTHON_LIBS
test_scripts += \
python/PyCompileTest.sh
endif

CLEANFILES += \
python/PyCompileTest.sh
3 changes: 2 additions & 1 deletion python/examples/ola_rdm_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

'''Get a PID from a UID.'''

from __future__ import print_function
import cmd
import getopt
import os.path
Expand Down Expand Up @@ -459,7 +460,7 @@ def main():
try:
PidStore.GetStore(pid_location)
except PidStore.MissingPLASAPIDs as e:
print e
print(e)
sys.exit()

controller = InteractiveModeController(universe,
Expand Down
12 changes: 11 additions & 1 deletion python/ola/ClientWrapperTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Copyright (C) 2019 Bruce Lowekamp

import array
import binascii
import datetime
import socket
# import timeout_decorator
Expand Down Expand Up @@ -208,7 +209,16 @@ class results:

def DataCallback(self):
data = sockets[1].recv(4096)
self.assertTrue(len(data) > 100)
expected = binascii.unhexlify(
"7d000010080110001a0d557064617465446d784461746122680801126400000"
"000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000"
"000000")
Comment thread
peternewman marked this conversation as resolved.
self.assertEqual(data, expected,
msg="Regression check failed. If protocol change "
Comment thread
peternewman marked this conversation as resolved.
"was intended set expected to: " +
str(binascii.hexlify(data)))
results.gotdata = True
wrapper.AddEvent(0, wrapper.Stop)

Expand Down
11 changes: 10 additions & 1 deletion python/ola/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ python/ola/PidStoreTest.sh: python/ola/Makefile.mk
echo "PYTHONPATH=${top_builddir}/python TESTDATADIR=$(srcdir)/common/rdm/testdata $(PYTHON) ${srcdir}/python/ola/PidStoreTest.py; exit \$$?" > $(top_builddir)/python/ola/PidStoreTest.sh
chmod +x $(top_builddir)/python/ola/PidStoreTest.sh

python/ola/RDMTest.sh: python/ola/Makefile.mk
mkdir -p $(top_builddir)/python/ola
echo "PYTHONPATH=${top_builddir}/python PIDSTOREDIR=$(srcdir)/data/rdm $(PYTHON) ${srcdir}/python/ola/RDMTest.py; exit \$$?" > $(top_builddir)/python/ola/RDMTest.sh
chmod +x $(top_builddir)/python/ola/RDMTest.sh

dist_check_SCRIPTS += \
python/ola/DUBDecoderTest.py \
python/ola/ClientWrapperTest.py \
python/ola/MACAddressTest.py \
python/ola/OlaClientTest.py \
python/ola/PidStoreTest.py \
python/ola/RDMTest.py \
python/ola/TestUtils.py \
python/ola/UIDTest.py

Expand All @@ -89,11 +95,14 @@ test_scripts += \
python/ola/MACAddressTest.py \
python/ola/OlaClientTest.sh \
python/ola/PidStoreTest.sh \
python/ola/RDMTest.sh \
python/ola/UIDTest.py
endif

CLEANFILES += \
python/ola/*.pyc \
python/ola/ClientWrapperTest.sh \
python/ola/OlaClientTest.sh \
python/ola/PidStoreTest.sh
python/ola/PidStoreTest.sh \
python/ola/RDMTest.sh \
python/ola/__pycache__/*
Comment thread
peternewman marked this conversation as resolved.
12 changes: 9 additions & 3 deletions python/ola/OlaClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ def message(self):


class RDMNack(object):
"""Nack response to a request.

Individual NACK response reasons can be access as attrs, e.g.
RMDNack.NR_FORMAT_ERROR
"""

NACK_SYMBOLS_TO_VALUES = {
'NR_UNKNOWN_PID': (0, 'Unknown PID'),
'NR_FORMAT_ERROR': (1, 'Format Error'),
Expand Down Expand Up @@ -1224,7 +1230,7 @@ def RunRDMDiscovery(self, universe, full, callback):
raise OLADNotRunningException()
return True

def RDMGet(self, universe, uid, sub_device, param_id, callback, data='',
def RDMGet(self, universe, uid, sub_device, param_id, callback, data=b'',
include_frames=False):
"""Send an RDM get command.

Expand All @@ -1246,7 +1252,7 @@ def RDMGet(self, universe, uid, sub_device, param_id, callback, data='',
return self._RDMMessage(universe, uid, sub_device, param_id, callback,
data, include_frames)

def RDMSet(self, universe, uid, sub_device, param_id, callback, data='',
def RDMSet(self, universe, uid, sub_device, param_id, callback, data=b'',
include_frames=False):
"""Send an RDM set command.

Expand Down Expand Up @@ -1274,7 +1280,7 @@ def SendRawRDMDiscovery(self,
sub_device,
param_id,
callback,
data='',
data=b'',
include_frames=False):
"""Send an RDM Discovery command. Unless you're writing RDM tests you
shouldn't need to use this.
Expand Down
20 changes: 13 additions & 7 deletions python/ola/PidStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Error(Exception):


class InvalidPidFormat(Error):
"Indicates the PID data file was invalid."""
"""Indicates the PID data file was invalid."""


class PidStructureException(Error):
Expand Down Expand Up @@ -458,7 +458,7 @@ def _AccountForMultiplierPack(self, value):
raise ArgsValidationError(
'Conversion will lose data: %d -> %d' %
(new_value, (new_value / multiplier * multiplier)))
new_value = new_value / multiplier
new_value = int(new_value / multiplier)
Comment thread
peternewman marked this conversation as resolved.

else:
try:
Expand Down Expand Up @@ -645,7 +645,10 @@ def Pack(self, args):
(self.name, self.min))

try:
data = struct.unpack('%ds' % arg_size, arg)
if sys.version >= '3.2':
data = struct.unpack('%ds' % arg_size, bytes(arg, 'utf8'))
else:
data = struct.unpack('%ds' % arg_size, arg)
except struct.error as e:
raise ArgsValidationError("Can't pack data: %s" % e)
return data[0], 1
Expand All @@ -665,7 +668,10 @@ def Unpack(self, data):
except struct.error as e:
raise UnpackException(e)

return value[0].rstrip('\x00')
if sys.version >= '3.2':
return value[0].rstrip(b'\x00').decode('utf-8')
else:
return value[0].rstrip(b'\x00')

def GetDescription(self, indent=0):
indent = ' ' * indent
Expand Down Expand Up @@ -807,10 +813,10 @@ def Pack(self, args):
raise ArgsValidationError('Too many arguments, expected %d, got %d' %
(arg_offset, len(args)))

return ''.join(data), arg_offset
return b''.join(data), arg_offset

elif self._group_size == 0:
return '', 0
return b'', 0
else:
# this could be groups of fields, but we don't support that yet
data = []
Expand All @@ -823,7 +829,7 @@ def Pack(self, args):
if arg_offset < len(args):
raise ArgsValidationError('Too many arguments, expected %d, got %d' %
(arg_offset, len(args)))
return ''.join(data), arg_offset
return b''.join(data), arg_offset

def Unpack(self, data):
"""Unpack binary data.
Expand Down
Loading