diff --git a/Makefile b/Makefile index 5152023..edbad2a 100644 --- a/Makefile +++ b/Makefile @@ -1,58 +1,50 @@ .PHONY: virtual dev build-requirements black isort flake8 +REQUIREMENTS_TXT ?= requirements.txt dev-requirements.txt + +include Makefile.venv +Makefile.venv: + curl \ + -o Makefile.fetched \ + -L "https://github.com/sio/Makefile.venv/raw/v2020.08.14/Makefile.venv" + echo "5afbcf51a82f629cd65ff23185acde90ebe4dec889ef80bbdc12562fbd0b2611 *Makefile.fetched" \ + | sha256sum --check - \ + && mv Makefile.fetched Makefile.venv + all: pip dev -virtual: .venv/bin/pip # Creates an isolated python 3 environment +.PHONY: dev +dev: venv + $(VENV)/pre-commit install -.venv/bin/pip: - virtualenv -p /usr/bin/python3 .venv +.PHONY: docs +docs: build + cp README.rst docs/readme.rst + cp Changelog docs/changelog.rst + tox -edocs -.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: +clean: clean-venv rm -rf dist/* - rm -rf .venv +.PHONY: test test: dev - .venv/bin/pre-commit run --all-files tox -p all build: test - rm -rf dist/* - .venv/bin/python3 setup.py sdist bdist_wheel - .venv/bin/twine check dist/* + $(VENV)/python3 setup.py sdist bdist_wheel + $(VENV)/twine check dist/* upload: build - .venv/bin/twine upload dist/* + $(VENV)/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 +update-requirements: dev + $(VENV)/pip-compile requirements.in + $(VENV)/pip-compile 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 +check: dev # Code format check with isort and black tox -efmt-check tox -epep8 -fix: .venv/bin/tox # fixes code formatting with isort and black +fix: dev # fixes code formatting with isort and black tox -efmt diff --git a/aprsd_slack_plugin/aprsd_slack_plugin.py b/aprsd_slack_plugin/aprsd_slack_plugin.py deleted file mode 100644 index c8bb940..0000000 --- a/aprsd_slack_plugin/aprsd_slack_plugin.py +++ /dev/null @@ -1,105 +0,0 @@ -import logging - -from aprsd import plugin -from aprsd.plugins import location as location_plugin -from slack_sdk import WebClient -from slack_sdk.errors import SlackApiError - -import aprsd_slack_plugin - -LOG = logging.getLogger("APRSD") - - -class SlackCommandPlugin(plugin.APRSDPluginBase): - """SlackCommandPlugin. - - This APRSD plugin looks for the location command comming in - to aprsd, then fetches the caller's location, and then reports - that location string to the configured slack channel. - - To use this: - Create a slack bot for your workspace at api.slack.com. - A good source of information on how to create the app - and the tokens and permissions and install the app in your - workspace is here: - - https://api.slack.com/start/building/bolt-python - - - You will need the signing secret from the - Basic Information -> App Credentials form. - You will also need the Bot User OAuth Access Token from - OAuth & Permissions -> OAuth Tokens for Your Team -> - Bot User OAuth Access Token. - - Install the app/bot into your workspace. - - Edit your ~/.config/aprsd/aprsd.yml and add the section - slack: - signing_secret: - bot_token: - channel: - """ - - version = aprsd_slack_plugin.__version__ - - # matches any string starting with h or H - command_regex = "^[lL]" - command_name = "location-slack" - - def _setup_slack(self): - """Create the slack require client from config.""" - - # signing_secret = self.config["slack"]["signing_secret"] - if "slack" not in self.config: - LOG.error("APRSD config is missing slack section") - return False - - bot_token = self.config["slack"].get("bot_token", None) - if not bot_token: - LOG.error( - "APRSD config is missing slack: bot_token:. " - "Please install the slack app and get the " - "Bot User OAth Access Token.", - ) - return False - - self.swc = WebClient(token=bot_token) - - self.slack_channel = self.config["slack"].get("channel", None) - if not self.slack_channel: - LOG.error( - "APRSD config is missing slack: slack_channel: " - "Please add a slack channel name to send messages.", - ) - return False - - return True - - def command(self, fromcall, message, ack): - LOG.info("SlackCommandPlugin") - - is_setup = self._setup_slack() - if not is_setup: - return - - # now call the location plugin to get the location info - lp = location_plugin.LocationPlugin(self.config) - location = lp.command(fromcall, message, ack) - if location: - reply = location - - LOG.debug("Sending '{}' to slack channel '{}'".format(reply, self.slack_channel)) - try: - self.swc.chat_postMessage(channel=self.slack_channel, text=reply) - except SlackApiError as e: - LOG.error( - "Failed to send message to channel '{}' because '{}'".format( - self.slack_channel, - str(e), - ), - ) - else: - LOG.debug("SlackCommandPlugin couldn't get location for '{}'".format(fromcall)) - - return None diff --git a/dev-requirements.in b/dev-requirements.in index b4fc8da..da88fa3 100644 --- a/dev-requirements.in +++ b/dev-requirements.in @@ -10,3 +10,4 @@ pbr Sphinx aprsd pre-commit +pip-tools diff --git a/dev-requirements.txt b/dev-requirements.txt index e3b4e76..d6f23cb 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,11 +1,279 @@ -tox -pytest -pytest-cov -mypy -flake8 -pep8-naming -black -isort -pbr -Sphinx -aprsd +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile dev-requirements.in +# +alabaster==0.7.12 + # via sphinx +appdirs==1.4.4 + # via + # black + # virtualenv +aprsd==1.6.1 + # via -r dev-requirements.in +aprslib==0.6.47 + # via aprsd +attrs==21.2.0 + # via pytest +babel==2.9.1 + # via sphinx +backoff==1.10.0 + # via + # aprsd + # opencage +black==21.6b0 + # via -r dev-requirements.in +certifi==2020.12.5 + # via + # aprsd + # requests +cffi==1.14.4 + # via + # aprsd + # cryptography +cfgv==3.3.0 + # via pre-commit +chardet==4.0.0 + # via + # aprsd + # requests +click-completion==0.5.2 + # via aprsd +click==7.1.2 + # via + # aprsd + # black + # click-completion + # flask + # pip-tools +coverage==5.5 + # via pytest-cov +cryptography==3.3.2 + # via + # aprsd + # pyopenssl +distlib==0.3.2 + # via virtualenv +dnspython==2.1.0 + # via + # aprsd + # py3-validate-email +docutils==0.17.1 + # via sphinx +filelock==3.0.12 + # via + # aprsd + # py3-validate-email + # tox + # virtualenv +flake8-polyfill==1.0.2 + # via pep8-naming +flake8==3.9.2 + # via + # -r dev-requirements.in + # flake8-polyfill +flask-classful==0.14.2 + # via aprsd +flask-httpauth==4.2.0 + # via aprsd +flask==1.1.2 + # via + # aprsd + # flask-classful + # flask-httpauth +identify==2.2.10 + # via pre-commit +idna==2.10 + # via + # aprsd + # py3-validate-email + # requests +imagesize==1.2.0 + # via sphinx +imapclient==2.2.0 + # via aprsd +iniconfig==1.1.1 + # via pytest +isort==5.8.0 + # via -r dev-requirements.in +itsdangerous==1.1.0 + # via + # aprsd + # flask +jinja2==2.11.3 + # via + # aprsd + # click-completion + # flask + # sphinx +lxml==4.6.3 + # via + # aprsd + # yfinance +markupsafe==1.1.1 + # via + # aprsd + # jinja2 +mccabe==0.6.1 + # via flake8 +multitasking==0.0.9 + # via + # aprsd + # yfinance +mypy-extensions==0.4.3 + # via + # black + # mypy +mypy==0.902 + # via -r dev-requirements.in +nodeenv==1.6.0 + # via pre-commit +numpy==1.20.1 + # via + # aprsd + # pandas + # yfinance +opencage==1.2.2 + # via aprsd +packaging==20.9 + # via + # pytest + # sphinx + # tox +pandas==1.2.2 + # via + # aprsd + # yfinance +pathspec==0.8.1 + # via black +pbr==5.5.1 + # via + # -r dev-requirements.in + # aprsd +pep517==0.10.0 + # via pip-tools +pep8-naming==0.11.1 + # via -r dev-requirements.in +pip-tools==6.1.0 + # via -r dev-requirements.in +pluggy==0.13.1 + # via + # aprsd + # pytest + # tox +pre-commit==2.13.0 + # via -r dev-requirements.in +py3-validate-email==0.2.12 + # via aprsd +py==1.10.0 + # via + # pytest + # tox +pycodestyle==2.7.0 + # via flake8 +pycparser==2.20 + # via + # aprsd + # cffi +pyflakes==2.3.1 + # via flake8 +pygments==2.9.0 + # via sphinx +pyopenssl==20.0.1 + # via + # aprsd + # opencage +pyparsing==2.4.7 + # via packaging +pytest-cov==2.12.1 + # via -r dev-requirements.in +pytest==6.2.4 + # via + # -r dev-requirements.in + # pytest-cov +python-dateutil==2.8.1 + # via + # aprsd + # pandas +pytz==2020.5 + # via + # aprsd + # babel + # pandas +pyyaml==5.4.1 + # via + # aprsd + # pre-commit +regex==2021.4.4 + # via black +requests==2.25.1 + # via + # aprsd + # opencage + # sphinx + # yfinance +shellingham==1.3.2 + # via + # aprsd + # click-completion +six==1.15.0 + # via + # aprsd + # click-completion + # cryptography + # imapclient + # opencage + # pyopenssl + # python-dateutil + # tox + # virtualenv +snowballstemmer==2.1.0 + # via sphinx +sphinx==4.0.2 + # via -r dev-requirements.in +sphinxcontrib-applehelp==1.0.2 + # via sphinx +sphinxcontrib-devhelp==1.0.2 + # via sphinx +sphinxcontrib-htmlhelp==2.0.0 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==1.0.3 + # via sphinx +sphinxcontrib-serializinghtml==1.1.5 + # via sphinx +thesmuggler==1.0.1 + # via aprsd +toml==0.10.2 + # via + # black + # mypy + # pep517 + # pre-commit + # pytest + # pytest-cov + # tox +tox==3.23.1 + # via -r dev-requirements.in +typing-extensions==3.10.0.0 + # via mypy +urllib3==1.26.3 + # via + # aprsd + # requests +virtualenv==20.4.7 + # via + # pre-commit + # tox +werkzeug==1.0.1 + # via + # aprsd + # flask +yfinance==0.1.55 + # via aprsd + +# The following packages are considered to be unsafe in a requirements file: +# pip +# setuptools diff --git a/requirements.in b/requirements.in index f9e7fff..f61c79c 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,5 @@ pbr slack_sdk>=3.0 slackeventsapi>=2.1.0 -aprsd +slackblocks +aprsd>=1.5.2 diff --git a/requirements.txt b/requirements.txt index 0a7accd..a7d5f07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,11 +2,160 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile +# pip-compile requirements.in # -aprsd>=1.5.0 # via -r requirements.in -pbr # via -r requirements.in, aprsd -requests # via aprsd -six # via aprsd, click-completion, imapclient -slack-sdk # via -r requirements.in -slackeventsapi # via -r requirements.in +aprsd==1.6.1 + # via -r requirements.in +aprslib==0.6.47 + # via aprsd +backoff==1.10.0 + # via + # aprsd + # opencage +certifi==2020.12.5 + # via + # aprsd + # requests +cffi==1.14.4 + # via + # aprsd + # cryptography +chardet==4.0.0 + # via + # aprsd + # requests +click-completion==0.5.2 + # via aprsd +click==7.1.2 + # via + # aprsd + # click-completion + # flask +cryptography==3.3.2 + # via + # aprsd + # pyopenssl +dnspython==2.1.0 + # via + # aprsd + # py3-validate-email +filelock==3.0.12 + # via + # aprsd + # py3-validate-email +flask-classful==0.14.2 + # via aprsd +flask-httpauth==4.2.0 + # via aprsd +flask==1.1.2 + # via + # aprsd + # flask-classful + # flask-httpauth + # slackeventsapi +idna==2.10 + # via + # aprsd + # py3-validate-email + # requests +imapclient==2.2.0 + # via aprsd +itsdangerous==1.1.0 + # via + # aprsd + # flask + # slackeventsapi +jinja2==2.11.3 + # via + # aprsd + # click-completion + # flask + # slackeventsapi +lxml==4.6.3 + # via + # aprsd + # yfinance +markupsafe==1.1.1 + # via + # aprsd + # jinja2 + # slackeventsapi +multitasking==0.0.9 + # via + # aprsd + # yfinance +numpy==1.20.1 + # via + # aprsd + # pandas + # yfinance +opencage==1.2.2 + # via aprsd +pandas==1.2.2 + # via + # aprsd + # yfinance +pbr==5.5.1 + # via + # -r requirements.in + # aprsd +pluggy==0.13.1 + # via aprsd +py3-validate-email==0.2.12 + # via aprsd +pycparser==2.20 + # via + # aprsd + # cffi +pyee==7.0.4 + # via slackeventsapi +pyopenssl==20.0.1 + # via + # aprsd + # opencage +python-dateutil==2.8.1 + # via + # aprsd + # pandas +pytz==2020.5 + # via + # aprsd + # pandas +pyyaml==5.4.1 + # via aprsd +requests==2.25.1 + # via + # aprsd + # opencage + # yfinance +shellingham==1.3.2 + # via + # aprsd + # click-completion +six==1.15.0 + # via + # aprsd + # click-completion + # cryptography + # imapclient + # opencage + # pyopenssl + # python-dateutil +slack-sdk==3.6.0 + # via -r requirements.in +slackblocks==0.2.3 + # via -r requirements.in +slackeventsapi==2.2.1 + # via -r requirements.in +thesmuggler==1.0.1 + # via aprsd +urllib3==1.26.3 + # via + # aprsd + # requests +werkzeug==1.0.1 + # via + # aprsd + # flask +yfinance==0.1.55 + # via aprsd