Holger Frey
3 years ago
12 changed files with 358 additions and 84 deletions
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
[flake8] |
||||
per-file-ignores = tests/*:S101 |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
repos: |
||||
- repo: https://github.com/pre-commit/pre-commit-hooks |
||||
rev: v2.4.0 |
||||
hooks: |
||||
- id: check-added-large-files |
||||
- id: check-byte-order-marker |
||||
- id: check-json |
||||
- id: check-merge-conflict |
||||
- id: check-toml |
||||
- id: debug-statements |
||||
- id: detect-private-key |
||||
- repo: local |
||||
hooks: |
||||
- id: isort-project |
||||
name: isort_project |
||||
entry: isort -rc s2watchdog |
||||
language: system |
||||
pass_filenames: false |
||||
- id: isort-test |
||||
name: isort_test |
||||
entry: isort -rc tests |
||||
language: system |
||||
pass_filenames: false |
||||
- id: black |
||||
name: black |
||||
entry: black s2watchdog tests |
||||
language: system |
||||
pass_filenames: false |
||||
- id: flake8 |
||||
name: flake8 |
||||
entry: flake8 s2watchdog tests |
||||
language: system |
||||
pass_filenames: false |
||||
- id: pytest |
||||
name: pytest |
||||
entry: pytest tests |
||||
pass_filenames: false |
||||
language: system |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
0.0.1 - first version |
||||
---------------------- |
||||
|
||||
- setting up the project |
@ -0,0 +1,117 @@
@@ -0,0 +1,117 @@
|
||||
Contributing |
||||
============ |
||||
|
||||
Contributions are welcome, and they are greatly appreciated! Every little bit |
||||
helps, and credit will always be given. |
||||
|
||||
You can contribute in many ways: |
||||
|
||||
Types of Contributions |
||||
---------------------- |
||||
|
||||
### Report Bugs |
||||
|
||||
Report bugs at https://git.cpi.imtek.uni-freiburg.de/CPI/s2watchdog.git/issues. |
||||
|
||||
If you are reporting a bug, please include: |
||||
|
||||
* Your operating system name and version. |
||||
* Any details about your local setup that might be helpful in troubleshooting. |
||||
* Detailed steps to reproduce the bug. |
||||
|
||||
### Fix Bugs |
||||
|
||||
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help |
||||
wanted" is open to whoever wants to implement it. |
||||
|
||||
### Implement Features |
||||
|
||||
Look through the GitHub issues for features. Anything tagged with "enhancement" |
||||
and "help wanted" is open to whoever wants to implement it. |
||||
|
||||
### Write Documentation |
||||
|
||||
s2watchdog could always use more documentation, whether as part of the |
||||
official s2watchdog docs, in docstrings, or even on the web in blog posts, |
||||
articles, and such. |
||||
|
||||
### Submit Feedback |
||||
|
||||
The best way to send feedback is to file an issue at https://git.cpi.imtek.uni-freiburg.de/CPI/s2watchdog.git/issues. |
||||
|
||||
If you are proposing a feature: |
||||
|
||||
* Explain in detail how it would work. |
||||
* Keep the scope as narrow as possible, to make it easier to implement. |
||||
* Remember that this is a volunteer-driven project, and that contributions |
||||
are welcome :) |
||||
|
||||
Get Started! |
||||
------------ |
||||
|
||||
Ready to contribute? Here's how to set up `s2watchdog` for local development. |
||||
|
||||
1. Fork the `s2watchdog` repo on GitHub. |
||||
2. Clone your fork locally:: |
||||
|
||||
`$ git clone git@github.com:your_name_here/s2watchdog.git` |
||||
|
||||
3. Install your local copy into a virtualenv. |
||||
|
||||
`$ cd s2watchdog/` |
||||
`$ make devenv` |
||||
|
||||
4. Create a branch for local development:: |
||||
|
||||
`$ git checkout -b name-of-your-bugfix-or-feature` |
||||
|
||||
Now you can make your changes locally. |
||||
|
||||
5. When you're done making changes, check that your changes passes the linters and the |
||||
tests, including testing other Python versions with tox:: |
||||
|
||||
``` |
||||
$ make lint |
||||
$ make coverage |
||||
$ make tox |
||||
``` |
||||
|
||||
6. Commit your changes and push your branch to GitHub:: |
||||
|
||||
``` |
||||
$ git add . |
||||
$ git commit -m "Your detailed description of your changes." |
||||
$ git push origin name-of-your-bugfix-or-feature |
||||
``` |
||||
|
||||
7. Submit a pull request through the GitHub website. |
||||
|
||||
Pull Request Guidelines |
||||
----------------------- |
||||
|
||||
Before you submit a pull request, check that it meets these guidelines: |
||||
|
||||
1. The pull request should include tests. |
||||
2. If the pull request adds functionality, the docs should be updated. Put |
||||
your new functionality into a function with a docstring, and add the |
||||
feature to the list in README.md and CHANGES.md |
||||
|
||||
Tips |
||||
---- |
||||
|
||||
To run a quick set of tests without coverage report |
||||
|
||||
$ make test |
||||
|
||||
Deploying |
||||
--------- |
||||
|
||||
A reminder for the maintainers on how to deploy. |
||||
Bump the version in `s2watchdog/__init__.py` and |
||||
make sure all your changes are committed (including an entry in CHANGES.md). |
||||
|
||||
$ git tag <new version> |
||||
$ git push |
||||
$ git push --tags |
||||
$ flit publish |
||||
|
@ -1,13 +1,10 @@
@@ -1,13 +1,10 @@
|
||||
BEERWARE |
||||
/* |
||||
* ---------------------------------------------------------------------------- |
||||
* "THE BEER-WARE LICENSE" (Revision 42): |
||||
* frey@imtek.de wrote this file. As long as you retain this notice you |
||||
* can do whatever you want with this stuff. If we meet some day, and you think |
||||
* this stuff is worth it, you can buy me a beer in return. Holger Frey |
||||
* ---------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
The beerware license is very open, close to public domain, but insists on |
||||
honoring the original author by just not claiming that the code is yours. |
||||
Instead assume that someone writing Open Source Software in the domain you’re |
||||
obviously interested in would be a nice match for having a beer with. |
||||
|
||||
So, just keep the name and contact details intact and if you ever meet the |
||||
author in person, just have an appropriate brand of sparkling beverage choice |
||||
together. The conversation will be worth the time for both of you. |
||||
|
||||
(Kudos to https://erdgeist.org/beerware.html) |
||||
|
||||
|
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
.PHONY: clean clean-test clean-pyc clean-build docs help |
||||
.DEFAULT_GOAL := help |
||||
|
||||
define BROWSER_PYSCRIPT |
||||
import os, webbrowser, sys |
||||
|
||||
try: |
||||
from urllib import pathname2url |
||||
except: |
||||
from urllib.request import pathname2url |
||||
|
||||
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) |
||||
endef |
||||
export BROWSER_PYSCRIPT |
||||
|
||||
define PRINT_HELP_PYSCRIPT |
||||
import re, sys |
||||
|
||||
for line in sys.stdin: |
||||
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) |
||||
if match: |
||||
target, help = match.groups() |
||||
print("%-20s %s" % (target, help)) |
||||
endef |
||||
export PRINT_HELP_PYSCRIPT |
||||
|
||||
BROWSER := python -c "$$BROWSER_PYSCRIPT" |
||||
|
||||
help: |
||||
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) |
||||
|
||||
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
|
||||
|
||||
clean-build: ## remove build artifacts
|
||||
rm -fr build/ |
||||
rm -fr dist/ |
||||
rm -fr .eggs/ |
||||
find . -name '*.egg-info' -exec rm -fr {} + |
||||
find . -name '*.egg' -exec rm -f {} + |
||||
|
||||
clean-pyc: ## remove Python file artifacts
|
||||
find . -name '*.pyc' -exec rm -f {} + |
||||
find . -name '*.pyo' -exec rm -f {} + |
||||
find . -name '*~' -exec rm -f {} + |
||||
find . -name '__pycache__' -exec rm -fr {} + |
||||
|
||||
clean-test: ## remove test and coverage artifacts
|
||||
rm -fr .pytest_cache/ |
||||
rm -fr .tox/ |
||||
rm -f .coverage |
||||
rm -fr htmlcov/ |
||||
|
||||
lint: ## reformat with black and check style with flake8
|
||||
isort s2watchdog |
||||
isort tests |
||||
black s2watchdog tests |
||||
flake8 s2watchdog tests |
||||
|
||||
test: lint ## run tests quickly with the default Python
|
||||
pytest tests -x --disable-warnings -m "not fun" |
||||
|
||||
testall: lint ## run tests quickly with the default Python
|
||||
pytest tests |
||||
|
||||
coverage: lint ## full test suite, check code coverage and open coverage report
|
||||
pytest tests --cov=s2watchdog -m "fun" |
||||
coverage html |
||||
$(BROWSER) htmlcov/index.html |
||||
|
||||
tox: ## run fully isolated tests with tox
|
||||
tox |
||||
|
||||
install: ## install updated project.toml with flint
|
||||
flit install --pth-file |
||||
|
||||
devenv: ## setup development environment
|
||||
python3 -m venv --prompt s2watchdog .venv |
||||
.venv/bin/pip3 install --upgrade pip |
||||
.venv/bin/pip3 install "flit>3.2" |
||||
.venv/bin/flit install --pth-file |
||||
|
||||
repo: devenv ## complete project setup with development environment and git repo
|
||||
git init . |
||||
git branch -m main |
||||
git add . |
||||
git commit -m "import of project template" |
||||
git remote add origin https://git.cpi.imtek.uni-freiburg.de/CPI/s2watchdog.git |
||||
git push -u origin main --no-verify |
||||
|
||||
.venv/bin/pre-commit install --install-hooks |
@ -1,12 +0,0 @@
@@ -1,12 +0,0 @@
|
||||
[[source]] |
||||
url = "https://pypi.org/simple" |
||||
verify_ssl = true |
||||
name = "pypi" |
||||
|
||||
[packages] |
||||
"s2watchdog" = {editable = true, path = "."} |
||||
|
||||
[dev-packages] |
||||
|
||||
[requires] |
||||
python_version = "3.7" |
@ -1,25 +0,0 @@
@@ -1,25 +0,0 @@
|
||||
{ |
||||
"_meta": { |
||||
"hash": { |
||||
"sha256": "a7568a70424d02f7de75f3c40f0434e4a03581a9e51e8f18117c08b4025b9261" |
||||
}, |
||||
"pipfile-spec": 6, |
||||
"requires": { |
||||
"python_version": "3.7" |
||||
}, |
||||
"sources": [ |
||||
{ |
||||
"name": "pypi", |
||||
"url": "https://pypi.org/simple", |
||||
"verify_ssl": true |
||||
} |
||||
] |
||||
}, |
||||
"default": { |
||||
"s2watchdog": { |
||||
"editable": true, |
||||
"path": "." |
||||
} |
||||
}, |
||||
"develop": {} |
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
|
||||
|
||||
[build-system] |
||||
requires = ["flit"] |
||||
build-backend = "flit.buildapi" |
||||
|
||||
[project] |
||||
name = "s2watchdog" |
||||
readme = "README.md" |
||||
description = "A simple watchdog script for the deep freezer alert system in our s2 scullery" |
||||
license = { file = "LICENSE" } |
||||
requires-python = ">=3.7" |
||||
dynamic = ["version"] |
||||
|
||||
authors = [ |
||||
{name = "Holger Frey", email = "frey@imtek.de"}, |
||||
] |
||||
|
||||
# see https://pypi.org/classifiers/ |
||||
classifiers = [ |
||||
"Development Status :: 2 - Pre-Alpha", |
||||
"Intended Audience :: Developers", |
||||
"Programming Language :: Python :: 3.7", |
||||
"Programming Language :: Python :: 3.8", |
||||
"Programming Language :: Python :: 3 :: Only", |
||||
"License :: Freely Distributable", |
||||
] |
||||
|
||||
dependencies = [ |
||||
'requests', |
||||
] |
||||
|
||||
[project.urls] |
||||
Source = "https://git.cpi.imtek.uni-freiburg.de/CPI/s2watchdog.git" |
||||
|
||||
[project.scripts] |
||||
s2watchdog = "s2watchdog:run" |
||||
|
||||
[project.optional-dependencies] |
||||
test = [ |
||||
"pytest >=4.0.0", |
||||
"pytest-cov", |
||||
"pytest-mock", |
||||
"pytest-randomly", |
||||
"tox", |
||||
] |
||||
dev = [ |
||||
"black", |
||||
"flake8", |
||||
"flake8-comprehensions", |
||||
"flake8-bandit", |
||||
"isort >= 5.0.0", |
||||
"keyring", |
||||
"pre-commit", |
||||
] |
||||
|
||||
[tool.black] |
||||
line-length = 79 |
||||
target-version = ['py37','py38', 'py39'] |
||||
include = '\.pyi?$' |
||||
extend-exclude = ''' |
||||
# A regex preceded with ^/ will apply only to files and directories |
||||
# in the root of the project. |
||||
^/.git |
||||
^/.tox |
||||
^/.venv |
||||
^/.build |
||||
^/.dist |
||||
''' |
||||
|
||||
[tool.isort] |
||||
line_length=79 |
||||
multi_line_output=3 |
||||
length_sort="True" |
||||
include_trailing_comma="True" |
||||
|
||||
[tool.pytest.ini_options] |
||||
markers = [ |
||||
"fun: marks tests as functional (deselect with '-m \"not fun\"')", |
||||
] |
||||
addopts = [ |
||||
"--strict-markers", |
||||
] |
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
import os |
||||
|
||||
from setuptools import setup, find_packages |
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__)) |
||||
with open(os.path.join(here, 'README.md')) as f: |
||||
README = f.read() |
||||
|
||||
requires = [ |
||||
'requests' |
||||
] |
||||
|
||||
setup( |
||||
name='s2watchdog', |
||||
version='0.0.1', |
||||
description='simple watchdog script for our deep freezer alert system', |
||||
long_description=README, |
||||
classifiers=[ |
||||
'Programming Language :: Python', |
||||
'Environment :: Console', |
||||
'Topic :: System :: Monitoring', |
||||
], |
||||
author='Holger Frey', |
||||
author_email='frey@imtek.de', |
||||
url='https://git.cpi.imtek.uni-freiburg.de/holgi/s2watchdog', |
||||
keywords='alerts', |
||||
packages=find_packages(), |
||||
include_package_data=True, |
||||
zip_safe=False, |
||||
install_requires=requires, |
||||
entry_points={ |
||||
'console_scripts': [ |
||||
's2watchdog = s2watchdog:run', |
||||
], |
||||
}, |
||||
) |
Loading…
Reference in new issue