diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml new file mode 100644 index 0000000..c23a7cc --- /dev/null +++ b/.github/workflows/pythonapp.yml @@ -0,0 +1,26 @@ +name: Python application + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 + - name: Lint with flake8 + run: | + flake8 . --count --max-line-length=79 --statistics diff --git a/main.py b/main.py index 3990d24..86f7458 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,6 @@ from os import path import functools -import gateway_addon import signal import sys import time @@ -12,10 +11,6 @@ from pkg.tide_calendar_adapter import TideCalendarAdapter # noqa -_API_VERSION = { - 'min': 2, - 'max': 2, -} _ADAPTER = None print = functools.partial(print, flush=True) @@ -30,11 +25,6 @@ def cleanup(signum, frame): if __name__ == '__main__': - if gateway_addon.API_VERSION < _API_VERSION['min'] or \ - gateway_addon.API_VERSION > _API_VERSION['max']: - print('Unsupported API version.') - sys.exit(0) - signal.signal(signal.SIGINT, cleanup) signal.signal(signal.SIGTERM, cleanup) _ADAPTER = TideCalendarAdapter(verbose=True) diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..cb4baa6 --- /dev/null +++ b/manifest.json @@ -0,0 +1,49 @@ +{ + "author": "Mozilla IoT", + "description": "Tide calendar for Mozilla WebThings Gateway", + "gateway_specific_settings": { + "webthings": { + "exec": "python3 {path}/main.py", + "primary_type": "adapter", + "strict_max_version": "*", + "strict_min_version": "0.10.0" + } + }, + "homepage_url": "https://github.com/mozilla-iot/tide-calendar-adapter", + "id": "tide-calendar-adapter", + "license": "MPL-2.0", + "manifest_version": 1, + "name": "Tide Calendar", + "options": { + "default": { + "stations": [], + "unit": "ft" + }, + "schema": { + "type": "object", + "required": [ + "stations", + "unit" + ], + "properties": { + "stations": { + "type": "array", + "description": "List of NOAA station IDs", + "items": { + "type": "integer" + } + }, + "unit": { + "type": "string", + "description": "Water level unit system", + "enum": [ + "english", + "metric" + ] + } + } + } + }, + "short_name": "Tide", + "version": "0.2.0" +} diff --git a/package.json b/package.json index 3d8b94e..bede269 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tide-calendar-adapter", "display_name": "Tide Calendar", - "version": "0.1.0", + "version": "0.2.0", "description": "Tide calendar for Mozilla WebThings Gateway", "author": "Mozilla IoT", "main": "main.py", @@ -23,9 +23,11 @@ }, "files": [ "LICENSE", + "README.md", "SHA256SUMS", "lib", "main.py", + "manifest.json", "pkg/__init__.py", "pkg/tide_calendar_adapter.py", "pkg/tide_calendar_device.py", diff --git a/package.sh b/package.sh index ab43f60..a169be7 100755 --- a/package.sh +++ b/package.sh @@ -5,26 +5,22 @@ set -e version=$(grep version package.json | cut -d: -f2 | cut -d\" -f2) # Clean up from previous releases -rm -rf *.tgz package -rm -f SHA256SUMS -rm -rf lib +rm -rf *.tgz package SHA256SUMS lib # Prep new package -mkdir lib -mkdir package +mkdir lib package # Pull down Python dependencies -pip3 install -r requirements.txt -t lib --no-binary pyHS100 --prefix "" +pip3 install -r requirements.txt -t lib --no-binary pytz,requests --prefix "" # Put package together -cp -r lib pkg LICENSE package.json *.py package/ +cp -r lib pkg LICENSE manifest.json package.json *.py README.md package/ find package -type f -name '*.pyc' -delete find package -type d -empty -delete # Generate checksums cd package -sha256sum *.py pkg/*.py LICENSE > SHA256SUMS -find lib -type f -exec sha256sum {} \; >> SHA256SUMS +find . -type f \! -name SHA256SUMS -exec sha256sum {} \; >> SHA256SUMS cd - # Make the tarball diff --git a/requirements.txt b/requirements.txt index 3ee8e42..db215d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -pytz==2019.1 +pytz==2019.2 requests==2.22.0