diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f867c56..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: python -sudo: required -dist: xenial -python: - - 2.7 - - 3.5 - - 3.6 - - 3.7 - - 3.8-dev -matrix: - allow_failures: - - python: "3.8-dev" -branches: - only: - - master - - develop -addons: - apt: - packages: - - cmake - - build-essential - - libglib2.0-dev - - bluez - - bluetooth - - python-dev - - python3-dev - - libbluetooth-dev - - libboost-python-dev - - libboost-thread-dev -before_install: - - export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g") -install: - - "pip install pytest" - - "pip install pytest-cov" - # - "pip install python-coveralls" - - "pip install Sphinx sphinx_rtd_theme" - - "pip install -e ." -script: py.test tests/ --cov pymetawear --cov-report term-missing -#after_success: -# - coveralls -env: - global: - - GH_REF: github.com/hbldh/pymetawear.git -#deploy: -# provider: script -# skip_cleanup: true -# script: bash ./deploy_gh_pages.sh -# on: -# branch: master -# python: 2.7 diff --git a/HISTORY.rst b/HISTORY.rst index b4e8b16..6f330c1 100755 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,19 @@ History ======= +v0.12.0 (2019-11-01) +----------------------- + +- Using ``metawear`` version ``0.7.0`` + + +v0.11.1 (2019-10-08) +----------------------- + +- Fixes #57 +- Merges #54. +- Added first draft of Azure Pipelines CI building. + v0.11.0 (2018-08-08) -------------------- - Using ``metawear`` version ``0.5.0`` diff --git a/Pipfile b/Pipfile index 0a599b3..01e55d1 100644 --- a/Pipfile +++ b/Pipfile @@ -1,20 +1,15 @@ [[source]] - url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" - [packages] - -metawear = "==0.5.0" +metawear = "==0.7.0" tqdm = "*" - [dev-packages] - pytest = "*" sphinx = "*" sphinx-rtd-theme = "*" pylint = "*" -"flake8" = "*" \ No newline at end of file +"flake8" = "*" diff --git a/README.rst b/README.rst index 6cb788b..782334a 100755 --- a/README.rst +++ b/README.rst @@ -2,8 +2,8 @@ PyMetaWear ========== -.. image:: https://travis-ci.org/hbldh/pymetawear.svg?branch=master - :target: https://travis-ci.org/hbldh/pymetawear +.. image:: https://dev.azure.com/hbldh/github/_apis/build/status/hbldh.pymetawear?branchName=master + :target: https://dev.azure.com/hbldh/github/_build/latest?definitionId=1?branchName=master .. image:: https://coveralls.io/repos/github/hbldh/pymetawear/badge.svg?branch=master :target: https://coveralls.io/github/hbldh/pymetawear?branch=master diff --git a/azure-pipelines.yml b/azure-pipelines.yml index df1eff6..6d029da 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,38 +3,48 @@ # Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/python +trigger: +- master +- releases/* +- develop +- feature/* + jobs: -- job: 'Test' +- job: 'TestLinux' pool: vmImage: 'Ubuntu 16.04' strategy: matrix: - Python27: + Python27-x64: python.version: '2.7' - Python35: + python.architecture: 'x64' + Python35-x64: python.version: '3.5' - Python36: + python.architecture: 'x64' + Python36-x64: python.version: '3.6' - Python37: + python.architecture: 'x64' + Python37-x64: python.version: '3.7' + python.architecture: 'x64' maxParallel: 4 steps: - task: UsePythonVersion@0 inputs: versionSpec: '$(python.version)' - architecture: 'x64' + architecture: '$(python.architecture)' - - script: apt install cmake build-essential libglib2.0-dev bluez bluetooth python-dev python3-dev libbluetooth-dev libboost-python-dev libboost-thread-dev + - script: sudo apt install cmake build-essential libglib2.0-dev bluez bluetooth python-dev python3-dev libbluetooth-dev libboost-python-dev libboost-thread-dev displayName: 'Install system dependencies' - script: python -m pip install --upgrade pip && pip install -r requirements.txt displayName: 'Install Python dependencies' - script: | - pip install pytest - pytest tests --doctest-modules --junitxml=junit/test-results.xml + pip install pytest pytest-cov mock + pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov pymetawear --cov-report term-missing displayName: 'pytest' - task: PublishTestResults@2 @@ -44,15 +54,44 @@ jobs: condition: succeededOrFailed() - job: 'Publish' - dependsOn: 'Test' + dependsOn: 'TestLinux' pool: vmImage: 'Ubuntu 16.04' + strategy: + matrix: + Python27-x64: + python.version: '2.7' + python.architecture: 'x64' + Python35-x64: + python.version: '3.5' + python.architecture: 'x64' + Python36-x64: + python.version: '3.6' + python.architecture: 'x64' + Python37-x64: + python.version: '3.7' + python.architecture: 'x64' + maxParallel: 4 + steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.x' - architecture: 'x64' + versionSpec: '$(python.version)' + architecture: '$(python.architecture)' + + - script: sudo apt install cmake build-essential libglib2.0-dev bluez bluetooth python-dev python3-dev libbluetooth-dev libboost-python-dev libboost-thread-dev + displayName: 'Install system dependencies' + + - script: python -m pip install --upgrade pip && pip install -U setuptools wheel + displayName: 'Install Python dependencies' + + - script: python setup.py sdist bdist_wheel + displayName: 'Build sdist and bdist_wheel' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: dist' + inputs: + PathtoPublish: dist + ArtifactName: 'dist-$(python.version)-$(python.architecture)' - - script: python setup.py sdist - displayName: 'Build sdist' diff --git a/docs/source/index.rst b/docs/source/index.rst index 8c8f77b..4179715 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,8 +6,8 @@ PyMetaWear documentation ======================== -.. image:: https://travis-ci.org/hbldh/pymetawear.svg?branch=master - :target: https://travis-ci.org/hbldh/pymetawear +.. image:: https://dev.azure.com/hbldh/github/_apis/build/status/hbldh.pymetawear?branchName=master + :target: https://dev.azure.com/hbldh/github/_build/latest?definitionId=1?branchName=master .. image:: https://coveralls.io/repos/github/hbldh/pymetawear/badge.svg?branch=master :target: https://coveralls.io/github/hbldh/pymetawear?branch=master diff --git a/examples/magnetometer_logging.py b/examples/magnetometer_logging.py index 13f19d9..3d6ffc8 100644 --- a/examples/magnetometer_logging.py +++ b/examples/magnetometer_logging.py @@ -28,7 +28,7 @@ print(k, v) print("Write magnetometer settings...") -client.magnetometer.set_settings(power_preset='REGULAR') +client.magnetometer.set_settings(power_preset='REGULAR', odr='30') # Not implemented yet... # settings = client.magnetometer.get_current_settings() @@ -40,7 +40,7 @@ client.magnetometer.start_logging() print("Logging magnetometer data...") -time.sleep(3.0) +time.sleep(5.0) client.magnetometer.stop_logging() print("Logging stopped.") diff --git a/examples/settings.py b/examples/settings.py index 2baccfc..cb0f50b 100755 --- a/examples/settings.py +++ b/examples/settings.py @@ -31,7 +31,7 @@ #time.sleep(2.0) print("Set new device name...") -c.settings.set_device_name(name="Antiware") +c.settings.set_device_name(name="hbldh") time.sleep(2.0) @@ -40,7 +40,7 @@ time.sleep(2.0) -scan_response= "\x03\x03\xD8\xfe\x10\x16\xd8\xfe\x00\x12\x00\x6d\x62\x69\x65\x6e\x74\x6c\x61\x62\x00" +scan_response = "\x03\x03\xD8\xfe\x10\x16\xd8\xfe\x00\x12\x00\x6d\x62\x69\x65\x6e\x74\x6c\x61\x62\x00" print("Set custom scan response...") c.settings.set_scan_response(response=scan_response) diff --git a/pymetawear/client.py b/pymetawear/client.py index aebeb82..c39c9c7 100755 --- a/pymetawear/client.py +++ b/pymetawear/client.py @@ -61,6 +61,7 @@ def __init__(self, address, device='hci0', connect=True, debug=False): """Constructor.""" self._address = address self._debug = debug + self._connect = connect if self._debug: add_stream_logger() @@ -86,6 +87,17 @@ def __init__(self, address, device='hci0', connect=True, debug=False): if connect: self.connect() + def __enter__(self): + if not self._connect: + self.connect() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + try: + self.disconnect() + except Exception as e: + print("Could not disconnect: {0}".format(e)) + @property def board(self): return self.mw.board diff --git a/pymetawear/modules/magnetometer.py b/pymetawear/modules/magnetometer.py index 24afda5..f84ecd8 100755 --- a/pymetawear/modules/magnetometer.py +++ b/pymetawear/modules/magnetometer.py @@ -45,6 +45,8 @@ class MagnetometerModule(PyMetaWearLoggingModule): def __init__(self, board, module_id): super(MagnetometerModule, self).__init__(board) + self.current_power_preset = None + self.module_id = module_id self.power_presets = {} @@ -104,17 +106,18 @@ def _get_power_preset(self, value): @require_bmm150 def get_current_settings(self): - raise NotImplementedError() + return { + 'power_preset': self.current_power_preset + } @require_bmm150 def get_possible_settings(self): return { 'power_preset': [sorted(self.power_presets.keys(), key=lambda x:(x.lower()))], - 'odr': [sorted(self.odr.keys(), key=lambda x:(x.lower()))] } @require_bmm150 - def set_settings(self, power_preset): + def set_settings(self, power_preset=None): """Set magnetometer settings. .code-block:: python @@ -128,10 +131,11 @@ def set_settings(self, power_preset): accuracy and power consumption """ - # TODO: Add setting of ODR. - pp = self._get_power_preset(power_preset) - log.debug("Setting Magnetometer power preset to {0}".format(pp)) - libmetawear.mbl_mw_mag_bmm150_set_preset(self.board, pp) + if power_preset is not None: + pp = self._get_power_preset(power_preset) + log.debug("Setting Magnetometer power preset to {0}".format(pp)) + libmetawear.mbl_mw_mag_bmm150_set_preset(self.board, pp) + self.current_power_preset = pp @require_bmm150 def notifications(self, callback=None): diff --git a/pymetawear/version.py b/pymetawear/version.py index d18eb2d..4e884b1 100755 --- a/pymetawear/version.py +++ b/pymetawear/version.py @@ -1,18 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" -version.py ------------ - -Release data for the PyMetaWear project. - -:copyright: 2016-11-28 by hbldh - -""" from __future__ import division from __future__ import print_function from __future__ import absolute_import -__version__ = '0.11.1' +__version__ = '0.12.0' version = __version__ # backwards compatibility name diff --git a/requirements.txt b/requirements.txt index 3946819..3538887 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -metawear==0.5.0 +metawear==0.7.0 tqdm diff --git a/setup.py b/setup.py index 525dbc0..7fcdbf6 100755 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ # What packages are required for this module to be executed? REQUIRED = [ - 'metawear==0.5.0', + 'metawear==0.7.0', 'tqdm', ]