Skip to content

Commit

Permalink
Updates for Gateway 0.10. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstegeman authored Oct 4, 2019
1 parent f161708 commit 52701ec
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 21 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 0 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from os import path
import functools
import gateway_addon
import signal
import sys
import time
Expand All @@ -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)
Expand All @@ -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)
Expand Down
49 changes: 49 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
14 changes: 5 additions & 9 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytz==2019.1
pytz==2019.2
requests==2.22.0

0 comments on commit 52701ec

Please sign in to comment.