diff --git a/.travis.yml b/.travis.yml index a0f253d6..0b787937 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ env: matrix: - DOCKER_BASE=ubuntu:latest - DOCKER_BASE=debian:latest + - DOCKER_BASE=i386/ubuntu:xenial + #~ - DOCKER_BASE=arm32v7/ubuntu:xenial + #~ - DOCKER_BASE=arm64v8/ubuntu:xenial #~ - DOCKER_BASE=resin/rpi-raspbian:latest - DOCS="true" global: diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 492275fc..1b504fd0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,14 @@ Changelog ********* +python_openzwave 0.4.18.x: + * Fix python 2.7/appveyor + + * Add serial port auto-detection + +python_openzwave 0.4.17.x: + * Add wheels for Windows + python_openzwave 0.4.16.x: * Fix appveyor build for windows diff --git a/Makefile b/Makefile index 6e6472c8..9bb1a49b 100644 --- a/Makefile +++ b/Makefile @@ -419,7 +419,7 @@ commit: push @echo "Commits for branches master pushed on github." tag: - git tag v${python_openzwave_version} + -git tag v${python_openzwave_version} git push origin v${python_openzwave_version} @echo @echo "Tag pushed on github." @@ -520,7 +520,7 @@ venv2: virtualenv --python=python2 venv2 venv2/bin/python --version venv2/bin/pip install nose - venv2/bin/pip install Cython==0.28.6 wheel six + venv2/bin/pip install Cython==0.28.6 wheel six pyserial venv2/bin/pip install 'Louie>=1.1' chmod 755 venv2/bin/activate -rm -f src-lib/libopenzwave/libopenzwave.cpp @@ -542,7 +542,7 @@ venv3: virtualenv --python=python3 venv3 venv3/bin/python --version venv3/bin/pip install nose - venv3/bin/pip install Cython==0.28.6 wheel six + venv3/bin/pip install Cython==0.28.6 wheel six pyserial venv3/bin/pip install 'PyDispatcher>=2.0.5' chmod 755 venv3/bin/activate -rm -f src-lib/libopenzwave/libopenzwave.cpp diff --git a/README.rst b/README.rst index 830221cd..c4ae7c44 100755 --- a/README.rst +++ b/README.rst @@ -65,14 +65,14 @@ python-openzwave 0.4.x is here !!! .. code-block:: bash - (venvX) pip install cython wheel six + (venvX) pip install cython wheel six pyserial (venvX) pip install 'Louie>=1.1' - on python 3 : .. code-block:: bash - (venvX) pip install cython wheel six + (venvX) pip install cython wheel six pyserial (venvX) pip install 'PyDispatcher>=2.0.5' - Choose your flavor : diff --git a/appveyor.yml b/appveyor.yml index c9c899e1..0dfab890 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,9 @@ environment: + PYPI_USER: + secure: yna6KiH2GE3Ka1G5a3TlUQ== + PYPI_PASSWORD: + secure: UpISOsYyHdCzurReV6FcTA== + global: # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the # /E:ON and /V:ON options are not enabled in the batch script intepreter @@ -37,6 +42,22 @@ environment: PYTHON_VERSION: "3.4.x" PYTHON_ARCH: "64" + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + PYTHON: "C:\\Python37" + PYTHON_VERSION: "3.7.x" + PYTHON_ARCH: "32" + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + PYTHON: "C:\\Python37-x64" + PYTHON_VERSION: "3.7.x" + PYTHON_ARCH: "64" + +deploy: + - provider: Environment + name: production + on: + APPVEYOR_REPO_TAG: true + install: # If there is a newer build queued for the same PR, cancel this one. # The AppVeyor 'rollout builds' option is supposed to serve the same @@ -78,15 +99,14 @@ install: # target Python version and architecture # - "%CMD_IN_ENV% pip install Cython six" - "python -m pip install wheel" + - "python -m pip install pyserial" - "python -m pip install Cython six" - "python -m pip install nose" + - "python -m pip install twine" - ps: Write-Host "PYTHON_VERSION $env:PYTHON_VERSION" - - ps: if ($env:PYTHON_VERSION -eq "2.7.x") { ` - python -m pip install Louie } ` - else { ` - python -m pip install PyDispatcher } + - cmd: IF "%PYTHON_VERSION%" == "2.7.x" ( python -m pip install Louie ) ELSE ( python -m pip install PyDispatcher ) - git clone git://github.com/OpenZWave/open-zwave.git C:\projects\python-openzwave\openzwave @@ -100,7 +120,7 @@ test_script: - "pyozw_check" - "nosetests --verbose tests/lib/autobuild tests/api/autobuild" -#~ after_test: +after_test: # If tests are successful, create binary packages for the project. - python setup.py bdist_wheel --flavor=dev #~ - "python setup.py bdist_wininst" @@ -109,8 +129,12 @@ test_script: artifacts: # Archive the generated packages in the ci.appveyor.com build report. - - path: dist\* - -#on_success: -# - TODO: upload the content of dist/*.whl to a public wheelhouse -# + - path: dist/* + name: windowswheels + +deploy_script: + # upload to pypi for Windows + - cmd: IF "%APPVEYOR_REPO_TAG%" == "true" (echo "Uploading wheels") + - cmd: IF "%APPVEYOR_REPO_TAG%" == "true" (set HOME=%USERPROFILE%) + - cmd: IF "%APPVEYOR_REPO_TAG%" == "true" (twine upload dist/*.whl --repository-url https://upload.pypi.org/legacy/ -u %PYPI_USER% -p %PYPI_PASSWORD%) + - cmd: IF "%APPVEYOR_REPO_TAG%" == "true" (echo "Finished Artifact Deployment" ) diff --git a/archives/open-zwave-master-0.4.17.zip b/archives/open-zwave-master-0.4.17.zip new file mode 100644 index 00000000..ffa36699 Binary files /dev/null and b/archives/open-zwave-master-0.4.17.zip differ diff --git a/archives/open-zwave-master-0.4.18.zip b/archives/open-zwave-master-0.4.18.zip new file mode 100644 index 00000000..9897a92f Binary files /dev/null and b/archives/open-zwave-master-0.4.18.zip differ diff --git a/archives/open-zwave-master-0.4.19.zip b/archives/open-zwave-master-0.4.19.zip new file mode 100644 index 00000000..62b61c1d Binary files /dev/null and b/archives/open-zwave-master-0.4.19.zip differ diff --git a/archives/python_openzwave-0.4.17.zip b/archives/python_openzwave-0.4.17.zip new file mode 100644 index 00000000..f1008c65 Binary files /dev/null and b/archives/python_openzwave-0.4.17.zip differ diff --git a/archives/python_openzwave-0.4.18.zip b/archives/python_openzwave-0.4.18.zip new file mode 100644 index 00000000..4dafdcfd Binary files /dev/null and b/archives/python_openzwave-0.4.18.zip differ diff --git a/archives/python_openzwave-0.4.19.zip b/archives/python_openzwave-0.4.19.zip new file mode 100644 index 00000000..0c9cafef Binary files /dev/null and b/archives/python_openzwave-0.4.19.zip differ diff --git a/debian/changelog b/debian/changelog index 8a988978..8744ed4c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-openzwave (0.4.16) UNRELEASED; urgency=medium +python-openzwave (0.4.19) UNRELEASED; urgency=medium * Try to fix * Automatic release from upstream. Look at CHANGELOG.txt @@ -24,8 +24,12 @@ python-openzwave (0.4.16) UNRELEASED; urgency=medium * Automatic release from upstream. Look at CHANGELOG.txt * Automatic release from upstream. Look at CHANGELOG.txt * Automatic release from upstream. Look at CHANGELOG.txt + * Automatic release from upstream. Look at CHANGELOG.txt + * Automatic release from upstream. Look at CHANGELOG.txt + * Automatic release from upstream. Look at CHANGELOG.txt + * Automatic release from upstream. Look at CHANGELOG.txt - -- bibi21000 Wed, 19 Dec 2018 03:39:03 +0100 + -- bibi21000 Wed, 20 Mar 2019 10:57:44 +0100 python-openzwave (0.3.0b8) UNRELEASED; urgency=medium diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index a0ef8263..ec9d1b02 100755 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -4,6 +4,15 @@ Changelog ========= +python_openzwave 0.4.18.x: + * Fix python 2.7/appveyor + * Add serial port auto-detection + + +python_openzwave 0.4.17.x: + * Add wheels for Windows + + python_openzwave 0.4.16.x: * Fix appveyor build for windows diff --git a/docs/README.rst b/docs/README.rst index 830221cd..c4ae7c44 100755 --- a/docs/README.rst +++ b/docs/README.rst @@ -65,14 +65,14 @@ python-openzwave 0.4.x is here !!! .. code-block:: bash - (venvX) pip install cython wheel six + (venvX) pip install cython wheel six pyserial (venvX) pip install 'Louie>=1.1' - on python 3 : .. code-block:: bash - (venvX) pip install cython wheel six + (venvX) pip install cython wheel six pyserial (venvX) pip install 'PyDispatcher>=2.0.5' - Choose your flavor : diff --git a/pyozw_setup.py b/pyozw_setup.py index 425bce82..b201840f 100644 --- a/pyozw_setup.py +++ b/pyozw_setup.py @@ -963,7 +963,7 @@ def parse_template(sysargv): current_template = parse_template(sys.argv) def install_requires(): - pkgs = ['six'] + pkgs = ['six', 'pyserial'] if (sys.version_info > (3, 0)): pkgs.append('PyDispatcher>=2.0.5') else: diff --git a/pyozw_version.py b/pyozw_version.py index b6e5aee1..4b4d3e8b 100644 --- a/pyozw_version.py +++ b/pyozw_version.py @@ -21,7 +21,7 @@ along with python-openzwave. If not, see http://www.gnu.org/licenses. """ -pyozw_version = '0.4.16' +pyozw_version = '0.4.19' if "-" in pyozw_version: pyozw_version_short = pyozw_version.split("-") else: diff --git a/src-api/openzwave/controller.py b/src-api/openzwave/controller.py index 38f97dfd..745740a9 100755 --- a/src-api/openzwave/controller.py +++ b/src-api/openzwave/controller.py @@ -367,7 +367,7 @@ def python_library_config_version(self): tversion = "Original %s" % self.library_version fversion = os.path.join(self.library_config_path, 'pyozw_config.version') if os.path.isfile(fversion): - with open(fversion, 'r') as f: + with open(fversion, 'r') as f: val = f.read() tversion = "Git %s" % val return tversion @@ -1378,7 +1378,7 @@ def update_ozw_config(self): shutil.rmtree(dest) except Exception: pass - + if os.path.isdir(self.library_config_path): #Try to remove old config try: @@ -1392,32 +1392,18 @@ def update_ozw_config(self): logger.exception("Can't copy to %s", self.library_config_path) try: - with open(os.path.join(self.library_config_path, 'pyozw_config.version'), 'w') as f: - f.write(time.strftime("%Y-%m-%d %H:%M")) + with open(os.path.join(self.library_config_path, 'pyozw_config.version'), 'w') as f: + f.write(time.strftime("%Y-%m-%d %H:%M")) except Exception: logger.exception("Can't update %s", os.path.join(self.library_config_path, 'pyozw_config.version')) - shutil.rmtree(dest) + try: + with open(os.path.join(self.library_config_path, '__init__.py'), 'a') as f: + f.write("#This file is part of **python-openzwave** project https://github.com/OpenZWave/python-openzwave.") + except Exception: + logger.exception("Can't create %s", os.path.join(self.library_config_path, '__init__.py')) + + shutil.rmtree(dest) - def update_ozw_config(self): - """ - Update the openzwave config from github. - Not available for shared flavor as we don't want to update the config of the precompiled config. - """ - if self.python_library_flavor in ['shared']: - logger.warning(u"Can't update_ozw_config for this flavor (%s)."%self.python_library_flavor) - return - logger.info(u'Update_ozw_config from github.') - dest = tempfile.mkdtemp() - dest_file = os.path.join(dest, 'open-zwave.zip') - req = urlopen('https://codeload.github.com/OpenZWave/open-zwave/zip/master') - with open(dest_file, 'wb') as f: - f.write(req.read()) - zip_ref = zipfile.ZipFile(dest_file, 'r') - zip_ref.extractall(dest) - zip_ref.close() - os.system("cp -rf %s %s"%(os.path.join(dest, 'open-zwave-master', 'config'), self.library_config_path)) - with open(os.path.join(self.library_config_path, 'pyozw_config.version'), 'w') as f: - f.write(time.strftime("%Y-%m-%d %H:%M")) diff --git a/src-api/openzwave/option.py b/src-api/openzwave/option.py index 74571f46..7fc68990 100755 --- a/src-api/openzwave/option.py +++ b/src-api/openzwave/option.py @@ -43,6 +43,32 @@ def emit(self, record): logger = logging.getLogger('openzwave') logger.addHandler(NullHandler()) + +VENDOR_IDS = ('0658',) + + +def _get_z_stick(): + try: + import serial.tools.list_ports + except ImportError: + return None + + for port in serial.tools.list_ports.comports(include_links=False): + if port.vid is None: + continue + if port.product is not None and 'Zigbee' in port.product: + continue + if port.interface is not None and 'Zigbee' in port.interface: + continue + if port.description is not None and 'Zigbee' in port.description: + continue + + for vid in VENDOR_IDS: + if vid.upper() == hex(port.vid)[2:].upper().zfill(4): + return port.device + return None + + class ZWaveOption(libopenzwave.PyOptions): """ Represents a Zwave option used to start the manager. @@ -52,7 +78,7 @@ def __init__(self, device=None, config_path=None, user_path=None, cmd_line=None) """ Create an option object and check that parameters are valid. - :param device: The device to use + :param device: The device to use or None for auto detection (pyserial needs to be installed for auto detection). :type device: str :param config_path: The openzwave config directory. If None, try to configure automatically. :type config_path: str @@ -62,7 +88,13 @@ def __init__(self, device=None, config_path=None, user_path=None, cmd_line=None) :type cmd_line: str """ + if device is None: + device = _get_z_stick() + if platform_system() == 'Windows': + if device and not device.startswith('\\\\.\\'): + device = '\\\\.\\' + device + self._device = device else: #For linux diff --git a/src-python_openzwave/python_openzwave/scripts/pyozw_check.py b/src-python_openzwave/python_openzwave/scripts/pyozw_check.py index 36baa0a0..0d888a2f 100644 --- a/src-python_openzwave/python_openzwave/scripts/pyozw_check.py +++ b/src-python_openzwave/python_openzwave/scripts/pyozw_check.py @@ -65,7 +65,7 @@ def imports(args): time.sleep(0.5) print("Try to import openzwave (API)") import openzwave - + elif args.output == 'raw': import libopenzwave from libopenzwave import PyLogLevels @@ -96,7 +96,7 @@ def zwcallback(zwargs): if notify_type == "DriverReady": global home_id home_id = zwargs['homeId'] - + #~ print("Received {0} : {1}".format(notify_type,libopenzwave.PyNotifications[notify_type].doc)) if args.output == 'txt': print("Received {0}".format(notify_type)) @@ -255,11 +255,11 @@ def list_nodes(args): print("Stop network") network.stop() print("Exit") - + def pyozw_parser(): parser = argparse.ArgumentParser(description='Run python_openzwave basics checks.') parser.add_argument('-o', '--output', action='store', help='The format (txt, raw, ...)', choices=['txt', 'raw'], default='txt') - parser.add_argument('-d', '--device', action='store', help='The device port', default='/dev/ttyUSB0') + parser.add_argument('-d', '--device', action='store', help='The device port', default=None) parser.add_argument('-m', '--imports', action='store_true', help='Import all libs', default=True) parser.add_argument('-i', '--init_device', action='store_true', help='Intialize the device', default=False) parser.add_argument('-l', '--list_nodes', action='store_true', help='List the nodes on zwave network', default=False) @@ -278,7 +278,7 @@ def main(): list_nodes(args) elif args.imports: imports(args) - + if __name__ == '__main__': main() diff --git a/src-python_openzwave/python_openzwave/scripts/pyozw_shell.py b/src-python_openzwave/python_openzwave/scripts/pyozw_shell.py index fd365333..b6b67fb7 100755 --- a/src-python_openzwave/python_openzwave/scripts/pyozw_shell.py +++ b/src-python_openzwave/python_openzwave/scripts/pyozw_shell.py @@ -49,7 +49,7 @@ def main(): '-d', '--device', dest='device', type="str", - default="/dev/ttyUSB0", + default=None, help="The path to your ZWave device") parser.add_option( diff --git a/tests/api/test_command.py b/tests/api/test_command.py index 609187c8..264fe0d3 100644 --- a/tests/api/test_command.py +++ b/tests/api/test_command.py @@ -62,7 +62,8 @@ def test_010_battery_item(self): for node in self.active_nodes: for val in self.active_nodes[node].get_battery_levels() : ran = True - self.assertTrue(isinstance(self.active_nodes[node].get_battery_level(val), integer_types)) + self.assertTrue(isinstance(self.active_nodes[node].get_battery_level(val), + six.integer_types)) if ran == False : self.skipTest("No battery found") diff --git a/tests/api/test_switch.py b/tests/api/test_switch.py index 5b277fe7..697bfff4 100644 --- a/tests/api/test_switch.py +++ b/tests/api/test_switch.py @@ -26,7 +26,9 @@ """ -import os, shutil +import os +import shutil +import sys import time import unittest from pprint import pprint diff --git a/tests/common.py b/tests/common.py index 1c05dee5..badec123 100644 --- a/tests/common.py +++ b/tests/common.py @@ -25,12 +25,9 @@ """ -#The common sleep dealy to wait for network -#We wait 1*SLEEP for network.STATE_AWAKED -#After that we wait 1*SLEEP for network.STATE_READY -SLEEP = 45 - -import sys, os +import os +import shutil +import sys import time import unittest import threading @@ -39,6 +36,11 @@ #~ import bson import six +#The common sleep dealy to wait for network +#We wait 1*SLEEP for network.STATE_AWAKED +#After that we wait 1*SLEEP for network.STATE_READY +SLEEP = 45 + class SetEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, set): diff --git a/tests/manager/autobuild/test_manager.py b/tests/manager/autobuild/test_manager.py index 5c0c6d0b..d8568016 100644 --- a/tests/manager/autobuild/test_manager.py +++ b/tests/manager/autobuild/test_manager.py @@ -32,6 +32,7 @@ import sys import time import logging +import unittest from tests.manager.common import TestManager diff --git a/tests/web/autobuild/test_web.py b/tests/web/autobuild/test_web.py index 2e33446f..52488258 100644 --- a/tests/web/autobuild/test_web.py +++ b/tests/web/autobuild/test_web.py @@ -32,6 +32,7 @@ import sys import time import logging +import unittest #~ from tests.web.common import FlaskTestBase diff --git a/tests/web/test_server.py b/tests/web/test_server.py index 6134f941..b5833cfe 100644 --- a/tests/web/test_server.py +++ b/tests/web/test_server.py @@ -32,6 +32,7 @@ import sys import time import logging +import unittest #~ from flask.ext.socketio import SocketIO, emit, join_room, leave_room, close_room, disconnect #~ from flask.ext.socketio.test_client import SocketIOTestClient