From 764730c123e020235615b4be8ab1d26b43fc96be Mon Sep 17 00:00:00 2001 From: Hemna Date: Wed, 15 Dec 2021 10:48:16 -0500 Subject: [PATCH] Updated list-plugins This patch updates the README.rst with the new format for `aprsd list-plugins`. --- README.rst | 50 ++++++---- aprsd/cmds/list_plugins.py | 182 +++++++++++++++++++------------------ 2 files changed, 128 insertions(+), 104 deletions(-) diff --git a/README.rst b/README.rst index 25d6201..dcdebac 100644 --- a/README.rst +++ b/README.rst @@ -51,25 +51,41 @@ Current List of built-in plugins: :: - โ””โ”€> aprsd list-plugins - Plugin Name Plugin Path Type Info - ---------------------- ----------------------------------------- ------------ ---------------------------------------------------------- - EmailPlugin aprsd.plugins.email.EmailPlugin RegexCommand Send and Receive email - 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? - NotifySeenPlugin aprsd.plugins.notify.NotifySeenPlugin WatchList Notify me when a CALLSIGN is recently seen on APRS-IS - PingPlugin aprsd.plugins.ping.PingPlugin RegexCommand reply with a Pong! - QueryPlugin aprsd.plugins.query.QueryPlugin RegexCommand APRSD Owner command to query messages in the MsgTrack - TimeOWMPlugin aprsd.plugins.time.TimeOWMPlugin RegexCommand Current time of GPS beacon's timezone. Uses OpenWeatherMap - TimeOpenCageDataPlugin aprsd.plugins.time.TimeOpenCageDataPlugin RegexCommand Current time of GPS beacon timezone. Uses OpenCage - TimePlugin aprsd.plugins.time.TimePlugin RegexCommand What is the current local time. - VersionPlugin aprsd.plugins.version.VersionPlugin RegexCommand What is the APRSD Version - AVWXWeatherPlugin aprsd.plugins.weather.AVWXWeatherPlugin RegexCommand AVWX weather of GPS Beacon location - OWMWeatherPlugin aprsd.plugins.weather.OWMWeatherPlugin RegexCommand OpenWeatherMap weather of GPS Beacon location - USMetarPlugin aprsd.plugins.weather.USMetarPlugin RegexCommand USA only METAR of GPS Beacon location - USWeatherPlugin aprsd.plugins.weather.USWeatherPlugin RegexCommand Provide USA only weather of GPS Beacon location + โ””โ”€> aprsd list-plugins + ๐Ÿ APRSD Built-in Plugins ๐Ÿ + โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ + โ”ƒ Plugin Name โ”ƒ Info โ”ƒ Type โ”ƒ Plugin Path โ”ƒ + โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ + โ”‚ AVWXWeatherPlugin โ”‚ AVWX weather of GPS Beacon location โ”‚ RegexCommand โ”‚ aprsd.plugins.weather.AVWXWeatherPlugin โ”‚ + โ”‚ EmailPlugin โ”‚ Send and Receive email โ”‚ RegexCommand โ”‚ aprsd.plugins.email.EmailPlugin โ”‚ + โ”‚ FortunePlugin โ”‚ Give me a fortune โ”‚ RegexCommand โ”‚ aprsd.plugins.fortune.FortunePlugin โ”‚ + โ”‚ LocationPlugin โ”‚ Where in the world is a CALLSIGN's last GPS beacon? โ”‚ RegexCommand โ”‚ aprsd.plugins.location.LocationPlugin โ”‚ + โ”‚ NotifySeenPlugin โ”‚ Notify me when a CALLSIGN is recently seen on APRS-IS โ”‚ WatchList โ”‚ aprsd.plugins.notify.NotifySeenPlugin โ”‚ + โ”‚ OWMWeatherPlugin โ”‚ OpenWeatherMap weather of GPS Beacon location โ”‚ RegexCommand โ”‚ aprsd.plugins.weather.OWMWeatherPlugin โ”‚ + โ”‚ PingPlugin โ”‚ reply with a Pong! โ”‚ RegexCommand โ”‚ aprsd.plugins.ping.PingPlugin โ”‚ + โ”‚ QueryPlugin โ”‚ APRSD Owner command to query messages in the MsgTrack โ”‚ RegexCommand โ”‚ aprsd.plugins.query.QueryPlugin โ”‚ + โ”‚ TimeOWMPlugin โ”‚ Current time of GPS beacon's timezone. Uses OpenWeatherMap โ”‚ RegexCommand โ”‚ aprsd.plugins.time.TimeOWMPlugin โ”‚ + โ”‚ TimeOpenCageDataPlugin โ”‚ Current time of GPS beacon timezone. Uses OpenCage โ”‚ RegexCommand โ”‚ aprsd.plugins.time.TimeOpenCageDataPlugin โ”‚ + โ”‚ TimePlugin โ”‚ What is the current local time. โ”‚ RegexCommand โ”‚ aprsd.plugins.time.TimePlugin โ”‚ + โ”‚ 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 โ”ƒ 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: ============= diff --git a/aprsd/cmds/list_plugins.py b/aprsd/cmds/list_plugins.py index e2508e7..943680a 100644 --- a/aprsd/cmds/list_plugins.py +++ b/aprsd/cmds/list_plugins.py @@ -103,88 +103,7 @@ def get_installed_plugins(): return ip -def show_pypi_plugins(installed_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"), - ("", "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.""" - +def show_built_in_plugins(console): modules = [email, fortune, location, notify, ping, query, time, version, weather] plugins = [] @@ -222,13 +141,102 @@ def list_plugins(ctx): for entry in plugins: table.add_row(entry["name"], entry["short_desc"], entry["type"], entry["path"]) - console = Console() console.print(table) - # now find any from pypi? - installed_plugins = get_installed_plugins() - with console.status("Fetching pypi.org plugins"): + +def show_pypi_plugins(installed_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"), + ("'", "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) - with console.status("Looking for installed aprsd plugins"): + status.update("Looking for installed APRSD plugins") show_installed_plugins(installed_plugins, console)