Skip to content

Commit

Permalink
Merge pull request #15 from eavanvalkenburg/dev
Browse files Browse the repository at this point in the history
major update to master
  • Loading branch information
eavanvalkenburg authored May 26, 2021
2 parents 35a0c3f + 573d2c9 commit f40f1b4
Show file tree
Hide file tree
Showing 66 changed files with 3,614 additions and 2,579 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.163.0/containers/python-3/.devcontainer/base.Dockerfile

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

# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [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
46 changes: 46 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.163.0/containers/python-3
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
"VARIANT": "3.8",
// Options
"INSTALL_NODE": "false",
"NODE_VERSION": "lts/*"
}
},
"appPort": 8126,
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"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.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",
"remote.autoForwardPorts": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [ 8126 ],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "sudo pip3 install -U setuptools setuptools_scm wheel tox; sudo pip3 install -e .[test]",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
34 changes: 22 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
name: CI
name: Test

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
- dev
tags-ignore:
- v*
pull_request:

jobs:
setup_test:
TOX:
name: "Run setup and mypy."
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Run setup of PySIAAlarm
run: python setup.py develop
- name: Test with pytest
run: python setup.py test
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run installs.
run: pip install -e .[test]
- name: Run Tox
run: tox
- name: Run Mypy
run: mypy
37 changes: 18 additions & 19 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

name: Build
name: Build and Release

on:
release:
Expand All @@ -10,20 +9,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel
python setup.py develop
- name: Build and publish
env: # Or as an environment variable
TWINE_USERNAME: ${{ secrets.pypi_username }}
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python setup.py bdist_wheel
twine upload dist/* --non-interactive
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel tox
pip install -e .
- name: Build and publish
env: # Or as an environment variable
TWINE_USERNAME: ${{ secrets.pypi_username }}
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
tox -e build
tox -e publish -- --repository pypi
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ __pycache__/*
.pydevproject
.settings
.idea
.vscode
tags

# Package files
Expand All @@ -31,11 +32,11 @@ tags
# Unittest and coverage
htmlcov/*
.coverage
.coverage.*
.tox
junit.xml
junit*.xml
coverage.xml
.pytest_cache/
.hypothesis

# Build and docs folder/files
build/*
Expand All @@ -49,6 +50,6 @@ MANIFEST

# Per-project virtualenvs
.venv*/
.conda*/

# local config files
local_config.json
tests/*.json
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 19.3b0
rev: 21.4b0
hooks:
- id: black
- repo: https://github.com/timothycrosley/isort
Expand Down
22 changes: 22 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

python:
version: 3.8
install:
- requirements: docs/requirements.txt
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
"request": "test",
"console": "integratedTerminal",
"justMyCode": false,
"logToFile": true
"env": {"PYTEST_ADDOPTS": "--no-cov"}
},
{
"name": "Python: AIO",
"type": "python",
"request": "launch",
"program": "run_aio.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}\\tests"
"cwd": "${workspaceFolder}//tests"
},
{
"name": "Python: Thread",
"type": "python",
"request": "launch",
"program": "run.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}\\tests"
"cwd": "${workspaceFolder}//tests"
},
{
"name": "Python: Client AIO",
"type": "python",
"request": "launch",
"program": "test_client_aio.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}\\tests"
"cwd": "${workspaceFolder}//tests"
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.pythonPath": "C:\\Anaconda3\\python.exe",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.linting.pydocstyleEnabled": true,
Expand Down
16 changes: 3 additions & 13 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@
Changelog
=========

Version 1.0
===========

- V1!
- Cleaned up a lot of code, made the errors and behaviour more consistent with official SIA DC-09 spec.
- Added error_count on SIAServer to show the number of events being sent that were not handled and passed to func.

Version 0.2
===========

- Revised version that handles multiple accounts being listened on on the same server, also optimized some code.

Version 0.1
===========

- Initial version of package for listening to SIA enabled alarm systems.
- Feature A added
- FIX: nasty bug #1729 fixed
- add your changes here!
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 E.A. van Valkenburg
Copyright (c) 2021 E.A. van Valkenburg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
36 changes: 7 additions & 29 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,19 @@ pysiaalarm
==========


Python package for creating a client that talks with SIA-based alarm systems. Currently tested using a Ajax Systems alarm system. If you have other systems please reach out.
Python package for creating a client that talks with SIA-based alarm systems.


Description
===========

This package was created to talk with alarm systems using the SIA protocal, it was tested using a Ajax system, but should support all defined SIA codes.
It creates a new thread with a TCP Server or a asyncio coroutine running bound to a host and port, the alarm system acts a client that sends messages to that server and the server acknowledges the messages and call the supplied function.
A longer description of your project goes here...


Config
==========

For threaded:

.. code-block:: python
from pysiaalarm import SIAClient, SIAAccount
For asyncio:

.. code-block:: python
from pysiaalarm.aio import SIAClient, SIAAccount
The SIAClient takes these arguments:

- host: if there is a specific host to talk to, usually has '' for localhost.
- port: the TCP port your alarm system communicates with.
- accounts: list of type SIAAccount that are to be allowed to send messages to this server
- function: a function that will be called for every event that it handles, takes only a SIAEvent as parameter and does not pass back anything.
.. _pyscaffold-notes:

SIAAccount takes these arguments:
Note
====

- account_id: the account id as 3-16 ASCII hex characters.
- [optional] key: encryption key specified in your alarm system 16, 24, or 32 ASCII characters
- [optional] allowed_timeband: encrypted messages have a timestamp and those are checked against this timeband, by default the timestamp is allowed between -40 and +20 seconds comparing the timestamp in the message and the current timestamp of the system running the server.
This project has been set up using PyScaffold 4.0. For details and usage
information on PyScaffold see https://pyscaffold.org/.
Loading

0 comments on commit f40f1b4

Please sign in to comment.