diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..67db858 --- /dev/null +++ b/LICENSE @@ -0,0 +1,175 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. diff --git a/README.rst b/README.rst index a540d8d..3ba3bd0 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,9 @@ APRSD ===== +.. image:: https://badge.fury.io/py/aprsd.svg + :target: https://badge.fury.io/py/aprsd + .. image:: https://github.com/craigerl/aprsd/workflows/python/badge.svg :target: https://github.com/craigerl/aprsd/actions @@ -11,9 +14,17 @@ APRSD .. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336 :target: https://timothycrosley.github.io/isort/ +.. image:: https://static.pepy.tech/personalized-badge/aprsd?period=month&units=international_system&left_color=black&right_color=orange&left_text=Downloads + :target: https://pepy.tech/project/aprsd + .. contents:: :local: -Listen on amateur radio aprs-is network for messages and respond to them. +`APRSD `_ is a Ham radio `APRS `_ message command gateway built on python. + +APRSD listens on amateur radio aprs-is network for messages and respond to them. +It has a plugin architecture for extensibility. Users of APRSD can write their own +plugins that can respond to APRS-IS messages. + You must have an amateur radio callsign to use this software. APRSD gets messages for the configured HAM callsign, and sends those messages to a list of plugins for processing. There are a set of core plugins that @@ -27,14 +38,13 @@ Typical use case Ham radio operator using an APRS enabled HAM radio sends a message to check the weather. an APRS message is sent, and then picked up by APRSD. The APRS packet is decoded, and the message is sent through the list of plugins -for processing. The WeatherPlugin picks up the message, fetches the weather +for processing. For example, the WeatherPlugin picks up the message, fetches the weather for the area around the user who sent the request, and then responds with the weather conditions in that area. - APRSD Capabilities ------------------- +================== * server - The main aprsd server processor. Send/Rx APRS messages to HAM callsign * send-message - use aprsd to send a command/message to aprsd server. Used for development testing @@ -52,6 +62,7 @@ If it matches, the plugin runs. IF the regex doesn't match, the plugin is skipp * FortunePlugin - Replies with old unix fortune random fortune! * LocationPlugin - Checks location of ham operator * PingPlugin - Sends pong with timestamp +* QueryPlugin - Allows querying the list of delayed messages that were not ACK'd by radio * TimePlugin - Current time of day * WeatherPlugin - Get weather conditions for current location of HAM callsign * VersionPlugin - Reports the version information for aprsd @@ -72,6 +83,7 @@ Current messages this will respond to: -email_addr email text = send an email, say "mapme" to send a current position/map -2 = resend the last 2 emails from your imap inbox to this radio p(ing) = respond with Pong!/time + v(ersion) = Respond with current APRSD Version string anything else = respond with usage @@ -86,7 +98,7 @@ email server, and associated logins, passwords. search for "yourdomain", Installation: -------------- +============= pip install aprsd @@ -118,13 +130,14 @@ Help show Show the click-completion-command completion code -Commands --------- -sample-config +Commands +======== + +Configuration ============= This command outputs a sample config yml formatted block that you can edit -and use to pass in to aprsd with -c. +and use to pass in to aprsd with -c. By default aprsd looks in ~/.config/aprsd/aprsd.yml aprsd sample-config @@ -235,8 +248,9 @@ test messages -h, --help Show this message and exit. + Example output: ---------------- +=============== SEND EMAIL (radio to smtp server) @@ -278,60 +292,30 @@ RECEIVE EMAIL (imap server to radio) Msg number : 0 -WEATHER -======= - -:: - - Received message______________ - Raw : KM6XXX>APY400,WIDE1-1,qAO,KM6XXX-1::KM6XXX-9 :weather{27 - From : KM6XXX - Message : weather - Msg number : 27 - - Sending message_______________ 6(Tx3) - Raw : KM6XXX-9>APRS::KM6XXX :58F(58F/46F) Partly cloudy. Tonight, Heavy Rain.{6 - To : KM6XXX - Message : 58F(58F/46F) Party Cloudy. Tonight, Heavy Rain. - - Sending ack __________________ Tx(3) - Raw : KM6XXX-9>APRS::KM6XXX :ack27 - To : KM6XXX - Ack number : 27 - - Received message______________ - Raw : KM6XXX>APY400,WIDE1-1,qAO,KM6XXX-1::KM6XXX-9 :ack6 - From : KM6XXX - Message : ack6 - Msg number : 0 - - LOCATION ======== :: - Received message______________ - Raw : KM6XXX>APY400,WIDE1-1,qAO,KM6XXX-1::KM6XXX-9 :location{28 - From : KM6XXX + Received Message _______________ + Raw : KM6XXX-6>APRS,TCPIP*,qAC,T2CAEAST::KM6XXX-14:location{2 + From : KM6XXX-6 Message : location - Msg number : 28 + Msg number : 2 + Received Message _______________ Complete - Sending message_______________ 7(Tx3) - Raw : KM6XXX-9>APRS::KM6XXX :8 Miles NE Auburn CA 1673' 39.91150,-120.93450 0.1h ago{7 - To : KM6XXX - Message : 8 Miles E Auburn CA 1673' 38.91150,-120.93450 0.1h ago + Sending Message _______________ + Raw : KM6XXX-14>APRS::KM6XXX-6 :KM6XXX-6: 8 Miles E Auburn CA 0' 0,-120.93584 1873.7h ago{2 + To : KM6XXX-6 + Message : KM6XXX-6: 8 Miles E Auburn CA 0' 0,-120.93584 1873.7h ago + Msg number : 2 + Sending Message _______________ Complete - Sending ack __________________ Tx(3) - Raw : KM6XXX-9>APRS::KM6XXX :ack28 - To : KM6XXX - Ack number : 28 - - Received message______________ - Raw : KM6XXX>APY400,WIDE1-1,qAO,KM6XXX-1::KM6XXX-9 :ack7 - From : KM6XXX - Message : ack7 - Msg number : 0 + Sending ack _______________ + Raw : KM6XXX-14>APRS::KM6XXX-6 :ack2 + To : KM6XXX-6 + Ack : 2 + Sending ack _______________ Complete AND... ping, fortune, time..... @@ -341,25 +325,21 @@ Development * git clone git@github.com:craigerl/aprsd.git * cd aprsd -* virtualenv .venv -* source .venv/bin/activate -* pip install -e . -* pre-commit install +* make Workflow --------- +======== While working aprsd, The workflow is as follows * Edit code, save file -* run tox -epep8 * run tox -efmt * run tox -p * git commit ( This will run the pre-commit hooks which does checks too ) Release -------- +======= To do release to pypi: @@ -371,25 +351,20 @@ To do release to pypi: git push origin master --tags -* Build dist and wheel +* Do a test build and verify build is valid - python setup.py sdist bdist_wheel - -* Verify build is valid for pypi (need twine installed ) - - pip install twine - twine check dist/* + make build * Once twine is happy, upload release to pypi - twine upload dist/* + make upload Docker Container ----------------- +================ Building --------- +======== There are 2 versions of the container Dockerfile that can be used. The main Dockerfile, which is for building the official release container @@ -398,18 +373,18 @@ which is used for building a container based off of a git branch of the repo. Official Build --------------- +============== docker build -t hemna6969/aprsd:latest . Development Build ------------------ +================= docker build -t hemna6969/aprsd:latest -f Dockerfile-dev . Running the container ---------------------- +===================== There is a docker-compose.yml file that can be used to run your container. There are 2 volumes defined that can be used to store your configuration diff --git a/docs/_static/.keep b/docs/_static/.keep new file mode 100644 index 0000000..e69de29 diff --git a/docs/_templates/.keep b/docs/_templates/.keep new file mode 100644 index 0000000..e69de29 diff --git a/docs/apidoc/aprsd.plugins.rst b/docs/apidoc/aprsd.plugins.rst new file mode 100644 index 0000000..7c6718a --- /dev/null +++ b/docs/apidoc/aprsd.plugins.rst @@ -0,0 +1,77 @@ +aprsd.plugins package +===================== + +Submodules +---------- + +aprsd.plugins.email module +-------------------------- + +.. automodule:: aprsd.plugins.email + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugins.fortune module +---------------------------- + +.. automodule:: aprsd.plugins.fortune + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugins.location module +----------------------------- + +.. automodule:: aprsd.plugins.location + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugins.ping module +------------------------- + +.. automodule:: aprsd.plugins.ping + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugins.query module +-------------------------- + +.. automodule:: aprsd.plugins.query + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugins.time module +------------------------- + +.. automodule:: aprsd.plugins.time + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugins.version module +---------------------------- + +.. automodule:: aprsd.plugins.version + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugins.weather module +---------------------------- + +.. automodule:: aprsd.plugins.weather + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: aprsd.plugins + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/apidoc/aprsd.rst b/docs/apidoc/aprsd.rst new file mode 100644 index 0000000..2056c90 --- /dev/null +++ b/docs/apidoc/aprsd.rst @@ -0,0 +1,93 @@ +aprsd package +============= + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + aprsd.plugins + +Submodules +---------- + +aprsd.client module +------------------- + +.. automodule:: aprsd.client + :members: + :undoc-members: + :show-inheritance: + +aprsd.email module +------------------ + +.. automodule:: aprsd.email + :members: + :undoc-members: + :show-inheritance: + +aprsd.fake\_aprs module +----------------------- + +.. automodule:: aprsd.fake_aprs + :members: + :undoc-members: + :show-inheritance: + +aprsd.fuzzyclock module +----------------------- + +.. automodule:: aprsd.fuzzyclock + :members: + :undoc-members: + :show-inheritance: + +aprsd.main module +----------------- + +.. automodule:: aprsd.main + :members: + :undoc-members: + :show-inheritance: + +aprsd.messaging module +---------------------- + +.. automodule:: aprsd.messaging + :members: + :undoc-members: + :show-inheritance: + +aprsd.plugin module +------------------- + +.. automodule:: aprsd.plugin + :members: + :undoc-members: + :show-inheritance: + +aprsd.threads module +-------------------- + +.. automodule:: aprsd.threads + :members: + :undoc-members: + :show-inheritance: + +aprsd.utils module +------------------ + +.. automodule:: aprsd.utils + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: aprsd + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/apidoc/modules.rst b/docs/apidoc/modules.rst new file mode 100644 index 0000000..ab430eb --- /dev/null +++ b/docs/apidoc/modules.rst @@ -0,0 +1,7 @@ +aprsd +===== + +.. toctree:: + :maxdepth: 4 + + aprsd diff --git a/docs/clean_docs.py b/docs/clean_docs.py new file mode 100644 index 0000000..771bfd3 --- /dev/null +++ b/docs/clean_docs.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +"""Removes temporary Sphinx build artifacts to ensure a clean build. + +This is needed if the Python source being documented changes significantly. Old sphinx-apidoc +RST files can be left behind. +""" + +from pathlib import Path +import shutil + + +def main() -> None: + docs_dir = Path(__file__).resolve().parent + for folder in ("_build", "apidoc"): + delete_dir = docs_dir / folder + if delete_dir.exists(): + shutil.rmtree(delete_dir) + + +if __name__ == "__main__": + main() diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..b71f155 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,188 @@ +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. + +import os +import sys + +sys.path.insert(0, os.path.abspath("../src")) + + +# -- Project information ----------------------------------------------------- + +project = "APRSD" +copyright = "" +author = "Craig Lamparter" + +# The short X.Y version +version = "v1.5.0" +# The full version, including alpha/beta/rc tags +release = "" + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.todo", + "sphinx.ext.viewcode", + "sphinx.ext.napoleon", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = ".rst" + +# The master toctree document. +master_doc = "index" + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +html_theme_options = { + # Override the default alabaster line wrap, which wraps tightly at 940px. + "page_width": "auto", +} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = "adoc" + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, "a.tex", "a Documentation", "a", "manual"), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [(master_doc, "a", "a Documentation", [author], 1)] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "a", + "a Documentation", + author, + "a", + "One line description of project.", + "Miscellaneous", + ), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ["search.html"] + + +# -- Extension configuration ------------------------------------------------- + +# -- Options for todo extension ---------------------------------------------- + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True diff --git a/docs/configure.rst b/docs/configure.rst new file mode 100644 index 0000000..dfb2a6c --- /dev/null +++ b/docs/configure.rst @@ -0,0 +1,71 @@ +APRSD Configure +=============== + +Configure APRSD +------------------------ + +Once APRSD is :doc:`installed ` You will need to configure the config file +for running. + + +Generate config file +--------------------- +If you have never run the server, running it the first time will generate +a sample config file in the default location of ~/.config/aprsd/aprsd.yml + +.. code-block:: shell + + └─[$] -> aprsd server + Load config + /home/aprsd/.config/aprsd/aprsd.yml is missing, creating config file + Default config file created at /home/aprsd/.config/aprsd/aprsd.yml. Please edit with your settings. + +You can see the sample config file output + +Sample config file +------------------ + +.. code-block:: shell + + └─[$] -> cat ~/.config/aprsd/aprsd.yml + aprs: + host: rotate.aprs.net + logfile: /tmp/arsd.log + login: someusername + password: somepassword + port: 14580 + aprsd: + enabled_plugins: + - aprsd.plugins.email.EmailPlugin + - aprsd.plugins.fortune.FortunePlugin + - aprsd.plugins.location.LocationPlugin + - aprsd.plugins.ping.PingPlugin + - aprsd.plugins.query.QueryPlugin + - aprsd.plugins.time.TimePlugin + - aprsd.plugins.weather.WeatherPlugin + - aprsd.plugins.version.VersionPlugin + plugin_dir: ~/.config/aprsd/plugins + ham: + callsign: KFART + imap: + host: imap.gmail.com + login: imapuser + password: something here too + port: 993 + use_ssl: true + shortcuts: + aa: 5551239999@vtext.com + cl: craiglamparter@somedomain.org + wb: 555309@vtext.com + smtp: + host: imap.gmail.com + login: something + password: some lame password + port: 465 + use_ssl: false + + +Note, You must edit the config file and change the ham callsign to your +legal FCC HAM callsign, or aprsd server will not start. + +.. include:: links.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..8b1a043 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,30 @@ +.. a documentation master file, created by + sphinx-quickstart on Wed Dec 19 18:34:22 2018. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +``APRSD`` Documentation +======================= + +.. include:: readme.rst + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + readme + install + configure + server + plugin + + apidoc/modules.rst + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + +.. include:: links.rst diff --git a/docs/install.rst b/docs/install.rst new file mode 100644 index 0000000..d904432 --- /dev/null +++ b/docs/install.rst @@ -0,0 +1,67 @@ +APRSD installation +================== + +Install info in a nutshell +-------------------------- + +**Pythons**: Python 3.6 or later + +**Operating systems**: Linux, OSX, Unix + +**Installer Requirements**: setuptools_ + +**License**: Apache license + +**git repository**: https://github.com/craigerl/aprsd + +Installation with pip +-------------------------------------- + +Use the following command: + +.. code-block:: shell + + pip install aprsd + +It is fine to install ``aprsd`` itself into a virtualenv_ environment. + +Install from clone +------------------------- + +Consult the GitHub page how to clone the git repository: + + https://github.com/craigerl/aprsd + +and then install in your environment with something like: + +.. code-block:: shell + + $ cd + $ pip install . + +or install it `editable `_ if you want code changes to propagate automatically: + +.. code-block:: shell + + $ cd + $ pip install --editable . + +so that you can do changes and submit patches. + + +Install for development +---------------------------- + +For developers you should clone the repo from github, then use the Makefile + +.. code-block:: shell + + $ cd + $ make + +This creates a virtualenv_ directory, install all the requirements for +development as well as aprsd in `editable `_ mode. +It will install all of the pre-commit git hooks required to test prior to committing code. + + +.. include:: links.rst diff --git a/docs/links.rst b/docs/links.rst new file mode 100644 index 0000000..ba75c60 --- /dev/null +++ b/docs/links.rst @@ -0,0 +1,31 @@ +.. _`Cookiecutter`: https://cookiecutter.readthedocs.io +.. _`pluggy`: https://pluggy.readthedocs.io +.. _`cookiecutter-tox-plugin`: https://github.com/tox-dev/cookiecutter-tox-plugin +.. _devpi: https://doc.devpi.net +.. _Python: https://www.python.org +.. _virtualenv: https://pypi.org/project/virtualenv +.. _`pytest`: https://pytest.org +.. _nosetests: +.. _`nose`: https://pypi.org/project/nose +.. _`Holger Krekel`: https://twitter.com/hpk42 +.. _`pytest-xdist`: https://pypi.org/project/pytest-xdist +.. _ConfigParser: https://docs.python.org/3/library/configparser.html + +.. _`easy_install`: http://peak.telecommunity.com/DevCenter/EasyInstall +.. _pip: https://pypi.org/project/pip +.. _setuptools: https://pypi.org/project/setuptools +.. _`jenkins`: https://jenkins.io/index.html +.. _sphinx: https://pypi.org/project/Sphinx +.. _discover: https://pypi.org/project/discover +.. _unittest2: https://pypi.org/project/unittest2 +.. _mock: https://pypi.org/project/mock/ +.. _flit: https://flit.readthedocs.io/en/latest/ +.. _poetry: https://poetry.eustace.io/ +.. _pypy: https://pypy.org + +.. _`Python Packaging Guide`: https://packaging.python.org/tutorials/packaging-projects/ +.. _`tox.ini`: :doc:configfile + +.. _`PEP-508`: https://www.python.org/dev/peps/pep-0508/ +.. _`PEP-517`: https://www.python.org/dev/peps/pep-0517/ +.. _`PEP-518`: https://www.python.org/dev/peps/pep-0518/ diff --git a/docs/plugin.rst b/docs/plugin.rst new file mode 100644 index 0000000..6f74ce3 --- /dev/null +++ b/docs/plugin.rst @@ -0,0 +1,55 @@ +APRSD Command Plugin Development +================================ + +APRSDPluginBase +------------------------ + +Plugins are written as python objects that extend the APRSDPluginBase class. +This is an abstract class that has several properties and a method that must be implemented +by your subclass. + +Properties +---------- + +* name - the Command name +* regex - The regular expression that if matched against the incoming APRS message, + will cause your plugin to be called. + +Methods +------- + +* command - This method is called when the regex matches the incoming message from APRS. + If you want to send a message back to the sending, just return a string + in your method implementation. If you get called and don't want to reply, then + you should return a messaging.NULL_MESSAGE to signal to the plugin processor + that you got called and processed the message correctly. Otherwise a usage + string may get returned to the sender. + + +Example Plugin +-------------- + +There is an example plugin in the aprsd source code here: +aprsd/examples/plugins/example_plugin.py + +.. code-block:: python + + import logging + + from aprsd import plugin + + LOG = logging.getLogger("APRSD") + + + class HelloPlugin(plugin.APRSDPluginBase): + """Hello World.""" + + version = "1.0" + # matches any string starting with h or H + command_regex = "^[hH]" + command_name = "hello" + + def command(self, fromcall, message, ack): + LOG.info("HelloPlugin") + reply = "Hello '{}'".format(fromcall) + return reply diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 0000000..9f44907 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1,392 @@ +APRSD +----- + +.. image:: https://badge.fury.io/py/aprsd.svg + :target: https://badge.fury.io/py/aprsd + +.. image:: https://github.com/craigerl/aprsd/workflows/python/badge.svg + :target: https://github.com/craigerl/aprsd/actions + +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://black.readthedocs.io/en/stable/ + +.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336 + :target: https://timothycrosley.github.io/isort/ + +.. image:: https://static.pepy.tech/personalized-badge/aprsd?period=month&units=international_system&left_color=black&right_color=orange&left_text=Downloads + :target: https://pepy.tech/project/aprsd + + +Summary +======= + +`APRSD `_ is a Ham radio `APRS `_ message command gateway built on python. + +APRSD listens on amateur radio aprs-is network for messages and respond to them. +It has a plugin architecture for extensibility. Users of APRSD can write their own +plugins that can respond to APRS-IS messages. + +You must have an amateur radio callsign to use this software. APRSD gets +messages for the configured HAM callsign, and sends those messages to a +list of plugins for processing. There are a set of core plugins that +provide responding to messages to check email, get location, ping, +time of day, get weather, and fortune telling as well as version information +of aprsd itself. + +Typical use case +================ + +Ham radio operator using an APRS enabled HAM radio sends a message to check +the weather. an APRS message is sent, and then picked up by APRSD. The +APRS packet is decoded, and the message is sent through the list of plugins +for processing. For example, the WeatherPlugin picks up the message, fetches the weather +for the area around the user who sent the request, and then responds with +the weather conditions in that area. + + +APRSD Capabilities +================== + +* server - The main aprsd server processor. Send/Rx APRS messages to HAM callsign +* send-message - use aprsd to send a command/message to aprsd server. Used for development testing +* sample-config - generate a sample aprsd.yml config file for use/editing +* bash completion generation. Uses python click bash completion to generate completion code for your .bashrc/.zshrc + + +List of core server plugins +=========================== + +Plugins function by specifying a regex that is searched for in the APRS message. +If it matches, the plugin runs. IF the regex doesn't match, the plugin is skipped. + +* EmailPlugin - Check email and reply with contents. Have to configure IMAP and SMTP settings in aprs.yml +* FortunePlugin - Replies with old unix fortune random fortune! +* LocationPlugin - Checks location of ham operator +* PingPlugin - Sends pong with timestamp +* QueryPlugin - Allows querying the list of delayed messages that were not ACK'd by radio +* TimePlugin - Current time of day +* WeatherPlugin - Get weather conditions for current location of HAM callsign +* VersionPlugin - Reports the version information for aprsd + + +Current messages this will respond to: +====================================== + +:: + + APRS messages: + l(ocation) [callsign] = descriptive current location of your radio + 8 Miles E Auburn CA 1673' 39.92150,-120.93950 0.1h ago + w(eather) = weather forecast for your radio's current position + 58F(58F/46F) Partly Cloudy. Tonight, Heavy Rain. + t(ime) = respond with the current time + f(ortune) = respond with a short fortune + -email_addr email text = send an email, say "mapme" to send a current position/map + -2 = resend the last 2 emails from your imap inbox to this radio + p(ing) = respond with Pong!/time + v(ersion) = Respond with current APRSD Version string + anything else = respond with usage + + +Meanwhile this code will monitor a single imap mailbox and forward email +to your BASECALLSIGN over the air. Only radios using the BASECALLSIGN are allowed +to send email, so consider this security risk before using this (or Amatuer radio in +general). Email is single user at this time. + +There are additional parameters in the code (sorry), so be sure to set your +email server, and associated logins, passwords. search for "yourdomain", +"password". Search for "shortcuts" to setup email aliases as well. + + +Example usage: +============== + + aprsd -h + +Help +==== +:: + + └─[$] > aprsd -h + Usage: aprsd [OPTIONS] COMMAND [ARGS]... + + Shell completion for click-completion-command Available shell types: + bash Bourne again shell fish Friendly interactive shell + powershell Windows PowerShell zsh Z shell Default type: auto + + Options: + --version Show the version and exit. + -h, --help Show this message and exit. + + Commands: + install Install the click-completion-command completion + sample-config This dumps the config to stdout. + send-message Send a message to a callsign via APRS_IS. + server Start the aprsd server process. + show Show the click-completion-command completion code + + + + +Configuration +------------- +This command outputs a sample config yml formatted block that you can edit +and use to pass in to aprsd with -c. By default aprsd looks in ~/.config/aprsd/aprsd.yml + + aprsd sample-config + +Output +====== +:: + + └─[$] > aprsd sample-config + + aprs: + host: rotate.aprs.net + logfile: /tmp/arsd.log + login: someusername + password: somepassword + port: 14580 + aprsd: + enabled_plugins: + - aprsd.plugin.EmailPlugin + - aprsd.plugin.FortunePlugin + - aprsd.plugin.LocationPlugin + - aprsd.plugin.PingPlugin + - aprsd.plugin.TimePlugin + - aprsd.plugin.WeatherPlugin + - aprsd.plugin.VersionPlugin + plugin_dir: ~/.config/aprsd/plugins + ham: + callsign: KFART + imap: + host: imap.gmail.com + login: imapuser + password: something here too + port: 993 + use_ssl: true + shortcuts: + aa: 5551239999@vtext.com + cl: craiglamparter@somedomain.org + wb: 555309@vtext.com + smtp: + host: imap.gmail.com + login: something + password: some lame password + port: 465 + use_ssl: false + + +server +------ + +This is the main server command that will listen to APRS-IS servers and +look for incomming commands to the callsign configured in the config file + +:: + + └─[$] > aprsd server --help + Usage: aprsd server [OPTIONS] + + Start the aprsd server process. + + Options: + --loglevel [CRITICAL|ERROR|WARNING|INFO|DEBUG] + The log level to use for aprsd.log + [default: DEBUG] + + --quiet Don't log to stdout + --disable-validation Disable email shortcut validation. Bad + email addresses can result in broken email + responses!! + + -c, --config TEXT The aprsd config file to use for options. + [default: ~/.config/aprsd/aprsd.yml] + + -h, --help Show this message and exit. + (.venv3) ┌─[waboring@dl360-1] - [~/devel/aprsd] - [Sun Dec 20, 12:32] - + └─[$] aprsd server + Load config + [12/20/2020 12:33:03 PM] [MainThread ] [INFO ] APRSD Started version: 1.0.2 + [12/20/2020 12:33:03 PM] [MainThread ] [INFO ] Checking IMAP configuration + [12/20/2020 12:33:04 PM] [MainThread ] [INFO ] Checking SMTP configuration + + +send-message +------------ + +This command is typically used for development to send another aprsd instance +test messages + +:: + + └─[$] > aprsd send-message -h + Usage: aprsd send-message [OPTIONS] TOCALLSIGN [COMMAND]... + + Send a message to a callsign via APRS_IS. + + Options: + --loglevel [CRITICAL|ERROR|WARNING|INFO|DEBUG] + The log level to use for aprsd.log + [default: DEBUG] + + --quiet Don't log to stdout + -c, --config TEXT The aprsd config file to use for options. + [default: ~/.config/aprsd/aprsd.yml] + + --aprs-login TEXT What callsign to send the message from. + [env var: APRS_LOGIN] + + --aprs-password TEXT the APRS-IS password for APRS_LOGIN [env + var: APRS_PASSWORD] + + -h, --help Show this message and exit. + + +Example Message output: +----------------------- + + +SEND EMAIL (radio to smtp server) +================================= + +:: + + Received message______________ + Raw : KM6XXX>APY400,WIDE1-1,qAO,KM6XXX-1::KM6XXX-9 :-user@host.com test new shortcuts global, radio to pc{29 + From : KM6XXX + Message : -user@host.com test new shortcuts global, radio to pc + Msg number : 29 + + Sending Email_________________ + To : user@host.com + Subject : KM6XXX + Body : test new shortcuts global, radio to pc + + Sending ack __________________ Tx(3) + Raw : KM6XXX-9>APRS::KM6XXX :ack29 + To : KM6XXX + Ack number : 29 + + +RECEIVE EMAIL (imap server to radio) +==================================== + +:: + + Sending message_______________ 6(Tx3) + Raw : KM6XXX-9>APRS::KM6XXX :-somebody@gmail.com email from internet to radio{6 + To : KM6XXX + Message : -somebody@gmail.com email from internet to radio + + Received message______________ + Raw : KM6XXX>APY400,WIDE1-1,qAO,KM6XXX-1::KM6XXX-9 :ack6 + From : KM6XXX + Message : ack6 + Msg number : 0 + + +LOCATION +======== + +:: + + Received Message _______________ + Raw : KM6XXX-6>APRS,TCPIP*,qAC,T2CAEAST::KM6XXX-14:location{2 + From : KM6XXX-6 + Message : location + Msg number : 2 + Received Message _______________ Complete + + Sending Message _______________ + Raw : KM6XXX-14>APRS::KM6XXX-6 :KM6XXX-6: 8 Miles E Auburn CA 0' 0,-120.93584 1873.7h ago{2 + To : KM6XXX-6 + Message : KM6XXX-6: 8 Miles E Auburn CA 0' 0,-120.93584 1873.7h ago + Msg number : 2 + Sending Message _______________ Complete + + Sending ack _______________ + Raw : KM6XXX-14>APRS::KM6XXX-6 :ack2 + To : KM6XXX-6 + Ack : 2 + Sending ack _______________ Complete + +AND... ping, fortune, time..... + + +Development +----------- + +* git clone git@github.com:craigerl/aprsd.git +* cd aprsd +* make + +Workflow +======== + +While working aprsd, The workflow is as follows + +* Edit code, save file +* run tox -efmt +* run tox -p +* git commit ( This will run the pre-commit hooks which does checks too ) + + +Release +======= + +To do release to pypi: + +* Tag release with + + git tag -v1.XX -m "New release" + +* push release tag up + + git push origin master --tags + +* Do a test build and verify build is valid + + make build + +* Once twine is happy, upload release to pypi + + make upload + + +Docker Container +---------------- + +Building +======== + +There are 2 versions of the container Dockerfile that can be used. +The main Dockerfile, which is for building the official release container +based off of the pip install version of aprsd and the Dockerfile-dev, +which is used for building a container based off of a git branch of +the repo. + +Official Build +============== + + docker build -t hemna6969/aprsd:latest . + +Development Build +================= + + docker build -t hemna6969/aprsd:latest -f Dockerfile-dev . + + +Running the container +===================== + +There is a docker-compose.yml file that can be used to run your container. +There are 2 volumes defined that can be used to store your configuration +and the plugins directory: /config and /plugins + +If you want to install plugins at container start time, then use the +environment var in docker-compose.yml specified as APRS_PLUGINS +Provide a csv list of pypi installable plugins. Then make sure the plugin +python file is in your /plugins volume and the plugin will be installed at +container startup. The plugin may have dependencies that are required. +The plugin file should be copied to /plugins for loading by aprsd diff --git a/docs/server.rst b/docs/server.rst new file mode 100644 index 0000000..8fc28fd --- /dev/null +++ b/docs/server.rst @@ -0,0 +1,53 @@ +APRSD server +============ + +Running the APRSD server +------------------------ + +Once APRSD is :doc:`installed ` and :doc:`configured ` the server can be started by +running. + +.. code-block:: shell + + aprsd server + +The server will start several threads to deal handle incoming messages, outgoing +messages, checking and sending email. + +.. code-block:: shell + + [MainThread ] [INFO ] APRSD Started version: 1.5.1 + [MainThread ] [INFO ] Checking IMAP configuration + [MainThread ] [INFO ] Checking SMTP configuration + [MainThread ] [DEBUG] Connect to SMTP host SSL smtp.gmail.com:465 with user 'test@hemna.com' + [MainThread ] [DEBUG] Connected to smtp host SSL smtp.gmail.com:465 + [MainThread ] [DEBUG] Logged into SMTP server SSL smtp.gmail.com:465 + [MainThread ] [INFO ] Validating 2 Email shortcuts. This can take up to 10 seconds per shortcut + [MainThread ] [ERROR] 'craiglamparter@somedomain.org' is an invalid email address. Removing shortcut + [MainThread ] [INFO ] Available shortcuts: {'wb': 'waboring@hemna.com'} + [MainThread ] [INFO ] Loading Core APRSD Command Plugins + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.email.EmailPlugin'(1.0) '^-.*' + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.fortune.FortunePlugin'(1.0) '^[fF]' + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.location.LocationPlugin'(1.0) '^[lL]' + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.ping.PingPlugin'(1.0) '^[pP]' + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.query.QueryPlugin'(1.0) '^\?.*' + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.time.TimePlugin'(1.0) '^[tT]' + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.weather.WeatherPlugin'(1.0) '^[wW]' + [MainThread ] [INFO ] Registering Command plugin 'aprsd.plugins.version.VersionPlugin'(1.0) '^[vV]' + [MainThread ] [INFO ] Skipping Custom Plugins directory. + [MainThread ] [INFO ] Completed Plugin Loading. + [MainThread ] [DEBUG] Loading saved MsgTrack object. + [RX_MSG ] [INFO ] Starting + [TX_MSG ] [INFO ] Starting + [MainThread ] [DEBUG] KeepAlive Tracker(0): {} + [RX_MSG ] [INFO ] Creating aprslib client + [RX_MSG ] [INFO ] Attempting connection to noam.aprs2.net:14580 + [RX_MSG ] [INFO ] Connected to ('198.50.198.139', 14580) + [RX_MSG ] [DEBUG] Banner: # aprsc 2.1.8-gf8824e8 + [RX_MSG ] [INFO ] Sending login information + [RX_MSG ] [DEBUG] Server: # logresp KM6XXX-14 verified, server T2VAN + [RX_MSG ] [INFO ] Login successful + [RX_MSG ] [DEBUG] Logging in to APRS-IS with user 'KM6XXX-14' + + +.. include:: links.rst diff --git a/setup.cfg b/setup.cfg index 125cd1f..e89d7a8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,14 +2,25 @@ name = aprsd long_description = file: README.rst long_description_content_type = text/x-rst +url = http://aprsd.readthedocs.org author = Craig Lamparter author_email = something@somewhere.com +license = Apache +license_file = LICENSE classifier = + License :: OSI Approved :: Apache Software License Topic :: Communications :: Ham Radio Operating System :: POSIX :: Linux Programming Language :: Python + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 description_file = README.rst +project_urls = + Source=https://github.com/craigerl/aprsd + Tracker=https://github.com/craigerl/aprsd/issues summary = Amateur radio APRS daemon which listens for messages and responds [global] @@ -26,9 +37,12 @@ console_scripts = fake_aprs = aprsd.fake_aprs:main [build_sphinx] -source-dir = doc/source -build-dir = doc/build +source-dir = docs +build-dir = docs/_build all_files = 1 [upload_sphinx] -upload-dir = doc/build/html +upload-dir = docs/_build + +[bdist_wheel] +universal = 1 diff --git a/tox.ini b/tox.ini index dd53ec5..69103ef 100644 --- a/tox.ini +++ b/tox.ini @@ -23,8 +23,15 @@ commands = {envpython} -bb -m pytest {posargs} [testenv:docs] -deps = -r{toxinidir}/test-requirements.txt -commands = sphinx-build -b html docs/source docs/html +skip_install = true +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/dev-requirements.txt +changedir = {toxinidir}/docs +commands = + {envpython} clean_docs.py + sphinx-apidoc --force --output-dir apidoc {toxinidir}/aprsd + sphinx-build -a -W . _build [testenv:pep8] commands =