Skip to content

Commit 52701ec

Browse files
authored
Updates for Gateway 0.10. (#1)
1 parent f161708 commit 52701ec

File tree

6 files changed

+84
-21
lines changed

6 files changed

+84
-21
lines changed

.github/workflows/pythonapp.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Python application
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python 3.7
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: 3.7
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install flake8
24+
- name: Lint with flake8
25+
run: |
26+
flake8 . --count --max-line-length=79 --statistics

main.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from os import path
44
import functools
5-
import gateway_addon
65
import signal
76
import sys
87
import time
@@ -12,10 +11,6 @@
1211
from pkg.tide_calendar_adapter import TideCalendarAdapter # noqa
1312

1413

15-
_API_VERSION = {
16-
'min': 2,
17-
'max': 2,
18-
}
1914
_ADAPTER = None
2015

2116
print = functools.partial(print, flush=True)
@@ -30,11 +25,6 @@ def cleanup(signum, frame):
3025

3126

3227
if __name__ == '__main__':
33-
if gateway_addon.API_VERSION < _API_VERSION['min'] or \
34-
gateway_addon.API_VERSION > _API_VERSION['max']:
35-
print('Unsupported API version.')
36-
sys.exit(0)
37-
3828
signal.signal(signal.SIGINT, cleanup)
3929
signal.signal(signal.SIGTERM, cleanup)
4030
_ADAPTER = TideCalendarAdapter(verbose=True)

manifest.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"author": "Mozilla IoT",
3+
"description": "Tide calendar for Mozilla WebThings Gateway",
4+
"gateway_specific_settings": {
5+
"webthings": {
6+
"exec": "python3 {path}/main.py",
7+
"primary_type": "adapter",
8+
"strict_max_version": "*",
9+
"strict_min_version": "0.10.0"
10+
}
11+
},
12+
"homepage_url": "https://github.com/mozilla-iot/tide-calendar-adapter",
13+
"id": "tide-calendar-adapter",
14+
"license": "MPL-2.0",
15+
"manifest_version": 1,
16+
"name": "Tide Calendar",
17+
"options": {
18+
"default": {
19+
"stations": [],
20+
"unit": "ft"
21+
},
22+
"schema": {
23+
"type": "object",
24+
"required": [
25+
"stations",
26+
"unit"
27+
],
28+
"properties": {
29+
"stations": {
30+
"type": "array",
31+
"description": "List of NOAA station IDs",
32+
"items": {
33+
"type": "integer"
34+
}
35+
},
36+
"unit": {
37+
"type": "string",
38+
"description": "Water level unit system",
39+
"enum": [
40+
"english",
41+
"metric"
42+
]
43+
}
44+
}
45+
}
46+
},
47+
"short_name": "Tide",
48+
"version": "0.2.0"
49+
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tide-calendar-adapter",
33
"display_name": "Tide Calendar",
4-
"version": "0.1.0",
4+
"version": "0.2.0",
55
"description": "Tide calendar for Mozilla WebThings Gateway",
66
"author": "Mozilla IoT",
77
"main": "main.py",
@@ -23,9 +23,11 @@
2323
},
2424
"files": [
2525
"LICENSE",
26+
"README.md",
2627
"SHA256SUMS",
2728
"lib",
2829
"main.py",
30+
"manifest.json",
2931
"pkg/__init__.py",
3032
"pkg/tide_calendar_adapter.py",
3133
"pkg/tide_calendar_device.py",

package.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,22 @@ set -e
55
version=$(grep version package.json | cut -d: -f2 | cut -d\" -f2)
66

77
# Clean up from previous releases
8-
rm -rf *.tgz package
9-
rm -f SHA256SUMS
10-
rm -rf lib
8+
rm -rf *.tgz package SHA256SUMS lib
119

1210
# Prep new package
13-
mkdir lib
14-
mkdir package
11+
mkdir lib package
1512

1613
# Pull down Python dependencies
17-
pip3 install -r requirements.txt -t lib --no-binary pyHS100 --prefix ""
14+
pip3 install -r requirements.txt -t lib --no-binary pytz,requests --prefix ""
1815

1916
# Put package together
20-
cp -r lib pkg LICENSE package.json *.py package/
17+
cp -r lib pkg LICENSE manifest.json package.json *.py README.md package/
2118
find package -type f -name '*.pyc' -delete
2219
find package -type d -empty -delete
2320

2421
# Generate checksums
2522
cd package
26-
sha256sum *.py pkg/*.py LICENSE > SHA256SUMS
27-
find lib -type f -exec sha256sum {} \; >> SHA256SUMS
23+
find . -type f \! -name SHA256SUMS -exec sha256sum {} \; >> SHA256SUMS
2824
cd -
2925

3026
# Make the tarball

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytz==2019.1
1+
pytz==2019.2
22
requests==2.22.0

0 commit comments

Comments
 (0)