1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-12-22 09:31:42 -05:00

Update location plugin and reworked requirements

Added geopy as a dependency for the location plugin.
The us weather service API is now broken upstream.

Reworked the requirements.txt and dev-requirements.txt files
This commit is contained in:
Hemna 2023-06-15 16:08:28 -04:00
parent c99d5b859e
commit 26c1e7afbb
4 changed files with 96 additions and 84 deletions

View File

@ -2,6 +2,7 @@ import logging
import re
import time
from geopy.geocoders import Nominatim
from oslo_config import cfg
from aprsd import packets, plugin, plugin_utils
@ -50,8 +51,28 @@ class LocationPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin):
LOG.error("Didn't get any entries from aprs.fi")
return "Failed to fetch aprs.fi location"
lat = aprs_data["entries"][0]["lat"]
lon = aprs_data["entries"][0]["lng"]
lat = float(aprs_data["entries"][0]["lat"])
lon = float(aprs_data["entries"][0]["lng"])
# Get some information about their location
try:
tic = time.perf_counter()
geolocator = Nominatim(user_agent="APRSD")
coordinates = f"{lat:0.6f}, {lon:0.6f}"
location = geolocator.reverse(coordinates)
address = location.raw.get("address")
toc = time.perf_counter()
if address:
LOG.info(f"Geopy address {address} took {toc - tic:0.4f}")
if address.get("country_code") == "us":
area_info = f"{address.get('county')}, {address.get('state')}"
else:
# what to do for address for non US?
area_info = f"{address.get('country')}"
except Exception as ex:
LOG.error(f"Failed to fetch Geopy address {ex}")
area_info = ""
try: # altitude not always provided
alt = float(aprs_data["entries"][0]["altitude"])
except Exception:
@ -64,22 +85,13 @@ class LocationPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin):
delta_seconds = time.time() - int(aprs_lasttime_seconds)
delta_hours = delta_seconds / 60 / 60
try:
wx_data = plugin_utils.get_weather_gov_for_gps(lat, lon)
except Exception as ex:
LOG.error(f"Couldn't fetch forecast.weather.gov '{ex}'")
wx_data = {"location": {"areaDescription": "Unknown Location"}}
if "location" not in wx_data:
LOG.error(f"Couldn't fetch forecast.weather.gov '{wx_data}'")
wx_data = {"location": {"areaDescription": "Unknown Location"}}
reply = "{}: {} {}' {},{} {}h ago".format(
searchcall,
wx_data["location"]["areaDescription"],
area_info,
str(altfeet),
str(lat),
str(lon),
f"{lat:0.2f}",
f"{lon:0.2f}",
str("%.1f" % round(delta_hours, 1)),
).rstrip()

View File

@ -1,88 +1,85 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --annotation-style=line --resolver=backtracking dev-requirements.in
#
add-trailing-comma==2.4.0 # via gray
add-trailing-comma==2.5.1 # via gray
alabaster==0.7.13 # via sphinx
attrs==22.2.0 # via jsonschema, pytest
attrs==23.1.0 # via jsonschema
autoflake==1.5.3 # via gray
babel==2.11.0 # via sphinx
black==22.12.0 # via gray
babel==2.12.1 # via sphinx
black==23.3.0 # via gray
build==0.10.0 # via pip-tools
cachetools==5.2.1 # via tox
certifi==2022.12.7 # via requests
cachetools==5.3.1 # via tox
certifi==2023.5.7 # via requests
cfgv==3.3.1 # via pre-commit
chardet==5.1.0 # via tox
charset-normalizer==3.0.1 # via requests
charset-normalizer==3.1.0 # via requests
click==8.1.3 # via black, pip-tools
colorama==0.4.6 # via tox
commonmark==0.9.1 # via rich
configargparse==1.5.3 # via gray
coverage[toml]==7.0.5 # via pytest-cov
coverage[toml]==7.2.7 # via pytest-cov
distlib==0.3.6 # via virtualenv
docutils==0.19 # via sphinx
exceptiongroup==1.1.0 # via pytest
filelock==3.9.0 # via tox, virtualenv
docutils==0.20.1 # via sphinx
exceptiongroup==1.1.1 # via pytest
filelock==3.12.2 # via tox, virtualenv
fixit==0.1.4 # via gray
flake8==6.0.0 # via -r dev-requirements.in, fixit, pep8-naming
gray==0.13.0 # via -r dev-requirements.in
identify==2.5.13 # via pre-commit
identify==2.5.24 # via pre-commit
idna==3.4 # via requests
imagesize==1.4.1 # via sphinx
importlib-metadata==6.0.0 # via sphinx
importlib-resources==5.10.2 # via fixit
importlib-resources==5.12.0 # via fixit
iniconfig==2.0.0 # via pytest
isort==5.11.4 # via -r dev-requirements.in, gray
isort==5.12.0 # via -r dev-requirements.in, gray
jinja2==3.1.2 # via sphinx
jsonschema==4.17.3 # via fixit
libcst==0.4.9 # via fixit
markupsafe==2.1.2 # via jinja2
libcst==1.0.1 # via fixit
markupsafe==2.1.3 # via jinja2
mccabe==0.7.0 # via flake8
mypy==0.991 # via -r dev-requirements.in
mypy-extensions==0.4.3 # via black, mypy, typing-inspect
nodeenv==1.7.0 # via pre-commit
packaging==23.0 # via build, pyproject-api, pytest, sphinx, tox
pathspec==0.10.3 # via black
mypy==1.3.0 # via -r dev-requirements.in
mypy-extensions==1.0.0 # via black, mypy, typing-inspect
nodeenv==1.8.0 # via pre-commit
packaging==23.1 # via black, build, pyproject-api, pytest, sphinx, tox
pathspec==0.11.1 # via black
pep8-naming==0.13.3 # via -r dev-requirements.in
pip-tools==6.12.1 # via -r dev-requirements.in
platformdirs==2.6.2 # via black, tox, virtualenv
pip-tools==6.13.0 # via -r dev-requirements.in
platformdirs==3.5.3 # via black, tox, virtualenv
pluggy==1.0.0 # via pytest, tox
pre-commit==2.21.0 # via -r dev-requirements.in
pre-commit==3.3.3 # via -r dev-requirements.in
pycodestyle==2.10.0 # via flake8
pyflakes==3.0.1 # via autoflake, flake8
pygments==2.14.0 # via rich, sphinx
pyproject-api==1.5.0 # via tox
pygments==2.15.1 # via rich, sphinx
pyproject-api==1.5.2 # via tox
pyproject-hooks==1.0.0 # via build
pyrsistent==0.19.3 # via jsonschema
pytest==7.2.1 # via -r dev-requirements.in, pytest-cov
pytest-cov==4.0.0 # via -r dev-requirements.in
pytz==2022.7.1 # via babel
pyupgrade==3.3.1 # via gray
pytest==7.3.2 # via -r dev-requirements.in, pytest-cov
pytest-cov==4.1.0 # via -r dev-requirements.in
pyupgrade==3.6.0 # via gray
pyyaml==6.0 # via fixit, libcst, pre-commit
requests==2.28.2 # via sphinx
requests==2.31.0 # via sphinx
rich==12.6.0 # via gray
snowballstemmer==2.2.0 # via sphinx
sphinx==6.1.3 # via -r dev-requirements.in
sphinxcontrib-applehelp==1.0.3 # via sphinx
sphinx==7.0.1 # via -r dev-requirements.in
sphinxcontrib-applehelp==1.0.4 # via sphinx
sphinxcontrib-devhelp==1.0.2 # via sphinx
sphinxcontrib-htmlhelp==2.0.0 # via sphinx
sphinxcontrib-htmlhelp==2.0.1 # via sphinx
sphinxcontrib-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.5 # via sphinx
tokenize-rt==5.0.0 # via add-trailing-comma, pyupgrade
tokenize-rt==5.1.0 # via add-trailing-comma, pyupgrade
toml==0.10.2 # via autoflake
tomli==2.0.1 # via black, build, coverage, mypy, pyproject-api, pyproject-hooks, pytest, tox
tox==4.3.5 # via -r dev-requirements.in
typing-extensions==4.4.0 # via black, libcst, mypy, typing-inspect
typing-inspect==0.8.0 # via libcst
tox==4.6.0 # via -r dev-requirements.in
typing-extensions==4.6.3 # via libcst, mypy, typing-inspect
typing-inspect==0.9.0 # via libcst
unify==0.5 # via gray
untokenize==0.1.1 # via unify
urllib3==1.26.14 # via requests
virtualenv==20.17.1 # via pre-commit, tox
wheel==0.38.4 # via pip-tools
zipp==3.11.0 # via importlib-metadata, importlib-resources
urllib3==2.0.3 # via requests
virtualenv==20.23.0 # via pre-commit, tox
wheel==0.40.0 # via pip-tools
# The following packages are considered to be unsafe in a requirements file:
# pip

View File

@ -37,3 +37,4 @@ rpyc
cryptography==38.0.1
shellingham==1.5.0.post1
ratelimiter
geopy

View File

@ -1,18 +1,18 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --annotation-style=line --resolver=backtracking requirements.in
#
aprslib==0.7.2 # via -r requirements.in
attrs==22.2.0 # via -r requirements.in, ax253, kiss3
attrs==23.1.0 # via -r requirements.in, ax253, kiss3
ax253==0.1.5.post1 # via kiss3
beautifulsoup4==4.11.1 # via -r requirements.in
beautifulsoup4==4.12.2 # via -r requirements.in
bidict==0.22.1 # via python-socketio
bitarray==2.6.2 # via ax253, kiss3
certifi==2022.12.7 # via requests
bitarray==2.7.5 # via ax253, kiss3
certifi==2023.5.7 # via requests
cffi==1.15.1 # via cryptography
charset-normalizer==3.0.1 # via requests
charset-normalizer==3.1.0 # via requests
click==8.1.3 # via -r requirements.in, click-completion, flask
click-completion==0.5.2 # via -r requirements.in
commonmark==0.9.1 # via rich
@ -24,46 +24,48 @@ dnspython==2.3.0 # via eventlet
eventlet==0.33.3 # via -r requirements.in
flask==2.1.2 # via -r requirements.in, flask-classful, flask-httpauth, flask-socketio
flask-classful==0.14.2 # via -r requirements.in
flask-httpauth==4.7.0 # via -r requirements.in
flask-socketio==5.3.2 # via -r requirements.in
greenlet==2.0.1 # via eventlet
flask-httpauth==4.8.0 # via -r requirements.in
flask-socketio==5.3.4 # via -r requirements.in
geographiclib==2.0 # via geopy
geopy==2.3.0 # via -r requirements.in
greenlet==2.0.2 # via eventlet
idna==3.4 # via requests
imapclient==2.3.1 # via -r requirements.in
importlib-metadata==6.0.0 # via ax253, flask, kiss3
importlib-metadata==6.6.0 # via ax253, kiss3
itsdangerous==2.1.2 # via flask
jinja2==3.1.2 # via click-completion, flask
kiss3==8.0.0 # via -r requirements.in
markupsafe==2.1.2 # via jinja2
markupsafe==2.1.3 # via jinja2
netaddr==0.8.0 # via oslo-config
oslo-config==9.1.0 # via -r requirements.in
oslo-i18n==5.1.0 # via oslo-config
oslo-config==9.1.1 # via -r requirements.in
oslo-i18n==6.0.0 # via oslo-config
pbr==5.11.1 # via -r requirements.in, oslo-i18n, stevedore
pluggy==1.0.0 # via -r requirements.in
plumbum==1.8.1 # via rpyc
plumbum==1.8.2 # via rpyc
pycparser==2.21 # via cffi
pygments==2.14.0 # via rich
pyopenssl==23.0.0 # via -r requirements.in
pygments==2.15.1 # via rich
pyopenssl==23.2.0 # via -r requirements.in
pyserial==3.5 # via pyserial-asyncio
pyserial-asyncio==0.6 # via kiss3
python-engineio==4.3.4 # via python-socketio
python-socketio==5.7.2 # via flask-socketio
pytz==2022.7.1 # via -r requirements.in
python-engineio==4.4.1 # via python-socketio
python-socketio==5.8.0 # via flask-socketio
pytz==2023.3 # via -r requirements.in
pyyaml==6.0 # via -r requirements.in, oslo-config
ratelimiter==1.2.0.post0 # via -r requirements.in
requests==2.28.2 # via -r requirements.in, oslo-config, update-checker
requests==2.31.0 # via -r requirements.in, oslo-config, update-checker
rfc3986==2.0.0 # via oslo-config
rich==12.6.0 # via -r requirements.in
rpyc==5.3.0 # via -r requirements.in
rpyc==5.3.1 # via -r requirements.in
shellingham==1.5.0.post1 # via -r requirements.in, click-completion
six==1.16.0 # via -r requirements.in, click-completion, eventlet, imapclient
soupsieve==2.3.2.post1 # via beautifulsoup4
stevedore==4.1.1 # via oslo-config
soupsieve==2.4.1 # via beautifulsoup4
stevedore==5.1.0 # via oslo-config
tabulate==0.9.0 # via -r requirements.in
thesmuggler==1.0.1 # via -r requirements.in
ua-parser==0.16.1 # via user-agents
update-checker==0.18.0 # via -r requirements.in
urllib3==1.26.14 # via requests
urllib3==2.0.3 # via requests
user-agents==2.2.0 # via -r requirements.in
werkzeug==2.1.2 # via -r requirements.in, flask
wrapt==1.14.1 # via -r requirements.in, debtcollector
zipp==3.11.0 # via importlib-metadata
wrapt==1.15.0 # via -r requirements.in, debtcollector
zipp==3.15.0 # via importlib-metadata