Removed TimeOpenCageDataPlugin

This patch removes the TimeOpenCageDataPlugin as it's been superceded
by the aprsd-timeopencage-plugin
This commit is contained in:
Hemna 2022-11-23 12:59:02 -05:00
parent fc1ca52593
commit 528bdb99e7
4 changed files with 2 additions and 76 deletions

View File

@ -2,9 +2,6 @@ import logging
import re
import time
from opencage.geocoder import OpenCageGeocode
import pytz
from aprsd import plugin, plugin_utils
from aprsd.utils import fuzzy, trace
@ -50,68 +47,6 @@ class TimePlugin(plugin.APRSDRegexCommandPluginBase):
return self.build_date_str(localzone)
class TimeOpenCageDataPlugin(TimePlugin, plugin.APRSFIKEYMixin):
"""geocage based timezone fetching."""
command_regex = "^[tT]"
command_name = "time"
short_description = "Current time of GPS beacon timezone. Uses OpenCage"
def setup(self):
self.ensure_aprs_fi_key()
@trace.trace
def process(self, packet):
fromcall = packet.get("from")
message = packet.get("message_text", None)
# ack = packet.get("msgNo", "0")
api_key = self.config["services"]["aprs.fi"]["apiKey"]
# optional second argument is a callsign to search
a = re.search(r"^.*\s+(.*)", message)
if a is not None:
searchcall = a.group(1)
searchcall = searchcall.upper()
else:
# if no second argument, search for calling station
searchcall = fromcall
try:
aprs_data = plugin_utils.get_aprs_fi(api_key, searchcall)
except Exception as ex:
LOG.error(f"Failed to fetch aprs.fi data {ex}")
return "Failed to fetch location"
# LOG.debug("LocationPlugin: aprs_data = {}".format(aprs_data))
if not len(aprs_data["entries"]):
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"]
try:
self.config.exists("opencagedata.apiKey")
except Exception as ex:
LOG.error(f"Failed to find config opencage:apiKey {ex}")
return "No opencage apiKey found"
try:
opencage_key = self.config["opencagedata"]["apiKey"]
geocoder = OpenCageGeocode(opencage_key)
results = geocoder.reverse_geocode(lat, lon)
except Exception as ex:
LOG.error(f"Couldn't fetch opencagedata api '{ex}'")
# Default to UTC instead
localzone = pytz.timezone("UTC")
else:
tzone = results[0]["annotations"]["timezone"]["name"]
localzone = pytz.timezone(tzone)
return self.build_date_str(localzone)
class TimeOWMPlugin(TimePlugin, plugin.APRSFIKEYMixin):
"""OpenWeatherMap based timezone fetching."""

View File

@ -36,7 +36,7 @@ iniconfig==1.1.1 # via pytest
isort==5.10.1 # via -r dev-requirements.in, gray
jaraco.classes==3.2.3 # via keyring
jinja2==3.1.2 # via sphinx
jsonschema==4.17.0 # via fixit
jsonschema==4.17.1 # via fixit
keyring==23.11.0 # via twine
libcst==0.4.9 # via fixit
markupsafe==2.1.1 # via jinja2

View File

@ -6,14 +6,12 @@ werkzeug==2.1.2
flask-classful
flask-httpauth
imapclient
opencage
pluggy
pbr
pyyaml
# Allowing a newer version can lead to a conflict with
# requests.
py3-validate-email
pytz
requests
six
thesmuggler

View File

@ -7,17 +7,14 @@
aprslib==0.7.2 # via -r requirements.in
attrs==22.1.0 # via -r requirements.in, ax253, kiss3
ax253==0.1.5.post1 # via kiss3
backoff==2.2.1 # via opencage
beautifulsoup4==4.11.1 # via -r requirements.in
bidict==0.22.0 # via python-socketio
bitarray==2.6.0 # via ax253, kiss3
certifi==2022.9.24 # via requests
cffi==1.15.1 # via cryptography
charset-normalizer==2.1.1 # via requests
click-completion==0.5.2 # via -r requirements.in
click==8.1.3 # via -r requirements.in, click-completion, flask
commonmark==0.9.1 # via rich
cryptography==38.0.3 # via pyopenssl
dnspython==2.2.1 # via eventlet, py3-validate-email
eventlet==0.33.2 # via -r requirements.in
filelock==3.8.0 # via py3-validate-email
@ -33,20 +30,16 @@ 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.1 # via jinja2
opencage==2.1.0 # via -r requirements.in
pbr==5.11.0 # via -r requirements.in
pluggy==1.0.0 # via -r requirements.in
py3-validate-email==1.0.5.post1 # via -r requirements.in
pycparser==2.21 # via cffi
pygments==2.13.0 # via rich
pyopenssl==22.1.0 # via opencage
pyserial-asyncio==0.6 # via kiss3
pyserial==3.5 # via pyserial-asyncio
python-engineio==4.3.4 # via python-socketio
python-socketio==5.7.2 # via flask-socketio
pytz==2022.6 # via -r requirements.in
pyyaml==6.0 # via -r requirements.in
requests==2.28.1 # via -r requirements.in, opencage, update-checker
requests==2.28.1 # via -r requirements.in, update-checker
rich==12.6.0 # via -r requirements.in
shellingham==1.5.0 # via click-completion
six==1.16.0 # via -r requirements.in, click-completion, eventlet, imapclient