Skip to content

Commit

Permalink
Merge pull request #88 from 2Fake/development
Browse files Browse the repository at this point in the history
Prepare Release
  • Loading branch information
2Fake authored Mar 12, 2021
2 parents 9ca15bb + 639a1eb commit 79fe8ee
Show file tree
Hide file tree
Showing 85 changed files with 2,302 additions and 1,742 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.145.1/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
ARG VARIANT="3.8"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
RUN python -m pip install --upgrade pip && pip install flake8-cognitive-complexity isort

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
55 changes: 55 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "devolo Home Control API",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
"VARIANT": "3.8"
}
},
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.formatting.provider": "yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--disable=C,R",
"--enable=useless-suppression",
],
"python.sortImports.path": "/usr/local/bin/isort",
"python.sortImports.args": [
"--settings-path=/workspaces/devolo_home_control_api/setup.cfg",
],
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"editor.formatOnSave": true,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true,
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.vscode-pylance",
"sourcery.sourcery",
"visualstudioexptteam.vscodeintellicode",
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip install -e .[test]",
}
3 changes: 1 addition & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

<!--
In case your pull request goes to master, please have a look at the following checklist. Otherwise feel free to remove this chapter.
Put an 'x' in the boxes that apply.
Put an 'x' in the boxes that apply.
-->

- [ ] Version number in \_\_init\_\_.py was properly set.
- [ ] Changelog is updated.
2 changes: 1 addition & 1 deletion .github/workflows/convert_todos_to_issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
LABEL: "# TODO:"
COMMENT_MARKER: "#"
id: "todo"
id: "todo"
93 changes: 76 additions & 17 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,95 @@ name: Python package
on: [push]

jobs:
build:

format:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Check formatting
uses: pre-commit/action@v2.0.0

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Lint with flake8
run: |
python -m pip install --upgrade pip
pip install flake8
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --ignore=E303,W503 --statistics
- name: Lint with pylint
run: |
pip install pylint
pip install -e .
pylint --errors-only --score=n devolo_home_control_api
pylint --exit-zero --score=n --disable=C,E,R --enable=useless-suppression devolo_home_control_api
- name: Lint with mypy
run: |
pip install mypy
mypy --ignore-missing-imports devolo_home_control_api
test:
name: Test with Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Checkout sources
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python setup.py install
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --ignore=E303,W503 --statistics
pip install -e .[test]
- name: Test with pytest
run: |
python setup.py test --addopts --cov=devolo_home_control_api
pytest --cov=devolo_home_control_api
- name: Preserve coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: .coverage

coverage:
name: Upload coverage
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Download coverage
uses: actions/download-artifact@v2
with:
name: coverage
- name: Coveralls
run: |
pip install coveralls==1.10.0
export COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_TOKEN }}
python -m pip install --upgrade pip
pip install wheel coveralls==1.10.0
export COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_TOKEN }}
coveralls
- name: Clean up coverage
uses: geekyeggo/delete-artifact@v1
with:
name: coverage
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Created by https://www.gitignore.io/api/linux,python,pycharm,visualstudiocode
# Edit at https://www.gitignore.io/?templates=linux,python,pycharm,visualstudiocode

###testfile
###testfile
test.py

### Linux ###
Expand Down Expand Up @@ -224,4 +224,3 @@ dmypy.json
### venv
venv/
# End of https://www.gitignore.io/api/linux,python,pycharm,visualstudiocode

14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/mirrors-yapf
rev: 'v0.30.0'
hooks:
- id: yapf
- repo: https://github.com/pycqa/isort
rev: '5.7.0'
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.4.0'
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Defining the system requirements with exact versions typically is difficult. But
* Python 3.6.9
* pip 18.1
* requests 2.22.0
* websocket_client 0.56.0
* websocket_client 0.58.0
* zeroconf 0.24.4

Other versions and even other operating systems might work. Feel free to tell us about your experience. If you want to run our unit tests, you also need:
Expand Down Expand Up @@ -50,10 +50,11 @@ cd devolo_home_control_api
python setup.py install
```

If you want to run out tests, change to the tests directory and start pytest via setup.py.
If you want to run out tests, install the extra requirements and start pytest.

```bash
python setup.py test
pip install -e .[test]
pytest
```

## Quick start
Expand Down
11 changes: 10 additions & 1 deletion devolo_home_control_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
__version__ = "0.16.0"
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError:
from importlib_metadata import PackageNotFoundError, version # type: ignore[no-redef]

try:
__version__ = version("package-name")
except PackageNotFoundError:
# package is not installed - e.g. pulled and run locally
__version__ = "0.0.0"
36 changes: 36 additions & 0 deletions devolo_home_control_api/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
MESSAGE_TYPES = {
"devolo.BinarySensor": "_binary_sensor",
"devolo.BinarySwitch": "_binary_switch",
"devolo.Blinds": "_multi_level_switch",
"devolo.DevicesPage": "_inspect_devices",
"devolo.DewpointSensor": "_multi_level_sensor",
"devolo.Dimmer": "_multi_level_switch",
"devolo.Grouping": "_grouping",
"devolo.HumidityBarValue": "_humidity_bar",
"devolo.HumidityBarZone": "_humidity_bar",
"devolo.mprm.gw.GatewayAccessibilityFI": "_gateway_accessible",
"devolo.Meter": "_meter",
"devolo.MildewSensor": "_binary_sensor",
"devolo.MultiLevelSensor": "_multi_level_sensor",
"devolo.MultiLevelSwitch": "_multi_level_switch",
"devolo.RemoteControl": "_remote_control",
"devolo.SirenMultiLevelSwitch": "_multi_level_switch",
"devolo.ShutterMovementFI": "_binary_sensor",
"devolo.ValveTemperatureSensor": "_multi_level_sensor",
"devolo.VoltageMultiLevelSensor": "_multi_level_sensor",
"devolo.WarningBinaryFI": "_binary_sensor",
"hdm": "_device_state",
"acs.hdm": "_automatic_calibration",
"bas.hdm": "_binary_async",
"bss.hdm": "_binary_sync",
"cps.hdm": "_parameter",
"gds.hdm": "_general_device",
"lis.hdm": "_led",
"mas.hdm": "_multilevel_async",
"mss.hdm": "_multilevel_sync",
"ps.hdm": "_protection",
"stmss.hdm": "_multilevel_sync",
"sts.hdm": "_switch_type",
"trs.hdm": "_temperature_report",
"vfs.hdm": "_led"
}
Loading

0 comments on commit 79fe8ee

Please sign in to comment.