1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-05-30 05:02:28 -04:00

Updated list-plugins

This patch updates the README.rst with the new format for
`aprsd list-plugins`.
This commit is contained in:
Hemna 2021-12-15 10:48:16 -05:00
parent 610e40aecd
commit 764730c123
2 changed files with 128 additions and 104 deletions

View File

@ -51,25 +51,41 @@ Current List of built-in plugins:
:: ::
└─> aprsd list-plugins └─> aprsd list-plugins
Plugin Name Plugin Path Type Info 🐍 APRSD Built-in Plugins 🐍
---------------------- ----------------------------------------- ------------ ---------------------------------------------------------- ┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
EmailPlugin aprsd.plugins.email.EmailPlugin RegexCommand Send and Receive email ┃ Plugin Name ┃ Info ┃ Type ┃ Plugin Path ┃
FortunePlugin aprsd.plugins.fortune.FortunePlugin RegexCommand Give me a fortune ┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
LocationPlugin aprsd.plugins.location.LocationPlugin RegexCommand Where in the world is a CALLSIGN's last GPS beacon? │ AVWXWeatherPlugin │ AVWX weather of GPS Beacon location │ RegexCommand │ aprsd.plugins.weather.AVWXWeatherPlugin │
NotifySeenPlugin aprsd.plugins.notify.NotifySeenPlugin WatchList Notify me when a CALLSIGN is recently seen on APRS-IS │ EmailPlugin │ Send and Receive email │ RegexCommand │ aprsd.plugins.email.EmailPlugin │
PingPlugin aprsd.plugins.ping.PingPlugin RegexCommand reply with a Pong! │ FortunePlugin │ Give me a fortune │ RegexCommand │ aprsd.plugins.fortune.FortunePlugin │
QueryPlugin aprsd.plugins.query.QueryPlugin RegexCommand APRSD Owner command to query messages in the MsgTrack │ LocationPlugin │ Where in the world is a CALLSIGN's last GPS beacon? │ RegexCommand │ aprsd.plugins.location.LocationPlugin │
TimeOWMPlugin aprsd.plugins.time.TimeOWMPlugin RegexCommand Current time of GPS beacon's timezone. Uses OpenWeatherMap │ NotifySeenPlugin │ Notify me when a CALLSIGN is recently seen on APRS-IS │ WatchList │ aprsd.plugins.notify.NotifySeenPlugin │
TimeOpenCageDataPlugin aprsd.plugins.time.TimeOpenCageDataPlugin RegexCommand Current time of GPS beacon timezone. Uses OpenCage │ OWMWeatherPlugin │ OpenWeatherMap weather of GPS Beacon location │ RegexCommand │ aprsd.plugins.weather.OWMWeatherPlugin │
TimePlugin aprsd.plugins.time.TimePlugin RegexCommand What is the current local time. │ PingPlugin │ reply with a Pong! │ RegexCommand │ aprsd.plugins.ping.PingPlugin │
VersionPlugin aprsd.plugins.version.VersionPlugin RegexCommand What is the APRSD Version │ QueryPlugin │ APRSD Owner command to query messages in the MsgTrack │ RegexCommand │ aprsd.plugins.query.QueryPlugin │
AVWXWeatherPlugin aprsd.plugins.weather.AVWXWeatherPlugin RegexCommand AVWX weather of GPS Beacon location │ TimeOWMPlugin │ Current time of GPS beacon's timezone. Uses OpenWeatherMap │ RegexCommand │ aprsd.plugins.time.TimeOWMPlugin │
OWMWeatherPlugin aprsd.plugins.weather.OWMWeatherPlugin RegexCommand OpenWeatherMap weather of GPS Beacon location │ TimeOpenCageDataPlugin │ Current time of GPS beacon timezone. Uses OpenCage │ RegexCommand │ aprsd.plugins.time.TimeOpenCageDataPlugin │
USMetarPlugin aprsd.plugins.weather.USMetarPlugin RegexCommand USA only METAR of GPS Beacon location │ TimePlugin │ What is the current local time. │ RegexCommand │ aprsd.plugins.time.TimePlugin │
USWeatherPlugin aprsd.plugins.weather.USWeatherPlugin RegexCommand Provide USA only weather of GPS Beacon location │ USMetarPlugin │ USA only METAR of GPS Beacon location │ RegexCommand │ aprsd.plugins.weather.USMetarPlugin │
│ USWeatherPlugin │ Provide USA only weather of GPS Beacon location │ RegexCommand │ aprsd.plugins.weather.USWeatherPlugin │
│ VersionPlugin │ What is the APRSD Version │ RegexCommand │ aprsd.plugins.version.VersionPlugin │
└────────────────────────┴────────────────────────────────────────────────────────────┴──────────────┴───────────────────────────────────────────┘
Pypi.org APRSD Installable Plugin Packages
Install any of the following plugins with pip install <Plugin Package Name>
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Plugin Package Name ┃ Description ┃ Version ┃ Released ┃ Installed? ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ 📂 aprsd-stock-plugin │ Ham Radio APRSD Plugin for fetching stock quotes │ 0.1.2 │ Nov 9, 2021 │ No │
│ 📂 aprsd-weewx-plugin │ HAM Radio APRSD that reports weather from a weewx weather station. │ 0.1.4 │ Dec 7, 2021 │ No │
│ 📂 aprsd-telegram-plugin │ Ham Radio APRS APRSD plugin for Telegram IM service │ 0.1.2 │ Nov 9, 2021 │ No │
│ 📂 aprsd-twitter-plugin │ Python APRSD plugin to send tweets │ 0.3.0 │ Dec 7, 2021 │ No │
│ 📂 aprsd-slack-plugin │ Amateur radio APRS daemon which listens for messages and responds │ 1.0.4 │ Jan 15, 2021 │ No │
└──────────────────────────┴────────────────────────────────────────────────────────────────────┴─────────┴──────────────┴────────────┘
installation: installation:
============= =============

View File

@ -103,88 +103,7 @@ def get_installed_plugins():
return ip return ip
def show_pypi_plugins(installed_plugins, console): def show_built_in_plugins(console):
query = "aprsd"
api_url = "https://pypi.org/search/"
snippets = []
s = requests.Session()
for page in range(1, 3):
params = {"q": query, "page": page}
r = s.get(api_url, params=params)
soup = BeautifulSoup(r.text, "html.parser")
snippets += soup.select('a[class*="snippet"]')
if not hasattr(s, "start_url"):
s.start_url = r.url.rsplit("&page", maxsplit=1).pop(0)
title = Text.assemble(
("Pypi.org APRSD Installable Plugin Packages\n\n", "bold magenta"),
("Install any of the following plugins with ", "bold yellow"),
("pip install ", "bold white"),
("<Plugin Package Name>", "cyan"),
)
table = Table(title=title)
table.add_column("Plugin Package Name", style="cyan", no_wrap=True)
table.add_column("Description", style="yellow")
table.add_column("Version", style="yellow")
table.add_column("Released", style="bold green")
table.add_column("Installed?", style="red")
table.add_column("Version Installed", style="yellow")
for snippet in snippets:
link = urljoin(api_url, snippet.get("href"))
package = re.sub(r"\s+", " ", snippet.select_one('span[class*="name"]').text.strip())
version = re.sub(r"\s+", " ", snippet.select_one('span[class*="version"]').text.strip())
released = re.sub(r"\s+", " ", snippet.select_one('span[class*="released"]').text.strip())
description = re.sub(r"\s+", " ", snippet.select_one('p[class*="description"]').text.strip())
emoji = ":open_file_folder:"
if "aprsd-" not in package or "-plugin" not in package:
continue
under = package.replace("-", "_")
if under in installed_plugins:
installed = "Yes"
try:
version_installed = installed_plugins[under].__version__
except Exception:
version_installed = "Unknown"
else:
installed = "No"
version_installed = "Unknown"
table.add_row(
f"[link={link}]{emoji}[/link] {package}",
description, version, released, installed, version_installed,
)
console.print("\n")
console.print(table)
return
def show_installed_plugins(installed_plugins, console):
if not installed_plugins:
return
table = Table(
title="[not italic]:snake:[/] [bold][magenta]APRSD Installed 3rd party Plugins [not italic]:snake:[/]",
)
table.add_column("Package Name", style="white", no_wrap=True)
table.add_column("Plugin Name", style="cyan", no_wrap=True)
table.add_column("Type", style="bold green")
table.add_column("Plugin Path", style="bold blue")
for name in installed_plugins:
for plugin in installed_plugins[name]:
table.add_row(name.replace("_", "-"), plugin["name"], plugin_type(plugin["obj"]), plugin["path"])
console.print("\n")
console.print(table)
@cli.command()
@cli_helper.add_options(cli_helper.common_options)
@click.pass_context
@cli_helper.process_standard_options_no_config
def list_plugins(ctx):
"""List the built in plugins available to APRSD."""
modules = [email, fortune, location, notify, ping, query, time, version, weather] modules = [email, fortune, location, notify, ping, query, time, version, weather]
plugins = [] plugins = []
@ -222,13 +141,102 @@ def list_plugins(ctx):
for entry in plugins: for entry in plugins:
table.add_row(entry["name"], entry["short_desc"], entry["type"], entry["path"]) table.add_row(entry["name"], entry["short_desc"], entry["type"], entry["path"])
console = Console()
console.print(table) console.print(table)
# now find any from pypi?
installed_plugins = get_installed_plugins() def show_pypi_plugins(installed_plugins, console):
with console.status("Fetching pypi.org plugins"): query = "aprsd"
api_url = "https://pypi.org/search/"
snippets = []
s = requests.Session()
for page in range(1, 3):
params = {"q": query, "page": page}
r = s.get(api_url, params=params)
soup = BeautifulSoup(r.text, "html.parser")
snippets += soup.select('a[class*="snippet"]')
if not hasattr(s, "start_url"):
s.start_url = r.url.rsplit("&page", maxsplit=1).pop(0)
title = Text.assemble(
("Pypi.org APRSD Installable Plugin Packages\n\n", "bold magenta"),
("Install any of the following plugins with ", "bold yellow"),
("'pip install ", "bold white"),
("<Plugin Package Name>'", "cyan"),
)
table = Table(title=title)
table.add_column("Plugin Package Name", style="cyan", no_wrap=True)
table.add_column("Description", style="yellow")
table.add_column("Version", style="yellow", justify="center")
table.add_column("Released", style="bold green", justify="center")
table.add_column("Installed?", style="red", justify="center")
for snippet in snippets:
link = urljoin(api_url, snippet.get("href"))
package = re.sub(r"\s+", " ", snippet.select_one('span[class*="name"]').text.strip())
version = re.sub(r"\s+", " ", snippet.select_one('span[class*="version"]').text.strip())
released = re.sub(r"\s+", " ", snippet.select_one('span[class*="released"]').text.strip())
description = re.sub(r"\s+", " ", snippet.select_one('p[class*="description"]').text.strip())
emoji = ":open_file_folder:"
if "aprsd-" not in package or "-plugin" not in package:
continue
under = package.replace("-", "_")
if under in installed_plugins:
installed = "Yes"
else:
installed = "No"
table.add_row(
f"[link={link}]{emoji}[/link] {package}",
description, version, released, installed,
)
console.print("\n")
console.print(table)
return
def show_installed_plugins(installed_plugins, console):
if not installed_plugins:
return
table = Table(
title="[not italic]:snake:[/] [bold][magenta]APRSD Installed 3rd party Plugins [not italic]:snake:[/]",
)
table.add_column("Package Name", style=" bold white", no_wrap=True)
table.add_column("Plugin Name", style="cyan", no_wrap=True)
table.add_column("Version", style="yellow", justify="center")
table.add_column("Type", style="bold green")
table.add_column("Plugin Path", style="bold blue")
for name in installed_plugins:
for plugin in installed_plugins[name]:
table.add_row(
name.replace("_", "-"),
plugin["name"],
plugin["version"],
plugin_type(plugin["obj"]),
plugin["path"],
)
console.print("\n")
console.print(table)
@cli.command()
@cli_helper.add_options(cli_helper.common_options)
@click.pass_context
@cli_helper.process_standard_options_no_config
def list_plugins(ctx):
"""List the built in plugins available to APRSD."""
console = Console()
with console.status("Show Built-in Plugins") as status:
show_built_in_plugins(console)
status.update("Fetching pypi.org plugins")
installed_plugins = get_installed_plugins()
show_pypi_plugins(installed_plugins, console) show_pypi_plugins(installed_plugins, console)
with console.status("Looking for installed aprsd plugins"): status.update("Looking for installed APRSD plugins")
show_installed_plugins(installed_plugins, console) show_installed_plugins(installed_plugins, console)