Added Makefile, pre-commit. Also update for 1.5.0
This patch Adds the Makefile for setting up a dev environment as well as fixing the plugin for the 1.5.0 release of aprsd.
This commit is contained in:
parent
2a7167745b
commit
36b2eff71c
|
@ -11,4 +11,4 @@ venv
|
||||||
dist
|
dist
|
||||||
.pytest_cache
|
.pytest_cache
|
||||||
.mypy_cache
|
.mypy_cache
|
||||||
build
|
build
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v3.4.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: detect-private-key
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-docstring-first
|
||||||
|
- id: check-builtin-literals
|
||||||
|
|
||||||
|
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||||
|
rev: v1.16.0
|
||||||
|
hooks:
|
||||||
|
- id: setup-cfg-fmt
|
||||||
|
|
||||||
|
- repo: https://github.com/asottile/add-trailing-comma
|
||||||
|
rev: v2.0.2
|
||||||
|
hooks:
|
||||||
|
- id: add-trailing-comma
|
||||||
|
args: [--py36-plus]
|
||||||
|
|
||||||
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
|
rev: v2.7.4
|
||||||
|
hooks:
|
||||||
|
- id: pyupgrade
|
||||||
|
args:
|
||||||
|
- --py3-plus
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
|
rev: v5.7.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 20.8b1
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
|
||||||
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
|
rev: 3.8.4
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
additional_dependencies: [flake8-bugbear]
|
|
@ -1,6 +1,11 @@
|
||||||
CHANGES
|
CHANGES
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
v1.0.3
|
||||||
|
------
|
||||||
|
|
||||||
|
* Plugin gets the version from pbr version now
|
||||||
|
|
||||||
v1.0.2
|
v1.0.2
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
|
@ -173,4 +173,3 @@
|
||||||
defend, and hold each Contributor harmless for any liability
|
defend, and hold each Contributor harmless for any liability
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
of your accepting any such warranty or additional liability.
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
.PHONY: virtual dev build-requirements black isort flake8
|
||||||
|
|
||||||
|
all: pip dev
|
||||||
|
|
||||||
|
virtual: .venv/bin/pip # Creates an isolated python 3 environment
|
||||||
|
|
||||||
|
.venv/bin/pip:
|
||||||
|
virtualenv -p /usr/bin/python3 .venv
|
||||||
|
|
||||||
|
.venv/bin/aprsd: virtual
|
||||||
|
test -s .venv/bin/aprsd || .venv/bin/pip install -q -e .
|
||||||
|
|
||||||
|
install: virtual
|
||||||
|
.venv/bin/pip install -Ur requirements.txt
|
||||||
|
|
||||||
|
dev-pre-commit:
|
||||||
|
test -s .git/hooks/pre-commit || .venv/bin/pre-commit install
|
||||||
|
|
||||||
|
dev-requirements:
|
||||||
|
test -s .venv/bin/twine || .venv/bin/pip install -q -r dev-requirements.txt
|
||||||
|
|
||||||
|
pip: virtual
|
||||||
|
.venv/bin/pip install -q -U pip
|
||||||
|
|
||||||
|
dev: pip install dev-requirements dev-pre-commit
|
||||||
|
|
||||||
|
pip-tools:
|
||||||
|
test -s .venv/bin/pip-compile || .venv/bin/pip install pip-tools
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf dist/*
|
||||||
|
rm -rf .venv
|
||||||
|
|
||||||
|
test: dev
|
||||||
|
.venv/bin/pre-commit run --all-files
|
||||||
|
tox -p
|
||||||
|
|
||||||
|
build: test
|
||||||
|
rm -rf dist/*
|
||||||
|
.venv/bin/python3 setup.py sdist bdist_wheel
|
||||||
|
.venv/bin/twine check dist/*
|
||||||
|
|
||||||
|
upload: build
|
||||||
|
.venv/bin/twine upload dist/*
|
||||||
|
|
||||||
|
update-requirements: dev pip-tools
|
||||||
|
.venv/bin/pip-compile -q -U requirements.in
|
||||||
|
.venv/bin/pip-compile -q -U dev-requirements.in
|
||||||
|
|
||||||
|
.venv/bin/tox: # install tox
|
||||||
|
test -s .venv/bin/tox || .venv/bin/pip install -q -U tox
|
||||||
|
|
||||||
|
check: .venv/bin/tox # Code format check with isort and black
|
||||||
|
tox -efmt-check
|
||||||
|
tox -epep8
|
||||||
|
|
||||||
|
fix: .venv/bin/tox # fixes code formatting with isort and black
|
||||||
|
tox -efmt
|
|
@ -10,7 +10,7 @@ aprsd_slack_plugin
|
||||||
.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
|
.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
|
||||||
:target: https://timothycrosley.github.io/isort/
|
:target: https://timothycrosley.github.io/isort/
|
||||||
|
|
||||||
This project is a python plugin for the APRSD server daemon written by
|
This project is a python plugin for the APRSD server daemon written by
|
||||||
Craig Lamparter. The plugin looks for location APRS commands from a ham
|
Craig Lamparter. The plugin looks for location APRS commands from a ham
|
||||||
radio, then reports that location to a slack channel. This is basically a
|
radio, then reports that location to a slack channel. This is basically a
|
||||||
location proxy.
|
location proxy.
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from aprsd import plugin
|
from aprsd import plugin
|
||||||
|
from aprsd.plugins import location as location_plugin
|
||||||
from slack_sdk import WebClient
|
from slack_sdk import WebClient
|
||||||
from slack_sdk.errors import SlackApiError
|
from slack_sdk.errors import SlackApiError
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ class SlackCommandPlugin(plugin.APRSDPluginBase):
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"APRSD config is missing slack: bot_token:<token>. "
|
"APRSD config is missing slack: bot_token:<token>. "
|
||||||
"Please install the slack app and get the "
|
"Please install the slack app and get the "
|
||||||
"Bot User OAth Access Token."
|
"Bot User OAth Access Token.",
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ class SlackCommandPlugin(plugin.APRSDPluginBase):
|
||||||
if not self.slack_channel:
|
if not self.slack_channel:
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"APRSD config is missing slack: slack_channel: <name> "
|
"APRSD config is missing slack: slack_channel: <name> "
|
||||||
"Please add a slack channel name to send messages."
|
"Please add a slack channel name to send messages.",
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -83,8 +84,8 @@ class SlackCommandPlugin(plugin.APRSDPluginBase):
|
||||||
return
|
return
|
||||||
|
|
||||||
# now call the location plugin to get the location info
|
# now call the location plugin to get the location info
|
||||||
location_plugin = plugin.LocationPlugin(self.config)
|
lp = location_plugin.LocationPlugin(self.config)
|
||||||
location = location_plugin.command(fromcall, message, ack)
|
location = lp.command(fromcall, message, ack)
|
||||||
if location:
|
if location:
|
||||||
reply = location
|
reply = location
|
||||||
|
|
||||||
|
@ -94,8 +95,9 @@ class SlackCommandPlugin(plugin.APRSDPluginBase):
|
||||||
except SlackApiError as e:
|
except SlackApiError as e:
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"Failed to send message to channel '{}' because '{}'".format(
|
"Failed to send message to channel '{}' because '{}'".format(
|
||||||
self.slack_channel, str(e)
|
self.slack_channel,
|
||||||
)
|
str(e),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
LOG.debug("SlackCommandPlugin couldn't get location for '{}'".format(fromcall))
|
LOG.debug("SlackCommandPlugin couldn't get location for '{}'".format(fromcall))
|
||||||
|
|
|
@ -9,3 +9,4 @@ isort
|
||||||
pbr
|
pbr
|
||||||
Sphinx
|
Sphinx
|
||||||
aprsd
|
aprsd
|
||||||
|
pre-commit
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Configuration file for the Sphinx documentation builder.
|
# Configuration file for the Sphinx documentation builder.
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
# pip-compile
|
# pip-compile
|
||||||
#
|
#
|
||||||
aprsd # via -r requirements.in
|
aprsd>=1.5.0 # via -r requirements.in
|
||||||
pbr # via -r requirements.in, aprsd
|
pbr # via -r requirements.in, aprsd
|
||||||
requests # via aprsd
|
requests # via aprsd
|
||||||
six # via aprsd, click-completion, imapclient
|
six # via aprsd, click-completion, imapclient
|
||||||
|
|
12
setup.cfg
12
setup.cfg
|
@ -1,11 +1,10 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = aprsd_slack_plugin
|
name = aprsd_slack_plugin
|
||||||
summary = Amateur radio APRS daemon which listens for messages and responds
|
long_description = file: README.rst
|
||||||
description-file =
|
long_description_content_type = text/x-rst
|
||||||
README.rst
|
|
||||||
long-description-content-type = text/x-rst; charset=UTF-8
|
|
||||||
author = Walter A. Boring IV
|
author = Walter A. Boring IV
|
||||||
author-email = something@somewhere.com
|
author_email = something@somewhere.com
|
||||||
|
license_file = LICENSE.txt
|
||||||
classifier =
|
classifier =
|
||||||
Topic :: Communications :: Ham Radio
|
Topic :: Communications :: Ham Radio
|
||||||
Operating System :: POSIX :: Linux
|
Operating System :: POSIX :: Linux
|
||||||
|
@ -14,6 +13,9 @@ classifier =
|
||||||
Programming Language :: Python :: 3.7
|
Programming Language :: Python :: 3.7
|
||||||
Programming Language :: Python :: 3.8
|
Programming Language :: Python :: 3.8
|
||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
|
description_file =
|
||||||
|
README.rst
|
||||||
|
summary = Amateur radio APRS daemon which listens for messages and responds
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
setup-hooks =
|
setup-hooks =
|
||||||
|
|
|
@ -6,7 +6,7 @@ from aprsd_slack_plugin import aprsd_slack_plugin as slack_plugin
|
||||||
if sys.version_info >= (3, 2):
|
if sys.version_info >= (3, 2):
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
else:
|
else:
|
||||||
import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
|
||||||
class TestPlugin(unittest.TestCase):
|
class TestPlugin(unittest.TestCase):
|
||||||
|
@ -15,7 +15,7 @@ class TestPlugin(unittest.TestCase):
|
||||||
mock_command.return_value = ""
|
mock_command.return_value = ""
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"slack": {"signing_secret": "something", "bot_token": "sometoken", "channel": "hemna"}
|
"slack": {"signing_secret": "something", "bot_token": "sometoken", "channel": "hemna"},
|
||||||
}
|
}
|
||||||
|
|
||||||
p = slack_plugin.SlackCommandPlugin(config)
|
p = slack_plugin.SlackCommandPlugin(config)
|
||||||
|
|
Loading…
Reference in New Issue