From dc6693fd99088fa6232558b38de8903bed83d68e Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Sun, 15 Sep 2024 23:13:29 -0700 Subject: [PATCH 01/31] [DOCUMENTATION] Prototype documentation features via sphinx (- WIP #79 -) Changes in file LICENSE.md: - Restyled to use markdown (Remains MIT License) - Added mention of modified sphinx config.py (BSD-2 License) Changes in file Makefile: - Added glue code to build documentaion via sphinx. W.I.P - Other minor tweaks to cleanup build documentaion stuff Changes in file docs/Makefile: - Added glue code to build documentaion via sphinx. W.I.P Changes in file docs/conf.py: - Prototype Sphinx configuration. W.I.P. Changes in file docs/requirements.txt: - Build-Docs dependencies. W.I.P. Changes in file docs/toc.md: - New template Table of Contents for Multicast Documentation. --- LICENSE.md | 36 +++-- Makefile | 23 ++- docs/Makefile | 167 ++++++++++++++++++++++ docs/conf.py | 321 ++++++++++++++++++++++++++++++++++++++++++ docs/requirements.txt | 47 +++++++ docs/toc.md | 23 +++ 6 files changed, 600 insertions(+), 17 deletions(-) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/requirements.txt create mode 100644 docs/toc.md diff --git a/LICENSE.md b/LICENSE.md index dcb6199..e5f6862 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -License - MIT +# MIT License Copyright (c) 2017-2024, Mr. Walls @@ -22,22 +22,22 @@ copies or substantial portions of the Software. -END MIT License +*** -Included Licenses and additional Acknowledgments included with package: +## Included Licenses and additional Acknowledgments included with package: -Files: `tests/context.py`, `tests/test_basic.py`, and `tests/test_usage.py` -.......................................... +* Files: `tests/context.py`, `tests/test_basic.py`, and `tests/test_usage.py` +--- Copyright (c) 2017-2022, Python Test Repo Template ALSO Licensed under MIT You may obtain a copy of the License at http://www.github.com/reactive-firewall/python-repo/LICENSE.md -.......................................... +--- -Third-party Acknowledgments: +## Third-party Acknowledgments: -Files: `multicast/send.py` and `multicast/recv.py` -.......................................... +* Files: `multicast/send.py` and `multicast/recv.py` +--- Some code (namely: run, and parseArgs) was modified/derived from: https://stackoverflow.com/a/52791404 Copyright (c) 2019, "pterodragon" (https://stackoverflow.com/users/5256940/pterodragon) @@ -46,15 +46,25 @@ see https://creativecommons.org/licenses/by-sa/4.0/ for details The code in `parseArgs`, `run`, and `main` are thus also under CC-by-sa-4 see https://creativecommons.org/licenses/by-sa/4.0/ for details -.......................................... +--- NO ASSOCIATION -Files: `tests/profiling.py` -.......................................... +* Files: `tests/profiling.py` +--- Some code (namely: class timewith, @do_cprofile, @do_line_profile) was modified/derived from: https://github.com/zapier/profiling-python-like-a-boss/tree/1ab93a1154 Copyright (c) 2013, Zapier Inc. All rights reserved. which was under BSD-3 Clause license. see https://github.com/zapier/profiling-python-like-a-boss/blob/1ab93a1154/LICENSE.md for details -.......................................... +--- +NO ASSOCIATION + +* Files: `docs/config.py` +--- +Some code (namely: sphinx setup output config) was modified/derived from: +https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/doc/conf.py +Copyright (c) 2007-2024 by the Sphinx team. All rights reserved. +which was under BSD-2 Clause license. +see https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/LICENSE.rst for details +--- NO ASSOCIATION diff --git a/Makefile b/Makefile index 0cf0d91..af7ede1 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,14 @@ ifeq "$(LINK)" "" LINK=ln -sf endif +ifeq "$(GIT)" "" + GIT=$(COMMAND) git +endif + +ifeq "$(GIT_WORK_TREE)" "" + GIT_WORK_TREE=$(shell -c "$(GIT) rev-parse --show-toplevel") +endif + ifeq "$(PYTHON)" "" PY_CMD=$(COMMAND) python3 ifneq "$(PY_CMD)" "" @@ -139,14 +147,15 @@ ifeq "$(RMDIR)" "" RMDIR=$(RM)Rd endif -PHONY: cleanup init must_be_root must_have_flake must_have_pytest uninstall +.PHONY: cleanup init clean-docs must_be_root must_have_flake must_have_pytest uninstall -build: init ./setup.py +build: init ./setup.py build-docs $(QUIET)$(PYTHON) -W ignore -m build --sdist --wheel --no-isolation ./ || $(QUIET)$(PYTHON) -W ignore -m build ./ ; $(QUITE)$(WAIT) $(QUIET)$(ECHO) "build DONE." init: + $(QUIET)$(ECHO) "Building from ... $(GIT_WORK_TREE)" $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) "pip>=19.0" "setuptools>=38.0" "wheel>=0.37" "build>=1.0.1" 2>$(ERROR_LOG_PATH) || : $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r requirements.txt 2>$(ERROR_LOG_PATH) || : $(QUIET)$(ECHO) "$@: Done." @@ -254,12 +263,18 @@ cleanup: $(QUIET)$(RMDIR) ./.tox/ 2>$(ERROR_LOG_PATH) || true $(QUIET)$(WAIT) ; +build-docs: ./docs/ ./docs/Makefile ./docs/requirements.txt + $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r ./docs/requirements.txt 2>$(ERROR_LOG_PATH) || : ; + $(QUIET)$(WAIT) ; + $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile html 2>$(ERROR_LOG_PATH) || : ; + $(QUIET)$(WAIT) ; + clean-docs: ./docs/ ./docs/Makefile - $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean 2>$(ERROR_LOG_PATH) || true + $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean 2>$(ERROR_LOG_PATH) || : ; $(QUIET)$(WAIT) ; ./docs/: - $(QUIET)$(WAIT) ; + $(QUIET) : ; ./docs/Makefile: ./docs/ $(QUIET)$(WAIT) ; diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..cd55c4c --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,167 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = -c ../docs/ +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build +SRCDIR = . +# change this to the directory you store python code in +PROJECT_DOC_SRC_DIR = multicast + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) + +.PHONY: help init clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +init: ../docs/ + @ln -sf ../"$(PROJECT_DOC_SRC_DIR)" $(SRCDIR)/"$(PROJECT_DOC_SRC_DIR)" + @ln -sf ../tests $(SRCDIR)/tests 2>/dev/null || true + @ln -sf ../README.md $(SRCDIR)/README.md + @ln -sf ../LICENSE.md $(SRCDIR)/LICENSE.md + +clean: + @-rm -rf $(BUILDDIR)/* 2>/dev/null || true + @-rm -rfRd $(SRCDIR)/apidocs/* 2>/dev/null || true + @-unlink $(SRCDIR)/README.md 2>/dev/null || true + @-unlink $(SRCDIR)/tests 2>/dev/null || true + @-unlink $(SRCDIR)/LICENSE.md 2>/dev/null || true + @-unlink $(SRCDIR)/"$(PROJECT_DOC_SRC_DIR)" 2>/dev/null || true + +html: init + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: init + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: init + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: init + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: init + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: init + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: init + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sample.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sample.qhc" + +devhelp: init + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/sample" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sample" + @echo "# devhelp" + +epub: init + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: init + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: init + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: init + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: init + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: init + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: init + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: init + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: init + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..b7ef998 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,321 @@ +# -*- coding: utf-8 -*- + +# sample documentation build configuration file, created by +# sphinx-quickstart on Mon Apr 16 21:22:43 2012. + +# This file is execfile()d with the current directory set to its containing dir. + +# Note that not all possible configuration values are present in this +# autogenerated file. + +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import argparse + +# 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. +sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(1, os.path.abspath('multicast')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = '5.2' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# for md us 'autodoc2' (pip install sphinx-autodoc2) +# for rst use 'sphinx.ext.autodoc' +extensions = [ + 'sphinx.ext.napoleon', 'autodoc2', 'sphinx.ext.autosummary', + 'sphinx.ext.githubpages', + 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.todo', + 'sphinx.ext.linkcode', 'sphinx.ext.viewcode', 'myst_parser' + ] + +# for md auto-docs +autodoc2_packages = [ + "multicast", + "tests", +] + +autodoc2_render_plugin = "myst" + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = { + '.md': 'markdown', + '.txt': 'markdown', + '.rst': 'restructuredtext', +} + +# The encoding of source files. Official sphinx docs reccomend utf-8-sig. +source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'toc' + +# General information about the project. +project = u'multicast' +copyright = u'2017-2024, reactive-firewall' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = 'v1.5' +# The full version, including alpha/beta/rc tags. +release = 'v1.5.0-rc' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' +today_fmt = '%Y.%B.%d' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build', '.github', '.circleci', '.DS_Store', '**/.git', 'dist', 'tests'] + +# The reST default role (used for this markup: `text`) to use for all documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# sigs should not have backslashes +strip_signature_backslash = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = True + +# The name of the Pygments (syntax highlighting) style to use. +# pygments_style = 'py' +pygments_style = 'default' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# Create table of contents entries for domain objects (e.g. functions, classes, attributes, etc.). +toc_object_entries = True + +# -- 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 = 'sphinxawesome_theme' + +# 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 = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +html_short_title = 'Multicast Docs' + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +html_permalinks_icon = '#' + +# 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'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'multicast_doc' + + +# -- Options for MyST markdown parser ------------------------------------------- +# see https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#syntax-directives + +# be more like GFM with style +myst_enable_extensions = set(['tasklist', 'strikethrough', 'fieldlist']) + +# for GFM diagrams and interoperability with other Markdown renderers +myst_fence_as_directive = set(('mermaid', 'suggestion', 'note')) + +# Focus only on github markdown +myst_gfm_only = False + + +#heading_anchors = 1 + +# -- Options for napoleon ext -------------------------------------------------- + +# include __init__ when it has docstrings +napoleon_include_init_with_doc = True + +# try to be smarter +napoleon_preprocess_types = True + +# -- 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': '', +# } + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ( + u'index', + u'Documentation.tex', + u'Multicast Documentation', + u'reactive-firewall', + u'manual' + ), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + u'index', + u'multicast', + u'Multicast Documentation', + [u'reactive-firewall'], + 1 + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- 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 = [ + ( + u'index', + u'Multicast', + u'Multicast Documentation', + u'reactive-firewall', + u'Multicast', + u'Multicast Python Module.', + u'Miscellaneous' + ), +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# -- Link resolver ------------------------------------------------------------- +def linkcode_resolve(domain, info): + if domain != 'py': + return None + if not info['module']: + return None + filename = info['module'].replace('.', '/') + return "https://github.com/reactive-firewall/multicast/blob/stable/%s.py" % filename diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..d6da49e --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,47 @@ +# Python Multicast Repo docs req file +# .................................. +# Copyright (c) 2017-2024, Mr. Walls +# .................................. +# Licensed under MIT (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# .......................................... +# http://www.github.com/reactive-firewall/multicast/LICENSE.md +# .......................................... +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#python +# time - builtin - PSF license +# re - builtin - PSF license? +# subprocess - PSF license +# sphinx - BSD license +sphinx>=5.2 +# sphinx - BSD license +sphinx-autodoc2>=0.5 +# sphinx - BSD license +myst-parser[linkify]>=4.0 +# sphinx - BSD license +sphinxawesome-theme>=0.5.0 +# argparse - builtin - PSF license +# socket - builtin - PSF license +# struct - builtin - PSF license +# argparse - builtin - PSF license +# argparse>=1.4.0 +# argparse - builtin - PSF license 3.7 = 62.6.0 +# setuptools - MIT license +setuptools>=38.0, !=71.0.1, !=72.0, !=69.4.0, !=69.3.0, !=60.3.0, !=59.1 +# virtualenv - MIT license +#virtualenv>=15.0.1 +# pgpy - BSD 3-Clause licensed +#pgpy>=0.4.1 +# tox - MIT license +#tox>=3.0.0, !=3.16.1 +# wheel - MIT license +wheel>=0.37.0 +# pip - MIT license +pip>=19.0 +# build - MIT license +# build>=0.5.1, !=1.0.3, !=0.6, !=0.6.1 !=1.1.0 !=1.2.0 diff --git a/docs/toc.md b/docs/toc.md new file mode 100644 index 0000000..1370df0 --- /dev/null +++ b/docs/toc.md @@ -0,0 +1,23 @@ +# Welcome to Multicast' documentation! + +## Contents: + +```{toctree} +:maxdepth: 3 +apidocs/index +/README.md +/setup.py +/LICENSE.md +:Name: Documentation +/ +``` + +## Overview + +```{autosummary} +``` + + +## Quickstart: + +more filler text From 66b6457f2ed4a3d35345723016aa42c2cb8e9732 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Mon, 16 Sep 2024 01:29:47 -0700 Subject: [PATCH 02/31] [DOCUMENTATION] debugged sphinx build features some more (- WIP #110 -) ### ChangeLog: Changes in file Makefile: cleanup: else endif Changes in file docs/conf.py: Unknown Changes --- Makefile | 24 +++++++++++++----------- docs/conf.py | 1 - 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index af7ede1..6ad6791 100644 --- a/Makefile +++ b/Makefile @@ -64,14 +64,6 @@ ifeq "$(LINK)" "" LINK=ln -sf endif -ifeq "$(GIT)" "" - GIT=$(COMMAND) git -endif - -ifeq "$(GIT_WORK_TREE)" "" - GIT_WORK_TREE=$(shell -c "$(GIT) rev-parse --show-toplevel") -endif - ifeq "$(PYTHON)" "" PY_CMD=$(COMMAND) python3 ifneq "$(PY_CMD)" "" @@ -149,13 +141,12 @@ endif .PHONY: cleanup init clean-docs must_be_root must_have_flake must_have_pytest uninstall -build: init ./setup.py build-docs +build: init ./setup.py $(QUIET)$(PYTHON) -W ignore -m build --sdist --wheel --no-isolation ./ || $(QUIET)$(PYTHON) -W ignore -m build ./ ; $(QUITE)$(WAIT) $(QUIET)$(ECHO) "build DONE." init: - $(QUIET)$(ECHO) "Building from ... $(GIT_WORK_TREE)" $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) "pip>=19.0" "setuptools>=38.0" "wheel>=0.37" "build>=1.0.1" 2>$(ERROR_LOG_PATH) || : $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r requirements.txt 2>$(ERROR_LOG_PATH) || : $(QUIET)$(ECHO) "$@: Done." @@ -266,10 +257,21 @@ cleanup: build-docs: ./docs/ ./docs/Makefile ./docs/requirements.txt $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r ./docs/requirements.txt 2>$(ERROR_LOG_PATH) || : ; $(QUIET)$(WAIT) ; - $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile html 2>$(ERROR_LOG_PATH) || : ; + $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile html 2>$(ERROR_LOG_PATH) || DO_FAIL="exit 2" ; + $(QUIET)$(WAIT) ; + $(QUIET)mkdir $(INST_OPTS) ./docs/www 2>$(ERROR_LOG_PATH) >$(ERROR_LOG_PATH) || : ; + $(QUIET)$(BSMARK) ./docs/www 2>$(ERROR_LOG_PATH) >$(ERROR_LOG_PATH) || : ; $(QUIET)$(WAIT) ; + $(QUIET)cp -fRp ./docs/_build/ ./docs/www/ 2>$(ERROR_LOG_PATH) || DO_FAIL="exit 35" ; + $(QUIET)$(WAIT) ; + $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean 2>$(ERROR_LOG_PATH) || : ; + $(QUIET)$(WAIT) ; + $(QUIET)$(ECHO) "Documentation should be in docs/www/html/" + $(QUIET)$(DO_FAIL) ; clean-docs: ./docs/ ./docs/Makefile + $(QUIET)$(RM) ./docs/www/* 2>$(ERROR_LOG_PATH) || : ; + $(QUIET)$(RMDIR) ./docs/www/ 2>$(ERROR_LOG_PATH) || : ; $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean 2>$(ERROR_LOG_PATH) || : ; $(QUIET)$(WAIT) ; diff --git a/docs/conf.py b/docs/conf.py index b7ef998..c32927b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,7 +13,6 @@ import sys import os -import argparse # 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 From afe6b2b85f6f7aae073e49b51d8e53e428d3133b Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Mon, 16 Sep 2024 15:05:22 -0700 Subject: [PATCH 03/31] [HOTFIX] Fixup .gitignore file Changes in file .gitignore: - added some generated paths to ignore list --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 7df3751..d560915 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,10 @@ ENV/ *.xcodeproj *.xcodeproj/* +# Project Specific +_build/ +docs/_build/ +docs/www/ +docs/make.bat +multicast/multicast/** +tests/tests/** From cb78e82c5f64ee756aa8d1129e6b0e62e15eefde Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Mon, 16 Sep 2024 15:07:23 -0700 Subject: [PATCH 04/31] [DOCUMENTATION] updated documentation configuration a bit. (- WIP #110 -) Changes in file docs/conf.py: - tweaks to theam and such - added project CC line - removed "import argparse" as per linters Changes in file docs/toc.md: - tweak for less verbose navigation --- docs/conf.py | 140 ++++++++++++++++++++++++++++++++------------------- docs/toc.md | 4 +- 2 files changed, 89 insertions(+), 55 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index c32927b..b8b6e4b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,6 +3,8 @@ # sample documentation build configuration file, created by # sphinx-quickstart on Mon Apr 16 21:22:43 2012. +# Copyright (c) 2012-2024, Mr. Walls + # This file is execfile()d with the current directory set to its containing dir. # Note that not all possible configuration values are present in this @@ -13,27 +15,28 @@ import sys import os +from sphinxawesome_theme.postprocess import Icons # 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. -sys.path.insert(0, os.path.abspath('..')) -sys.path.insert(1, os.path.abspath('multicast')) +sys.path.insert(0, os.path.abspath("""..""")) +sys.path.insert(1, os.path.abspath("""multicast""")) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = '5.2' +needs_sphinx = "5.2" # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # for md us 'autodoc2' (pip install sphinx-autodoc2) # for rst use 'sphinx.ext.autodoc' extensions = [ - 'sphinx.ext.napoleon', 'autodoc2', 'sphinx.ext.autosummary', - 'sphinx.ext.githubpages', - 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.todo', - 'sphinx.ext.linkcode', 'sphinx.ext.viewcode', 'myst_parser' + "sphinx.ext.napoleon", "autodoc2", "sphinx.ext.autosummary", + "sphinx.ext.githubpages", + "sphinx.ext.autosummary", "sphinx.ext.doctest", "sphinx.ext.todo", + "sphinx.ext.linkcode", "sphinx.ext.viewcode", "myst_parser" ] # for md auto-docs @@ -45,33 +48,35 @@ autodoc2_render_plugin = "myst" # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. source_suffix = { - '.md': 'markdown', - '.txt': 'markdown', - '.rst': 'restructuredtext', + ".md": "markdown", + ".txt": "markdown", + ".rst": "restructuredtext", + ".yml": "yaml", + "Makefile": "makefile", } # The encoding of source files. Official sphinx docs reccomend utf-8-sig. -source_encoding = 'utf-8-sig' +source_encoding = "utf-8-sig" # The master toctree document. -master_doc = 'toc' +master_doc = "toc" # General information about the project. -project = u'multicast' -copyright = u'2017-2024, reactive-firewall' +project = "multicast" +copyright = "2017-2024, reactive-firewall" -# The version info for the project you're documenting, acts as replacement for +# The version info for the project yo"re documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = 'v1.5' +version = "v1.5" # The full version, including alpha/beta/rc tags. -release = 'v1.5.0-rc' +release = "v1.5.0-rc" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -82,11 +87,14 @@ # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' -today_fmt = '%Y.%B.%d' +today_fmt = "%Y.%B.%d" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build', '.github', '.circleci', '.DS_Store', '**/.git', 'dist', 'tests'] +exclude_patterns = [ + "_build", ".github", ".circleci", "coddcov_env", ".DS_Store", "**/.git", "dist", + "tests/tests", "www", "**/docs", "multicast/multicast", "*~" +] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None @@ -106,8 +114,32 @@ show_authors = True # The name of the Pygments (syntax highlighting) style to use. -# pygments_style = 'py' -pygments_style = 'default' +# pygments_style = "default" +pygments_style = "xcode" + +# and for dark-mode +# pygments_style_dark ="monokai" +pygments_style_dark = "github-dark" + + +pygments_options = { + tabsize: 4, + stripall: False, + encoding: "utf-8", +} + +pygments_yaml_options = { + tabsize: 2, + stripall: True, + encoding: "utf-8", +} + +highlight_options = { + "default": pygments_options, + "python": pygments_options, + "yaml": pygments_yaml_options, + "makefile": pygments_options, +} # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -119,7 +151,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'sphinxawesome_theme' +html_theme = "sphinxawesome_theme" # 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 @@ -134,7 +166,7 @@ # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -html_short_title = 'Multicast Docs' +html_short_title = "Multicast Docs" # The name of an image file (relative to this directory) to place at the top # of the sidebar. @@ -145,16 +177,18 @@ # pixels large. # html_favicon = None -html_permalinks_icon = '#' +#html_permalinks_icon = "#" +html_permalinks_icon = Icons.permalinks_icon # 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'] +html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' +html_last_updated_fmt = today_fmt.strip() # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. @@ -183,7 +217,7 @@ # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True +html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the @@ -194,23 +228,23 @@ # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'multicast_doc' +htmlhelp_basename = "multicast_doc" # -- Options for MyST markdown parser ------------------------------------------- # see https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#syntax-directives # be more like GFM with style -myst_enable_extensions = set(['tasklist', 'strikethrough', 'fieldlist']) +myst_enable_extensions = set(["tasklist", "strikethrough", "fieldlist"]) # for GFM diagrams and interoperability with other Markdown renderers -myst_fence_as_directive = set(('mermaid', 'suggestion', 'note')) +myst_fence_as_directive = ("mermaid", "suggestion", "note") # Focus only on github markdown myst_gfm_only = False - -#heading_anchors = 1 +# how deep should markdown headers have anchors be generated +heading_anchors = 3 # -- Options for napoleon ext -------------------------------------------------- @@ -237,11 +271,11 @@ # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ( - u'index', - u'Documentation.tex', - u'Multicast Documentation', - u'reactive-firewall', - u'manual' + "index", + "Documentation.tex", + "Multicast Documentation", + "reactive-firewall", + "manual" ), ] @@ -272,10 +306,10 @@ # (source start file, name, description, authors, manual section). man_pages = [ ( - u'index', - u'multicast', - u'Multicast Documentation', - [u'reactive-firewall'], + "index", + "multicast", + "Multicast Documentation", + ["reactive-firewall"], 1 ) ] @@ -291,13 +325,13 @@ # dir menu entry, description, category) texinfo_documents = [ ( - u'index', - u'Multicast', - u'Multicast Documentation', - u'reactive-firewall', - u'Multicast', - u'Multicast Python Module.', - u'Miscellaneous' + "index", + "Multicast", + "Multicast Documentation", + "reactive-firewall", + "Multicast", + "Multicast Python Module.", + "Miscellaneous" ), ] @@ -312,9 +346,11 @@ # -- Link resolver ------------------------------------------------------------- def linkcode_resolve(domain, info): - if domain != 'py': + if domain != """py""": return None - if not info['module']: + if not info["""module"""]: return None - filename = info['module'].replace('.', '/') - return "https://github.com/reactive-firewall/multicast/blob/stable/%s.py" % filename + filename = info["""module"""].replace(""".""", """/""") + return str("""https://github.com/reactive-firewall/{proj}/blob/{branch}/{file}.py""").format( + proj=project, branch="""stable""", file=filename + ) diff --git a/docs/toc.md b/docs/toc.md index 1370df0..7c02f4c 100644 --- a/docs/toc.md +++ b/docs/toc.md @@ -3,10 +3,9 @@ ## Contents: ```{toctree} -:maxdepth: 3 +:maxdepth: 2 apidocs/index /README.md -/setup.py /LICENSE.md :Name: Documentation / @@ -17,7 +16,6 @@ apidocs/index ```{autosummary} ``` - ## Quickstart: more filler text From 824276371c355d9cc5d567ca29732f5c6d5f80ca Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Mon, 16 Sep 2024 18:17:09 -0700 Subject: [PATCH 05/31] [DOCUMENTATION] Fixed GH links for project and updated some docs (- WIP #79 & #110 -) Changes in file LICENSE.md: - cleaned up markdown (still MIT License) Changes in file docs/FAQ.md: - moved FAQ to its own document (- WIP #79 -) Changes in file docs/Makefile: - minor tweaks for debugging the alpha Changes in file docs/conf.py: - improved link resolution and such (- WIP #110 -) Changes in file docs/toc.md: ## Contents: --- LICENSE.md | 34 +++++----- docs/FAQ.md | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/Makefile | 2 +- docs/conf.py | 58 ++++++++++++----- docs/toc.md | 42 ++++++++++++- 5 files changed, 270 insertions(+), 36 deletions(-) create mode 100644 docs/FAQ.md diff --git a/LICENSE.md b/LICENSE.md index e5f6862..89ee164 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -27,44 +27,44 @@ copies or substantial portions of the Software. ## Included Licenses and additional Acknowledgments included with package: * Files: `tests/context.py`, `tests/test_basic.py`, and `tests/test_usage.py` ---- +*** Copyright (c) 2017-2022, Python Test Repo Template ALSO Licensed under MIT You may obtain a copy of the License at -http://www.github.com/reactive-firewall/python-repo/LICENSE.md ---- +[MIT License](http://www.github.com/reactive-firewall/python-repo/LICENSE.md) +*** ## Third-party Acknowledgments: * Files: `multicast/send.py` and `multicast/recv.py` ---- +*** Some code (namely: run, and parseArgs) was modified/derived from: -https://stackoverflow.com/a/52791404 -Copyright (c) 2019, "pterodragon" (https://stackoverflow.com/users/5256940/pterodragon) +[This answer on stackoverflow](https://stackoverflow.com/a/52791404) +Copyright (c) 2019, ["pterodragon"](https://stackoverflow.com/users/5256940/pterodragon) which was under CC-by-sa-4 license. -see https://creativecommons.org/licenses/by-sa/4.0/ for details +see [CC-by-sa-4](https://creativecommons.org/licenses/by-sa/4.0/) for details The code in `parseArgs`, `run`, and `main` are thus also under CC-by-sa-4 -see https://creativecommons.org/licenses/by-sa/4.0/ for details ---- +see [CC-by-sa-4](https://creativecommons.org/licenses/by-sa/4.0/) for details +*** NO ASSOCIATION * Files: `tests/profiling.py` ---- +*** Some code (namely: class timewith, @do_cprofile, @do_line_profile) was modified/derived from: -https://github.com/zapier/profiling-python-like-a-boss/tree/1ab93a1154 +[profiling-python-like-a-boss](https://github.com/zapier/profiling-python-like-a-boss/tree/1ab93a1154) Copyright (c) 2013, Zapier Inc. All rights reserved. which was under BSD-3 Clause license. -see https://github.com/zapier/profiling-python-like-a-boss/blob/1ab93a1154/LICENSE.md for details ---- +see [BSD-3 Clause license](https://github.com/zapier/profiling-python-like-a-boss/blob/1ab93a1154/LICENSE.md) for details +*** NO ASSOCIATION * Files: `docs/config.py` ---- +*** Some code (namely: sphinx setup output config) was modified/derived from: -https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/doc/conf.py +[Sphinx documentation](https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/doc/conf.py) Copyright (c) 2007-2024 by the Sphinx team. All rights reserved. which was under BSD-2 Clause license. -see https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/LICENSE.rst for details ---- +see [BSD License](https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/LICENSE.rst) for details +*** NO ASSOCIATION diff --git a/docs/FAQ.md b/docs/FAQ.md new file mode 100644 index 0000000..af1a09f --- /dev/null +++ b/docs/FAQ.md @@ -0,0 +1,170 @@ +# FAQ + +## Frequently Asked Questions + +### How do I get this running? + +(assuming python3 is setup and installed) + +```bash +# cd /MY-AWSOME-DEV-PATH +git clone https://github.com/reactive-firewall/multicast.git multicast +cd ./multicast +git checkout stable +# make clean ; make test ; make clean ; +make install ; +python3 -m multicast --help ; +``` +#### DONE + +If all went well `multicast` is now installed and working :tada: + + +### How do I use this to receive some UDP Multicast? + +(assuming project is setup and installed and you want to listen on 0.0.0.0) + +```bash +# cd /MY-AWSOME-DEV-PATH +python3 -m multicast HEAR --use-std --port 59595 --join-mcast-groups 224.0.0.1 --bind-group 224.0.0.1 +``` + +Caveat: RCEV is much more usefull if actually used in a loop like: + +```bash +# cd /MY-AWSOME-DEV-PATH +while true ; do # unitl user ctl+c inturupts +python3 -m multicast RECV --use-std --port 59595 --join-mcast-groups 224.0.0.1 --bind-group 224.0.0.1 +done +``` + + +### How do I use this to send UDP Multicast? + +(assuming project is setup and installed) + +```bash +# cd /MY-AWSOME-DEV-PATH +python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello World!" +``` + + +### What is the basic API via python (instead of bash like above): + +#### Caveat: this module is still a BETA +[Here is how it is tested right now](https://github.com/reactive-firewall/multicast/blob/cdd577549c0bf7c2bcf85d1b857c86135778a9ed/tests/test_usage.py#L251-L554) + +```python3 +import mulicast as mulicast +from multiprocessing import Process as Process + +# setup some stuff +_fixture_PORT_arg = int(59595) +_fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses +_fixture_host_BIND_arg +_fixture_HEAR_args = [ + """--port""", _fixture_PORT_arg, + """--join-mcast-groups""", _fixture_mcast_GRP_arg, + """--bind-group""", _fixture_mcast_GRP_arg" +] + +# spwan a listening proc + +def inputHandle() + buffer_string = str("""""") + buffer_string += multicast.recv.hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) + return buffer_string + +def printLoopStub(func): + for i in range( 0, 5 ): + print( str( func() ) ) + +p = Process( + target=multicast.__main__.McastDispatch().doStep, + name="HEAR", args=("HEAR", _fixture_HEAR_args,) + ) +p.start() + +# ... probably will return with nothing outside a handler function in a loop +``` +and elsewhere (like another function or even module) for the sender: +```python3 + +# assuming already did 'import mulicast as mulicast' + +_fixture_SAY_args = [ + """--port""", _fixture_PORT_arg, + """--mcast-group""", _fixture_mcast_GRP_arg, + """--message""", """'test message'""" +] +try: + multicast.__main__.McastDispatch().doStep("SAY", _fixture_SAY_args) + # Hint: use a loop to repeat or different arguments to varry message. +except Exception: + p.join() + raise RuntimeException("multicast seems to have failed, blah, blah") + +# clean up some stuff +p.join() # if not already handled don't forget to join the process and other overhead +didWork = (int(p.exitcode) <= int(0)) # if you use a loop and need to know the exit code + +``` +#### Caveat: the above examples assume the reader is knowledgeable about general `IPC` theory and the standard python `multiprocessing` module and its use. + + +### What are the defaults? + +#### The default multicast group address is 224.0.0.1 + +From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L185-L187): +> The Value of "224.0.0.1" is chosen as a default multicast group as per RFC-5771 +> on the rational that this group address will be treated as a local-net multicast +> (caveat: one should use link-local for ipv6) + +#### The default multicast Time-to-Live (TTL) is 1 + +From [RFC-1112 §6.1](https://www.rfc-editor.org/rfc/rfc1112#section-6.1) +> ... If the +> upper-layer protocol chooses not to specify a time-to-live, it should +> default to 1 for all multicast IP datagrams, so that an explicit +> choice is required to multicast beyond a single network. + +From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L214-L217): +> A Value of 1 (one TTL) is chosen as per [RFC-1112 §6.1](https://www.rfc-editor.org/rfc/rfc1112#section-6.1) on the rational that an +> explicit value that could traverse byond the local connected network should be +> chosen by the caller rather than the default vaule. This is inline with the principle +> of none, one or many. + +#### The default multicast destination port is 59559 + +From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L155): +> Arbitrary port to use by default, though any dynamic and free port would work. + +> :exclamation: Caution: it is best to specify the port in use at this time as the default has yet to be properly assigned ( see related reactive-firewall/multicast#62 ) + + +### What does exit code _x_ mean? + +#### Python function return code meanings + +`0` is the default and implies *success*, and means the process has essentially (or actually) returned nothing (or `None`) + +`1` is used when a *single* result is returned (caveat: functions may return a single `tuple` instead of `None` to indicate exit code `1` by returning a `boolean` success value, and result (which may also be encapsulated as an iteratable if needed) ) + +`2` is used to indicate a *value and reason* are returned (caveat: functions may return a single `tuple` with a single value and reason and the value can be a `tuple`) + +`-1` is used to mean *many* of unspecified length and otherwise functions as `1` + +#### CLI exit code meanings + +`0` *success* + +`1` *none-sucsess* - and is often accompanied by warnings or errors + +`2 >` *failure* of specific reason + + +#### Everything Else +_(extra exit code meanings)_ + +Other codes (such as `126`) may or may not have meanings (such as skip) but are not handled within the scope of the Multicast Project at this time. diff --git a/docs/Makefile b/docs/Makefile index cd55c4c..f55974a 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,7 +2,7 @@ # # You can set these variables from the command line. -SPHINXOPTS = -c ../docs/ +SPHINXOPTS = -c ../docs/ -v SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build diff --git a/docs/conf.py b/docs/conf.py index b8b6e4b..1f056f6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,11 +33,11 @@ # for md us 'autodoc2' (pip install sphinx-autodoc2) # for rst use 'sphinx.ext.autodoc' extensions = [ - "sphinx.ext.napoleon", "autodoc2", "sphinx.ext.autosummary", - "sphinx.ext.githubpages", - "sphinx.ext.autosummary", "sphinx.ext.doctest", "sphinx.ext.todo", - "sphinx.ext.linkcode", "sphinx.ext.viewcode", "myst_parser" - ] + """sphinx.ext.napoleon""", """autodoc2""", """sphinx.ext.autosectionlabel""", + """sphinx.ext.githubpages""", """myst_parser""", + """sphinx.ext.autosummary""", """sphinx.ext.doctest""", """sphinx.ext.todo""", + """sphinx.ext.linkcode""", """sphinx.ext.viewcode""", """sphinx.ext.intersphinx""", +] # for md auto-docs autodoc2_packages = [ @@ -93,7 +93,7 @@ # directories to ignore when looking for source files. exclude_patterns = [ "_build", ".github", ".circleci", "coddcov_env", ".DS_Store", "**/.git", "dist", - "tests/tests", "www", "**/docs", "multicast/multicast", "*~" + "../tests/tests/**", "www", "**/docs", "../multicast/multicast/**", "*~" ] # The reST default role (used for this markup: `text`) to use for all documents. @@ -123,15 +123,15 @@ pygments_options = { - tabsize: 4, - stripall: False, - encoding: "utf-8", + """tabsize""": 4, + """stripall""": False, + """encoding""": "utf-8", } pygments_yaml_options = { - tabsize: 2, - stripall: True, - encoding: "utf-8", + """tabsize""": 2, + """stripall""": True, + """encoding""": "utf-8", } highlight_options = { @@ -345,12 +345,36 @@ # texinfo_show_urls = 'footnote' # -- Link resolver ------------------------------------------------------------- + +linkcode_url_prefix = str( + """https://github.com/reactive-firewall/{proj}""" +).format(proj=project) + +extlinks = {"""issue""": (str("""{prefix}/{suffix}""").format( + prefix=linkcode_url_prefix, suffix="""/issues/%s""" + ), + """issue #%s""") +} + +# try to link with official python3 documentation. +# see https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html for more +intersphinx_mapping = { + """python""": ( + """https://docs.python.org/3""", + (None, """python-inv.txt""" + ) + ) +} + def linkcode_resolve(domain, info): - if domain != """py""": - return None - if not info["""module"""]: + if domain != """py""" or not info["""module"""]: return None filename = info["""module"""].replace(""".""", """/""") - return str("""https://github.com/reactive-firewall/{proj}/blob/{branch}/{file}.py""").format( - proj=project, branch="""stable""", file=filename + theResult = str("""{prefix}/blob/{branch}/{file}.py""").format( + prefix=linkcode_url_prefix, branch="""stable""", file=filename ) + if str("""/multicast.py""") in theResult: + theResult = theResult.replace("/multicast.py", "/multicast/__init__.py") + if str("""/tests.py""") in theResult: + theResult = theResult.replace("/tests.py", "/tests/__init__.py") + return theResult diff --git a/docs/toc.md b/docs/toc.md index 7c02f4c..950457d 100644 --- a/docs/toc.md +++ b/docs/toc.md @@ -17,5 +17,45 @@ apidocs/index ``` ## Quickstart: +**Welcome to the Multicast Python Library! Let's get you started quickly.** -more filler text +**Step 1: Install Python 3** + +* Ensure Python 3 is installed on your system. + +**Step 2: Clone the Repository** + +* Open your terminal and run: + ```shell + git clone https://github.com/reactive-firewall/multicast.git + cd multicast + ``` + +**Step 3: Install the Package** + +* Run: + ```shell + make install + ``` + +**Step 4: Sending Messages** + +* Send a message using: + ```shell + python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello, Multicast!" + ``` + +**Step 5: Receiving Messages** + +* Receive messages by running: + ```shell + python3 -m multicast RECV --use-std --port 59595 --join-mcast-groups 224.1.1.2 + ``` + +**You're all set! Enjoy using Multicast for your projects.** + + +--- +### Copyright (c) 2021-2024, Mr. Walls + +[![License - MIT](https://img.shields.io/github/license/reactive-firewall/multicast.svg?maxAge=3600)](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md) From a645bb2d5a3254a1da81ba5141e81e0740b1a492 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Mon, 16 Sep 2024 20:04:16 -0700 Subject: [PATCH 06/31] [DOCUMENTATION] Improved Documentation hopefully (- WIP #104 & #110 -) Changes in file docs/CI.md: - Moved CI section to its own document Changes in file docs/FAQ.md: - Moved FAQ to its own document Changes in file docs/USAGE.md: - Moved CLI usage to a combined usage document - Moved alpha api usage examples to combined usage document Changes in file docs/requirements.txt: - documentation generator related dependencies Changes in file docs/toc.md: - improved TOC page a bit --- docs/CI.md | 53 ++++++++++++++++++++++ docs/FAQ.md | 11 ++++- docs/USAGE.md | 100 ++++++++++++++++++++++++++++++++++++++++++ docs/requirements.txt | 16 +++---- docs/toc.md | 36 ++++++++------- 5 files changed, 190 insertions(+), 26 deletions(-) create mode 100644 docs/CI.md create mode 100644 docs/USAGE.md diff --git a/docs/CI.md b/docs/CI.md new file mode 100644 index 0000000..966484a --- /dev/null +++ b/docs/CI.md @@ -0,0 +1,53 @@ +# CI: + +## Service providers +*** + +Continuous integration testing is handled by github actions and the generous Circle-CI Service. + + +## MATs +*** + +Minimal acceptance testing is run across multiple versions of python to ensure stable behavior +accross a wide range of environments. Feature development and non-security related bug fixes are +done on development branches and then merged into the +[default branch (master)](https://github.com/reactive-firewall/multicast/blob/master/) for further +integration testing. This ensures the [stable](https://github.com/reactive-firewall/multicast/blob/stable/) +branch remains acceptable for production use. + + +## Testing +*** + +You can find all of the testing code in the aptly named `tests/` directory. +* Unit-testing is primarally done with the `unittest` framework. +* Functional testing is done via additional checks, including an end-to-end check invoking an + actual pair of processes to test that `SAY` and `RECV` indeed work together. + + +## Dev dependancy Testing: +*** + +### In a rush to get this module working? Then try using this with your own test: + +```bash +#cd /MY-AWSOME-DEV-PATH/multicast +make clean ; # cleans up from any previous tests hopefully +make test ; # runs the tests +make clean ; # cleans up for next test +``` + +#### Use PEP8 to check python code style? Great! Try this: + +```bash +make clean ; # cleans up from any previous tests hopefully +make test-style ; # runs the tests +make clean ; # cleans up for next test +``` + +_draft_ + +--- +#### Copyright (c) 2021-2024, Mr. Walls +[License - MIT](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md) diff --git a/docs/FAQ.md b/docs/FAQ.md index af1a09f..4cf1336 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -2,6 +2,13 @@ ## Frequently Asked Questions +```{toctree} +:maxdepth: 3 + +https://github.com/reactive-firewall/multicast/.github/CODE_OF_CONDUCT.md +https://github.com/reactive-firewall/multicast/.github/CONTRIBUTING.md +``` + ### How do I get this running? (assuming python3 is setup and installed) @@ -55,7 +62,7 @@ python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello W [Here is how it is tested right now](https://github.com/reactive-firewall/multicast/blob/cdd577549c0bf7c2bcf85d1b857c86135778a9ed/tests/test_usage.py#L251-L554) ```python3 -import mulicast as mulicast +import multicast as multicast from multiprocessing import Process as Process # setup some stuff @@ -90,7 +97,7 @@ p.start() and elsewhere (like another function or even module) for the sender: ```python3 -# assuming already did 'import mulicast as mulicast' +# assuming already did 'import multicast as multicast' _fixture_SAY_args = [ """--port""", _fixture_PORT_arg, diff --git a/docs/USAGE.md b/docs/USAGE.md new file mode 100644 index 0000000..920060b --- /dev/null +++ b/docs/USAGE.md @@ -0,0 +1,100 @@ +# Usage + + +## Basic library usage +*** + +The API is in late alpha testing, and has not yet reached a beta (pre-release) stage. + +Here is an example of usage (circa v1.4) + +```python3 +import multicast as multicast +from multiprocessing import Process as Process + +# setup some stuff +_fixture_PORT_arg = int(59595) +_fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses +_fixture_host_BIND_arg +_fixture_HEAR_args = [ + """--port""", _fixture_PORT_arg, + """--join-mcast-groups""", _fixture_mcast_GRP_arg, + """--bind-group""", _fixture_mcast_GRP_arg" +] + +# spwan a listening proc + +def inputHandle() + buffer_string = str("""""") + buffer_string += multicast.recv.hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) + return buffer_string + +def printLoopStub(func): + for i in range( 0, 5 ): + print( str( func() ) ) + +p = Process( + target=multicast.__main__.McastDispatch().doStep, + name="HEAR", args=("HEAR", _fixture_HEAR_args,) + ) +p.start() + +# ... probably will return with nothing outside a handler function in a loop +``` +and elsewhere (like another function or even module) for the sender: +```python3 + +# assuming already did 'import multicast as multicast' + +_fixture_SAY_args = [ + """--port""", _fixture_PORT_arg, + """--mcast-group""", _fixture_mcast_GRP_arg, + """--message""", """'test message'""" +] +try: + multicast.__main__.McastDispatch().doStep("SAY", _fixture_SAY_args) + # Hint: use a loop to repeat or different arguments to varry message. +except Exception: + p.join() + raise RuntimeException("multicast seems to have failed, blah, blah") + +# clean up some stuff +p.join() # if not already handled don't forget to join the process and other overhead +didWork = (int(p.exitcode) <= int(0)) # if you use a loop and need to know the exit code + +``` +#### Caveat: the above examples assume the reader is knowledgeable about general `IPC` theory and the standard python `multiprocessing` module and its use. + + + +## CLI Usage +*** + +The CLI is actually not the best way to use this kind of library so it should not be considered the full implementation. For testing/prototyping though it is quite convenient, thus I begin with it. + +CLI should work like so: + +```plain +multicast (SAY|RECV|HEAR) [-h|--help] [--use-std] [--daemon] [--port PORT] [--iface IFACE] [--pipe|-m MESSAGE|--message MESSAGE] [--group BIND_GROUP] [--groups [JOIN_MCAST_GROUPS ...]] +``` + +The commands are `SAY`, `RECV`, and `HEAR` for the CLI and are analogus to `send` listen/accept and echo functions of a 1-to-1 connection. + +### `SAY` + +The `SAY` command is used to send data messages via multicast datagrams. +* Note: the `--daemon` flag has no effect on the `SAY` command. + +### `RECV` + +The `RECV` command is used to receive multicast datagrams by listening or "joining" a multicast group. +* If the `--use-std` flag is set the output is printed to the standard-output +* This command is purely for testing or interfacing with external components and not intended as a first-class API +* Note: If the `--daemon` flag is used the process will loop after reporting each datagrams until canceled, it has no effect on the `RECV` command. + +### `HEAR` + +The `HEAR` command is used to send data acknowledged messages via "HEAR" messages echoing select received multicast datagrams. +* While mostly a testing function it is possible to use `HEAR` as a proxy for other send/recv instances by using the `--daemon` flag +* Note: this will use the same port for sends and receives and can lead to data loss if less than two groups are used. +* If more than one group is used via the `--groups` flag then all but the bind group (via `--group`) will be echoed to the bind group. diff --git a/docs/requirements.txt b/docs/requirements.txt index d6da49e..8efd5bd 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -17,14 +17,6 @@ # time - builtin - PSF license # re - builtin - PSF license? # subprocess - PSF license -# sphinx - BSD license -sphinx>=5.2 -# sphinx - BSD license -sphinx-autodoc2>=0.5 -# sphinx - BSD license -myst-parser[linkify]>=4.0 -# sphinx - BSD license -sphinxawesome-theme>=0.5.0 # argparse - builtin - PSF license # socket - builtin - PSF license # struct - builtin - PSF license @@ -45,3 +37,11 @@ wheel>=0.37.0 pip>=19.0 # build - MIT license # build>=0.5.1, !=1.0.3, !=0.6, !=0.6.1 !=1.1.0 !=1.2.0 +# sphinx - BSD license +sphinx>=5.2 +# sphinx-autodoc2 - MIT license +sphinx-autodoc2>=0.5.0 +# myst-parser - MIT license +myst-parser[linkify]>=4.0.0 +# sphinxawesome-theme - MIT license +sphinxawesome-theme>=0.5.0 diff --git a/docs/toc.md b/docs/toc.md index 950457d..dd35542 100644 --- a/docs/toc.md +++ b/docs/toc.md @@ -1,21 +1,5 @@ # Welcome to Multicast' documentation! -## Contents: - -```{toctree} -:maxdepth: 2 -apidocs/index -/README.md -/LICENSE.md -:Name: Documentation -/ -``` - -## Overview - -```{autosummary} -``` - ## Quickstart: **Welcome to the Multicast Python Library! Let's get you started quickly.** @@ -55,6 +39,26 @@ apidocs/index **You're all set! Enjoy using Multicast for your projects.** + +## Contents: + +```{toctree} +:maxdepth: 2 +:Name: Documentation +apidocs/index +/README.md +/FAQ.md +/CI.md +/USAGE.md +:Name: License +/LICENSE.md +``` + +## Overview + +```{autosummary} +``` + --- ### Copyright (c) 2021-2024, Mr. Walls From e5a9b5a437da1013e6fd83ac1a7470cd67e7fb0d Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Mon, 16 Sep 2024 23:03:20 -0700 Subject: [PATCH 07/31] [REGRESSION] Apply suggestions from code review (- WIP #110 -) Lots of mistakes. Lots of fixes. :speak_no_evil: Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- LICENSE.md | 16 ++++++++-------- docs/CI.md | 10 +++++----- docs/FAQ.md | 23 ++++++++++++----------- docs/USAGE.md | 11 ++++++----- docs/toc.md | 14 +++++++------- 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 89ee164..e9466c2 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -24,7 +24,7 @@ copies or substantial portions of the Software. *** -## Included Licenses and additional Acknowledgments included with package: +## Included Licenses and additional Acknowledgments included with package * Files: `tests/context.py`, `tests/test_basic.py`, and `tests/test_usage.py` *** @@ -38,33 +38,33 @@ You may obtain a copy of the License at * Files: `multicast/send.py` and `multicast/recv.py` *** -Some code (namely: run, and parseArgs) was modified/derived from: +Some code (namely: run, and parseArgs) was modified/derived from [This answer on stackoverflow](https://stackoverflow.com/a/52791404) Copyright (c) 2019, ["pterodragon"](https://stackoverflow.com/users/5256940/pterodragon) which was under CC-by-sa-4 license. -see [CC-by-sa-4](https://creativecommons.org/licenses/by-sa/4.0/) for details +See [CC-by-sa-4](https://creativecommons.org/licenses/by-sa/4.0/) for details. The code in `parseArgs`, `run`, and `main` are thus also under CC-by-sa-4 -see [CC-by-sa-4](https://creativecommons.org/licenses/by-sa/4.0/) for details +See [CC-by-sa-4](https://creativecommons.org/licenses/by-sa/4.0/) for details. *** NO ASSOCIATION * Files: `tests/profiling.py` *** -Some code (namely: class timewith, @do_cprofile, @do_line_profile) was modified/derived from: +Some code (namely: class timewith, @do_cprofile, @do_line_profile) was modified/derived from [profiling-python-like-a-boss](https://github.com/zapier/profiling-python-like-a-boss/tree/1ab93a1154) Copyright (c) 2013, Zapier Inc. All rights reserved. which was under BSD-3 Clause license. -see [BSD-3 Clause license](https://github.com/zapier/profiling-python-like-a-boss/blob/1ab93a1154/LICENSE.md) for details +See [BSD-3 Clause license](https://github.com/zapier/profiling-python-like-a-boss/blob/1ab93a1154/LICENSE.md) for details. *** NO ASSOCIATION * Files: `docs/config.py` *** -Some code (namely: sphinx setup output config) was modified/derived from: +Some code (namely: Sphinx setup output config) was modified/derived from [Sphinx documentation](https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/doc/conf.py) Copyright (c) 2007-2024 by the Sphinx team. All rights reserved. which was under BSD-2 Clause license. -see [BSD License](https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/LICENSE.rst) for details +See [BSD License](https://github.com/sphinx-doc/sphinx/blob/569fde84d49c984282355c768c16426af83132e2/LICENSE.rst) for details. *** NO ASSOCIATION diff --git a/docs/CI.md b/docs/CI.md index 966484a..46dc790 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -3,14 +3,14 @@ ## Service providers *** -Continuous integration testing is handled by github actions and the generous Circle-CI Service. +Continuous integration testing is handled by GitHub Actions and the generous CircleCI service. ## MATs *** Minimal acceptance testing is run across multiple versions of python to ensure stable behavior -accross a wide range of environments. Feature development and non-security related bug fixes are +across a wide range of environments. Feature development and non-security related bug fixes are done on development branches and then merged into the [default branch (master)](https://github.com/reactive-firewall/multicast/blob/master/) for further integration testing. This ensures the [stable](https://github.com/reactive-firewall/multicast/blob/stable/) @@ -21,18 +21,18 @@ branch remains acceptable for production use. *** You can find all of the testing code in the aptly named `tests/` directory. -* Unit-testing is primarally done with the `unittest` framework. +* Unit-testing is primarily done with the `unittest` framework. * Functional testing is done via additional checks, including an end-to-end check invoking an actual pair of processes to test that `SAY` and `RECV` indeed work together. -## Dev dependancy Testing: +## Dev Dependency Testing *** ### In a rush to get this module working? Then try using this with your own test: ```bash -#cd /MY-AWSOME-DEV-PATH/multicast +#cd /MY-AWESOME-DEV-PATH/multicast make clean ; # cleans up from any previous tests hopefully make test ; # runs the tests make clean ; # cleans up for next test diff --git a/docs/FAQ.md b/docs/FAQ.md index 4cf1336..61058a6 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -11,7 +11,7 @@ https://github.com/reactive-firewall/multicast/.github/CONTRIBUTING.md ### How do I get this running? -(assuming python3 is setup and installed) +(assuming python3 is set up and installed) ```bash # cd /MY-AWSOME-DEV-PATH @@ -29,18 +29,18 @@ If all went well `multicast` is now installed and working :tada: ### How do I use this to receive some UDP Multicast? -(assuming project is setup and installed and you want to listen on 0.0.0.0) +(assuming project is set up, installed and you want to listen on 0.0.0.0) ```bash # cd /MY-AWSOME-DEV-PATH python3 -m multicast HEAR --use-std --port 59595 --join-mcast-groups 224.0.0.1 --bind-group 224.0.0.1 ``` -Caveat: RCEV is much more usefull if actually used in a loop like: +Caveat: `RCEV` is much more useful if actually used in a loop like: ```bash -# cd /MY-AWSOME-DEV-PATH -while true ; do # unitl user ctl+c inturupts +# cd /MY-AWESOME-DEV-PATH +while true ; do # until user Ctl+C interrupts python3 -m multicast RECV --use-std --port 59595 --join-mcast-groups 224.0.0.1 --bind-group 224.0.0.1 done ``` @@ -48,7 +48,7 @@ done ### How do I use this to send UDP Multicast? -(assuming project is setup and installed) +(assuming `multicast` is set up and installed) ```bash # cd /MY-AWSOME-DEV-PATH @@ -56,7 +56,7 @@ python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello W ``` -### What is the basic API via python (instead of bash like above): +### What is the basic API via python (instead of bash like above)? #### Caveat: this module is still a BETA [Here is how it is tested right now](https://github.com/reactive-firewall/multicast/blob/cdd577549c0bf7c2bcf85d1b857c86135778a9ed/tests/test_usage.py#L251-L554) @@ -68,18 +68,19 @@ from multiprocessing import Process as Process # setup some stuff _fixture_PORT_arg = int(59595) _fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses -_fixture_host_BIND_arg +_fixture_host_BIND_arg = """224.0.0.1""" _fixture_HEAR_args = [ """--port""", _fixture_PORT_arg, """--join-mcast-groups""", _fixture_mcast_GRP_arg, - """--bind-group""", _fixture_mcast_GRP_arg" + """--bind-group""", _fixture_host_BIND_arg ] # spwan a listening proc -def inputHandle() +def inputHandler(): + test_RCEV = multicast.recv.McastRECV() buffer_string = str("""""") - buffer_string += multicast.recv.hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) + buffer_string += test_RCEV._hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) return buffer_string def printLoopStub(func): diff --git a/docs/USAGE.md b/docs/USAGE.md index 920060b..7024eae 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -19,12 +19,12 @@ _fixture_host_BIND_arg _fixture_HEAR_args = [ """--port""", _fixture_PORT_arg, """--join-mcast-groups""", _fixture_mcast_GRP_arg, - """--bind-group""", _fixture_mcast_GRP_arg" + """--bind-group""", _fixture_mcast_GRP_arg ] # spwan a listening proc -def inputHandle() +def inputHandle(): buffer_string = str("""""") buffer_string += multicast.recv.hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) return buffer_string @@ -56,21 +56,22 @@ try: # Hint: use a loop to repeat or different arguments to varry message. except Exception: p.join() - raise RuntimeException("multicast seems to have failed, blah, blah") + raise RuntimeError("Multicast operation failed.") # clean up some stuff p.join() # if not already handled don't forget to join the process and other overhead didWork = (int(p.exitcode) <= int(0)) # if you use a loop and need to know the exit code ``` -#### Caveat: the above examples assume the reader is knowledgeable about general `IPC` theory and the standard python `multiprocessing` module and its use. +### Caveat +The above examples assume the reader is knowledgeable about general `IPC` theory and the standard Python `multiprocessing` module and its use. ## CLI Usage *** -The CLI is actually not the best way to use this kind of library so it should not be considered the full implementation. For testing/prototyping though it is quite convenient, thus I begin with it. +The CLI is actually not the best way to use this kind of library, so it should not be considered the full implementation. For testing and prototyping, though, it is quite convenient; therefore, I begin with it. CLI should work like so: diff --git a/docs/toc.md b/docs/toc.md index dd35542..34d257d 100644 --- a/docs/toc.md +++ b/docs/toc.md @@ -1,13 +1,13 @@ -# Welcome to Multicast' documentation! +# Welcome to Multicast's documentation! ## Quickstart: **Welcome to the Multicast Python Library! Let's get you started quickly.** -**Step 1: Install Python 3** +### Step 1: Install Python 3 * Ensure Python 3 is installed on your system. -**Step 2: Clone the Repository** +### Step 2: Clone the Repository * Open your terminal and run: ```shell @@ -15,21 +15,21 @@ cd multicast ``` -**Step 3: Install the Package** +### Step 3: Install the Package * Run: ```shell make install ``` -**Step 4: Sending Messages** +### Step 4: Sending Messages * Send a message using: ```shell python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello, Multicast!" ``` -**Step 5: Receiving Messages** +### Step 5: Receiving Messages * Receive messages by running: ```shell @@ -40,7 +40,7 @@ -## Contents: +## Contents ```{toctree} :maxdepth: 2 From 0cefdee72300f81e9488f0765758f65cbe82e4b8 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Mon, 16 Sep 2024 23:49:44 -0700 Subject: [PATCH 08/31] [DOCUMENTATION] Apply suggestions from code review (- WIP #110 -) A few more fixes Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/FAQ.md | 6 +++--- docs/toc.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 61058a6..4bc0ac5 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -14,7 +14,7 @@ https://github.com/reactive-firewall/multicast/.github/CONTRIBUTING.md (assuming python3 is set up and installed) ```bash -# cd /MY-AWSOME-DEV-PATH +# cd /MY-AWESOME-DEV-PATH git clone https://github.com/reactive-firewall/multicast.git multicast cd ./multicast git checkout stable @@ -107,10 +107,10 @@ _fixture_SAY_args = [ ] try: multicast.__main__.McastDispatch().doStep("SAY", _fixture_SAY_args) - # Hint: use a loop to repeat or different arguments to varry message. + # Hint: use a loop to repeat or different arguments to vary message. except Exception: p.join() - raise RuntimeException("multicast seems to have failed, blah, blah") + raise RuntimeError("multicast seems to have failed.") # clean up some stuff p.join() # if not already handled don't forget to join the process and other overhead diff --git a/docs/toc.md b/docs/toc.md index 34d257d..4719177 100644 --- a/docs/toc.md +++ b/docs/toc.md @@ -1,6 +1,6 @@ # Welcome to Multicast's documentation! -## Quickstart: +## Quickstart **Welcome to the Multicast Python Library! Let's get you started quickly.** ### Step 1: Install Python 3 From ef3987fbdb2c0a568fa64f165d38ed0e06fc1b29 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 00:14:14 -0700 Subject: [PATCH 09/31] Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- LICENSE.md | 2 +- docs/CI.md | 6 +++--- docs/FAQ.md | 10 +++++----- docs/Makefile | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index e9466c2..b7b1278 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -34,7 +34,7 @@ You may obtain a copy of the License at [MIT License](http://www.github.com/reactive-firewall/python-repo/LICENSE.md) *** -## Third-party Acknowledgments: +## Third-party Acknowledgments * Files: `multicast/send.py` and `multicast/recv.py` *** diff --git a/docs/CI.md b/docs/CI.md index 46dc790..48389dd 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -1,4 +1,4 @@ -# CI: +# CI ## Service providers *** @@ -29,7 +29,7 @@ You can find all of the testing code in the aptly named `tests/` directory. ## Dev Dependency Testing *** -### In a rush to get this module working? Then try using this with your own test: +### In a rush to get this module working? Then try using this with your own test ```bash #cd /MY-AWESOME-DEV-PATH/multicast @@ -38,7 +38,7 @@ make test ; # runs the tests make clean ; # cleans up for next test ``` -#### Use PEP8 to check python code style? Great! Try this: +#### Use PEP8 to check python code style? Great! Try this ```bash make clean ; # cleans up from any previous tests hopefully diff --git a/docs/FAQ.md b/docs/FAQ.md index 4bc0ac5..6ceb1f9 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -36,11 +36,11 @@ If all went well `multicast` is now installed and working :tada: python3 -m multicast HEAR --use-std --port 59595 --join-mcast-groups 224.0.0.1 --bind-group 224.0.0.1 ``` -Caveat: `RCEV` is much more useful if actually used in a loop like: +Caveat: `RECV` is much more useful if actually used in a loop like: ```bash # cd /MY-AWESOME-DEV-PATH -while true ; do # until user Ctl+C interrupts +while true ; do # until user Ctrl+C interrupts python3 -m multicast RECV --use-std --port 59595 --join-mcast-groups 224.0.0.1 --bind-group 224.0.0.1 done ``` @@ -139,8 +139,8 @@ From [RFC-1112 §6.1](https://www.rfc-editor.org/rfc/rfc1112#section-6.1) From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L214-L217): > A Value of 1 (one TTL) is chosen as per [RFC-1112 §6.1](https://www.rfc-editor.org/rfc/rfc1112#section-6.1) on the rational that an -> explicit value that could traverse byond the local connected network should be -> chosen by the caller rather than the default vaule. This is inline with the principle +> explicit value that could traverse beyond the local connected network should be +> chosen by the caller rather than the default value. This is inline with the principle > of none, one or many. #### The default multicast destination port is 59559 @@ -157,7 +157,7 @@ From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1. `0` is the default and implies *success*, and means the process has essentially (or actually) returned nothing (or `None`) -`1` is used when a *single* result is returned (caveat: functions may return a single `tuple` instead of `None` to indicate exit code `1` by returning a `boolean` success value, and result (which may also be encapsulated as an iteratable if needed) ) +`1` is used when a *single* result is returned (caveat: functions may return a single `tuple` instead of `None` to indicate exit code `1` by returning a `boolean` success value, and result (which may also be encapsulated as an iterable if needed) ) `2` is used to indicate a *value and reason* are returned (caveat: functions may return a single `tuple` with a single value and reason and the value can be a `tuple`) diff --git a/docs/Makefile b/docs/Makefile index f55974a..1c7aa1a 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,4 +1,20 @@ +#!/usr/bin/env make -f + # Makefile for Sphinx documentation +# .................................. +# Copyright (c) 2024, Mr. Walls +# .................................. +# Licensed under MIT (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# .......................................... +# http://www.github.com/reactive-firewall/multicast/LICENSE.md +# .......................................... +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # # You can set these variables from the command line. From c96e6963448d152c00f58833c75f22ff7d6bbc68 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 00:27:51 -0700 Subject: [PATCH 10/31] [STYLE] Apply suggestions from code review (- WIP #110 -) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/CI.md | 2 +- docs/FAQ.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CI.md b/docs/CI.md index 48389dd..61005d1 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -9,7 +9,7 @@ Continuous integration testing is handled by GitHub Actions and the generous Cir ## MATs *** -Minimal acceptance testing is run across multiple versions of python to ensure stable behavior +Minimal acceptance testing is run across multiple versions of Python to ensure stable behavior across a wide range of environments. Feature development and non-security related bug fixes are done on development branches and then merged into the [default branch (master)](https://github.com/reactive-firewall/multicast/blob/master/) for further diff --git a/docs/FAQ.md b/docs/FAQ.md index 6ceb1f9..8c06c41 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -32,7 +32,7 @@ If all went well `multicast` is now installed and working :tada: (assuming project is set up, installed and you want to listen on 0.0.0.0) ```bash -# cd /MY-AWSOME-DEV-PATH +# cd /MY-AWESOME-DEV-PATH python3 -m multicast HEAR --use-std --port 59595 --join-mcast-groups 224.0.0.1 --bind-group 224.0.0.1 ``` @@ -140,7 +140,7 @@ From [RFC-1112 §6.1](https://www.rfc-editor.org/rfc/rfc1112#section-6.1) From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L214-L217): > A Value of 1 (one TTL) is chosen as per [RFC-1112 §6.1](https://www.rfc-editor.org/rfc/rfc1112#section-6.1) on the rational that an > explicit value that could traverse beyond the local connected network should be -> chosen by the caller rather than the default value. This is inline with the principle +> chosen by the caller rather than the default value. This is in line with the principle > of none, one or many. #### The default multicast destination port is 59559 From d70813d3b78214847277ee2c937b1ecf93c36688 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 00:36:10 -0700 Subject: [PATCH 11/31] [PATCH] More Fixes Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/CI.md | 2 +- docs/FAQ.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CI.md b/docs/CI.md index 61005d1..538dbd9 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -20,7 +20,7 @@ branch remains acceptable for production use. ## Testing *** -You can find all of the testing code in the aptly named `tests/` directory. +You can find all the testing code in the aptly named `tests/` directory. * Unit-testing is primarily done with the `unittest` framework. * Functional testing is done via additional checks, including an end-to-end check invoking an actual pair of processes to test that `SAY` and `RECV` indeed work together. diff --git a/docs/FAQ.md b/docs/FAQ.md index 8c06c41..0f7a602 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -24,7 +24,7 @@ python3 -m multicast --help ; ``` #### DONE -If all went well `multicast` is now installed and working :tada: +If all went well, `multicast` is now installed and working :tada: ### How do I use this to receive some UDP Multicast? @@ -167,7 +167,7 @@ From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1. `0` *success* -`1` *none-sucsess* - and is often accompanied by warnings or errors +`1` *non-success* - and is often accompanied by warnings or errors `2 >` *failure* of specific reason From decc2980b51d820cba7a690098d446ca95bba2d6 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 14:08:38 -0700 Subject: [PATCH 12/31] [DOCUMENTATION] CI documentation tweaks (- WIP #110 -) ### ChangeLog: Changes in file docs/CI.md: # CI ## Testing --- docs/CI.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/docs/CI.md b/docs/CI.md index 538dbd9..3428174 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -5,6 +5,9 @@ Continuous integration testing is handled by GitHub Actions and the generous CircleCI service. +[![CircleCI](https://dl.circleci.com/insights-snapshot/gh/reactive-firewall/multicast/master/workflow/badge.svg?window=30d)](https://app.circleci.com/insights/github/reactive-firewall/multicast/workflows/workflow/overview?branch=master&reporting-window=last-90-days&insights-snapshot=true) +[![DeepSource](https://app.deepsource.com/gh/reactive-firewall/multicast.svg/?label=active+issues&show_trend=true&token=SZUDMH7AtX399xLmONFAkiD6)](https://app.deepsource.com/gh/reactive-firewall/multicast/) + ## MATs *** @@ -16,6 +19,49 @@ done on development branches and then merged into the integration testing. This ensures the [stable](https://github.com/reactive-firewall/multicast/blob/stable/) branch remains acceptable for production use. +```mermaid +gitGraph + commit id:start + branch master + checkout master + commit + commit + branch stable + commit + checkout stable + merge master + checkout master + branch develop + checkout develop + commit + branch develop-nest + checkout develop-nest + commit + commit + checkout master + branch develop-B + checkout develop-B + commit + checkout master + branch develop-C + checkout develop-C + commit + commit + checkout develop + merge develop-nest + checkout develop-C + commit + checkout master + merge develop + merge develop-B + merge develop-C + commit + checkout stable + merge master + checkout master + commit +``` + ## Testing *** @@ -29,10 +75,10 @@ You can find all the testing code in the aptly named `tests/` directory. ## Dev Dependency Testing *** -### In a rush to get this module working? Then try using this with your own test +### In a rush to get this module working? Then try using this in your own test workflow ```bash -#cd /MY-AWESOME-DEV-PATH/multicast +#cd /MY-AWESOME-DEV-PATH/multicast || git clone ... make clean ; # cleans up from any previous tests hopefully make test ; # runs the tests make clean ; # cleans up for next test @@ -42,12 +88,11 @@ make clean ; # cleans up for next test ```bash make clean ; # cleans up from any previous tests hopefully -make test-style ; # runs the tests +make test-style ; # runs the tests for style make clean ; # cleans up for next test ``` -_draft_ ---- +*** #### Copyright (c) 2021-2024, Mr. Walls -[License - MIT](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md) +[MIT License](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md) From d66b9bf696a1a56132627fb713b75839059d79e7 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 14:15:52 -0700 Subject: [PATCH 13/31] Apply MORE suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/FAQ.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 0f7a602..05a49b6 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -51,7 +51,7 @@ done (assuming `multicast` is set up and installed) ```bash -# cd /MY-AWSOME-DEV-PATH +# cd /MY-AWESOME-DEV-PATH python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello World!" ``` @@ -75,7 +75,7 @@ _fixture_HEAR_args = [ """--bind-group""", _fixture_host_BIND_arg ] -# spwan a listening proc +# spawn a listening proc def inputHandler(): test_RCEV = multicast.recv.McastRECV() From 24f4f6042341eb4293974f0eeef68156744032d4 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 14:34:17 -0700 Subject: [PATCH 14/31] [STYLE] Refactored some unrelated code for style compliance (- WIP #53 -) Changes in file tests/context.py: * added line breaks to long lines Changes in file tests/test_deps.py: * added line breaks to long lines * tweaked indentation This should satisfy codecov testing failures. * This is a trivial change and mostly unrelated to the rest of PR #110 --- tests/context.py | 15 +++++++++++---- tests/test_deps.py | 15 +++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/context.py b/tests/context.py index 2ab7c9a..cee000e 100644 --- a/tests/context.py +++ b/tests/context.py @@ -268,7 +268,7 @@ def checkCovCommand(args=[None]): >>> import tests.context as context >>> - Testcase 1: Function should return unmodified arguments if 'coverage' is not in the first argument. + Testcase 1: Function should return unmodified arguments if 'coverage' is missing. >>> context.checkCovCommand(["python", "script.py"]) ['python', 'script.py'] @@ -430,20 +430,27 @@ def checkPythonCommand(args, stderr=None): Testcase 2: Function should capture stderr when specified. >>> import subprocess - >>> test_args_2 = [str(sys.executable), '-c', 'import sys; print("Error", file=sys.stderr)'] + >>> test_args_2 = [ + ... str(sys.executable), '-c', 'import sys; print("Error", file=sys.stderr)' + ... ] + >>> >>> tests.context.checkPythonCommand(test_args_2, stderr=subprocess.STDOUT) 'Error\\n' Testcase 3: Function should handle exceptions and return output. >>> test_fixture_e = [str(sys.executable), '-c', 'raise ValueError("Test error")'] - >>> tests.context.checkPythonCommand(test_fixture_e, stderr=subprocess.STDOUT) #doctest: +ELLIPSIS + >>> tests.context.checkPythonCommand( + ... test_fixture_e, stderr=subprocess.STDOUT + ... ) #doctest: +ELLIPSIS 'Traceback (most recent call last):\\n...ValueError...' Testcase 4: Function should return the output as a string. >>> test_fixture_s = [str(sys.executable), '-c', 'print(b"Bytes output")'] - >>> isinstance(tests.context.checkPythonCommand(test_fixture_s, stderr=subprocess.STDOUT), str) + >>> isinstance(tests.context.checkPythonCommand( + ... test_fixture_s, stderr=subprocess.STDOUT + ... ), str) True diff --git a/tests/test_deps.py b/tests/test_deps.py index ec57089..796a7f2 100644 --- a/tests/test_deps.py +++ b/tests/test_deps.py @@ -54,7 +54,7 @@ class TestRequirementsTxt(context.BasicUsageTestSuite): """Test cases for 'tests/requirements.txt'.""" - + __module__ = """tests.test_deps""" def test_requirements_file_exists(self): @@ -81,14 +81,17 @@ def test_requirements_format(self): line, pattern, str("""Invalid requirement format at line {line_number}: '{line}'""").format( - line_number=line_number, line=line - ) + line_number=line_number, line=line + ) ) - @unittest.skipUnless((_sys.platform.startswith("linux") or - _sys.platform.startswith("darwin")), "This test is not supported on OS.") + @unittest.skipUnless( + ( + _sys.platform.startswith("linux") or _sys.platform.startswith("darwin") + ), "This test is not supported on this OS." + ) def test_requirements_installation(self): - """Attempt to install dependencies from 'tests/requirements.txt' in a virtual environment.""" + """Attempt to install dependencies from 'tests/requirements.txt' in a virtual env.""" env_dir = 'test_env' builder = venv.EnvBuilder(with_pip=True) builder.create(env_dir) From 467473f1949cd9c74544dae7a7e66149fc1b3ea1 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 14:50:19 -0700 Subject: [PATCH 15/31] [DOCUMENTATION] Clearified setup the label from 'set up' the words (- WIP #79 -) Changes in file .circleci/config.yml: * Corrected 'setup' with 'set up' as needed Changes in file .github/workflows/Tests.yml: * Corrected 'setup' with 'set up' as needed Changes in file docs/FAQ.md: * Corrected 'setup' with 'set up' as needed Changes in file docs/USAGE.md: * Corrected 'setup' with 'set up' as needed Changes in file multicast/__init__.py: * Corrected 'setup' with 'set up' as needed Changes in file multicast/__main__.py: * Corrected 'setup' with 'set up' as needed Changes in file multicast/hear.py: * Corrected 'setup' with 'set up' as needed Changes in file multicast/recv.py: * Corrected 'setup' with 'set up' as needed Changes in file multicast/send.py: * Corrected 'setup' with 'set up' as needed Changes in file multicast/skt.py: * Corrected 'setup' with 'set up' as needed Changes in file setup.py: * Corrected 'setup' with 'set up' as needed Changes in file tests/MulticastUDPClient.py: * Corrected 'setup' with 'set up' as needed Changes in file tests/context.py: * Corrected 'setup' with 'set up' as needed --- .circleci/config.yml | 2 +- .github/workflows/Tests.yml | 18 +++++++++--------- docs/FAQ.md | 2 +- docs/USAGE.md | 2 +- multicast/__init__.py | 26 +++++++++++++------------- multicast/__main__.py | 12 ++++++------ multicast/hear.py | 14 +++++++------- multicast/recv.py | 18 +++++++++--------- multicast/send.py | 12 ++++++------ multicast/skt.py | 12 ++++++------ setup.py | 4 ++-- tests/MulticastUDPClient.py | 2 +- tests/context.py | 24 ++++++++++++------------ 13 files changed, 74 insertions(+), 74 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4518d46..54392e5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -109,7 +109,7 @@ jobs: key: v1-repo-{{ .Environment.CIRCLE_SHA1 }} - run: shell: /bin/bash - name: "setup depends" + name: "set up depends" command: | python3 -m pip install --upgrade --user -r ./requirements.txt || : ; when: on_success diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 67163d5..919e3ee 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -87,11 +87,11 @@ jobs: LANG: ${{ matrix.lang-var }} steps: - uses: actions/checkout@v4 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Setup dependencies + - name: Set up dependencies run: | pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "build>=1.0.1"; pip install -r ./requirements.txt ; @@ -145,7 +145,7 @@ jobs: LANG: "en_US.utf-8" steps: - uses: actions/checkout@v4 - - name: Setup Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -193,7 +193,7 @@ jobs: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} steps: - uses: actions/checkout@v4 - - name: Setup Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -275,7 +275,7 @@ jobs: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} steps: - uses: actions/checkout@v4 - - name: Setup Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -349,7 +349,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.10" @@ -393,7 +393,7 @@ jobs: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} steps: - uses: actions/checkout@v4 - - name: Setup Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -490,7 +490,7 @@ jobs: CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_TOKEN }} steps: - uses: actions/checkout@v4 - - name: Setup Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -551,7 +551,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.12" diff --git a/docs/FAQ.md b/docs/FAQ.md index 05a49b6..496e660 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -65,7 +65,7 @@ python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello W import multicast as multicast from multiprocessing import Process as Process -# setup some stuff +# set up some stuff _fixture_PORT_arg = int(59595) _fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses _fixture_host_BIND_arg = """224.0.0.1""" diff --git a/docs/USAGE.md b/docs/USAGE.md index 7024eae..86e4516 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -12,7 +12,7 @@ Here is an example of usage (circa v1.4) import multicast as multicast from multiprocessing import Process as Process -# setup some stuff +# set up some stuff _fixture_PORT_arg = int(59595) _fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses _fixture_host_BIND_arg diff --git a/multicast/__init__.py b/multicast/__init__.py index a318ddc..534ba99 100644 --- a/multicast/__init__.py +++ b/multicast/__init__.py @@ -33,7 +33,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast as _multicast >>> @@ -50,7 +50,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast as _multicast >>> @@ -67,7 +67,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast as _multicast >>> @@ -86,7 +86,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast as _multicast >>> @@ -107,7 +107,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> @@ -161,7 +161,7 @@ Minimal Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> @@ -210,7 +210,7 @@ Minimal Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> @@ -239,7 +239,7 @@ Minimal Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> @@ -269,7 +269,7 @@ Minimal Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> _BLANK = multicast._BLANK @@ -348,7 +348,7 @@ class mtool(abc.ABC): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.mtool is not None @@ -375,7 +375,7 @@ def buildArgs(cls, calling_parser_group): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.mtool is not None @@ -447,7 +447,7 @@ def parseArgs(cls, arguments=None): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.mtool is not None @@ -499,7 +499,7 @@ def checkToolArgs(cls, args): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> diff --git a/multicast/__main__.py b/multicast/__main__.py index 8f0838d..c8670ac 100644 --- a/multicast/__main__.py +++ b/multicast/__main__.py @@ -21,7 +21,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast as multicast >>> @@ -158,7 +158,7 @@ class McastNope(mtool): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast.__main__ as _multicast >>> _multicast.McastNope is not None @@ -228,7 +228,7 @@ def NoOp(*args, **kwargs): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast.__main__ >>> @@ -264,7 +264,7 @@ class McastRecvHearDispatch(mtool): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast.__main__ as _multicast >>> _multicast.McastNope is not None @@ -334,7 +334,7 @@ def setupArgs(cls, parser): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.hear is not None @@ -541,7 +541,7 @@ def main(*argv): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.send is not None diff --git a/multicast/hear.py b/multicast/hear.py index e9ed046..f5284e7 100644 --- a/multicast/hear.py +++ b/multicast/hear.py @@ -21,7 +21,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -95,7 +95,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -119,7 +119,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -144,7 +144,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -203,7 +203,7 @@ class McastServer(socketserver.UDPServer): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -262,7 +262,7 @@ class MyUDPHandler(socketserver.BaseRequestHandler): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -328,7 +328,7 @@ class McastHEAR(multicast.mtool): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.hear is not None diff --git a/multicast/recv.py b/multicast/recv.py index 658fecd..4a0d769 100644 --- a/multicast/recv.py +++ b/multicast/recv.py @@ -34,7 +34,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -108,7 +108,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -132,7 +132,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -157,7 +157,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -215,7 +215,7 @@ def joinstep(groups, port, iface=None, bind_group=None, isock=None): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.recv is not None @@ -281,7 +281,7 @@ def tryrecv(msgbuffer, chunk, sock): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.recv is not None @@ -339,7 +339,7 @@ class McastRECV(multicast.mtool): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.recv is not None @@ -394,7 +394,7 @@ def setupArgs(cls, parser): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.recv is not None @@ -472,7 +472,7 @@ def _hearstep(groups, port, iface=None, bind_group=None): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.recv is not None diff --git a/multicast/send.py b/multicast/send.py index 361a231..848b7e0 100644 --- a/multicast/send.py +++ b/multicast/send.py @@ -35,7 +35,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -71,7 +71,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -95,7 +95,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -120,7 +120,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -172,7 +172,7 @@ class McastSAY(multicast.mtool): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.send is not None @@ -217,7 +217,7 @@ def setupArgs(cls, parser): Testing: - Testcase 0: First setup test fixtures by importing multicast. + Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.send is not None diff --git a/multicast/skt.py b/multicast/skt.py index 2dde40b..abb6a5f 100644 --- a/multicast/skt.py +++ b/multicast/skt.py @@ -36,7 +36,7 @@ Minimal Acceptance Testing: -First setup test fixtures by importing multicast. +First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -85,7 +85,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -109,7 +109,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -134,7 +134,7 @@ Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. Testcase 0: Multicast should be importable. @@ -170,7 +170,7 @@ def genSocket(): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.__doc__ is not None @@ -214,7 +214,7 @@ def endSocket(sock=None): Minimal Acceptance Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> multicast.__doc__ is not None diff --git a/setup.py b/setup.py index 50efdee..2633b4e 100755 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ Minimal Acceptance Testing: - Testcase 0: Just setup test fixtures by importing multicast. + Testcase 0: Just set up test fixtures by importing multicast. >>> import multicast >>> @@ -55,7 +55,7 @@ def readFile(filename): Testing: - First setup test fixtures by importing multicast. + First set up test fixtures by importing multicast. >>> import multicast >>> diff --git a/tests/MulticastUDPClient.py b/tests/MulticastUDPClient.py index a8f5df0..1f257a1 100644 --- a/tests/MulticastUDPClient.py +++ b/tests/MulticastUDPClient.py @@ -145,7 +145,7 @@ def __init__(self, *args, **kwargs): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.MulticastUDPClient as MulticastUDPClient >>> from MulticastUDPClient import MCastClient as MCastClient diff --git a/tests/context.py b/tests/context.py index cee000e..6b0c293 100644 --- a/tests/context.py +++ b/tests/context.py @@ -113,7 +113,7 @@ Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context as _context >>> @@ -142,7 +142,7 @@ def getCoverageCommand(): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context as context >>> @@ -178,7 +178,7 @@ def __check_cov_before_py(): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context >>> @@ -222,7 +222,7 @@ def getPythonCommand(): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context >>> @@ -263,7 +263,7 @@ def checkCovCommand(args=[None]): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context as context >>> @@ -340,7 +340,7 @@ def checkStrOrByte(theInput): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context as _context >>> @@ -416,7 +416,7 @@ def checkPythonCommand(args, stderr=None): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context >>> @@ -505,7 +505,7 @@ def debugBlob(blob=None): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context >>> @@ -571,7 +571,7 @@ def debugtestError(someError): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context >>> @@ -646,7 +646,7 @@ def debugUnexpectedOutput(expectedOutput, actualOutput, thepython): Meta Testing: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context >>> @@ -716,7 +716,7 @@ class BasicUsageTestSuite(unittest.TestCase): Meta Tests - Creation: - First setup test fixtures by importing test context. + First set up test fixtures by importing test context. >>> import tests.context >>> @@ -742,7 +742,7 @@ class BasicUsageTestSuite(unittest.TestCase): @classmethod def setUpClass(cls): - """Overides unittest.TestCase.setUpClass(cls) to setup thepython test fixture.""" + """Overides unittest.TestCase.setUpClass(cls) to set up thepython test fixture.""" cls._thepython = getPythonCommand() def setUp(self): From 50ca4920cdad81f7d7764da4d7a21968a2be9724 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 14:56:42 -0700 Subject: [PATCH 16/31] [STYLE] added Copyright line to source docs (- WIP #110 -) Changes in file docs/FAQ.md: * added copyright Changes in file docs/USAGE.md: * added copyright --- docs/FAQ.md | 5 +++++ docs/USAGE.md | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/docs/FAQ.md b/docs/FAQ.md index 496e660..80861c3 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -176,3 +176,8 @@ From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1. _(extra exit code meanings)_ Other codes (such as `126`) may or may not have meanings (such as skip) but are not handled within the scope of the Multicast Project at this time. + + +*** +#### Copyright (c) 2021-2024, Mr. Walls +[MIT License](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md) diff --git a/docs/USAGE.md b/docs/USAGE.md index 86e4516..f854167 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -99,3 +99,8 @@ The `HEAR` command is used to send data acknowledged messages via "HEAR" message * While mostly a testing function it is possible to use `HEAR` as a proxy for other send/recv instances by using the `--daemon` flag * Note: this will use the same port for sends and receives and can lead to data loss if less than two groups are used. * If more than one group is used via the `--groups` flag then all but the bind group (via `--group`) will be echoed to the bind group. + + +*** +#### Copyright (c) 2021-2024, Mr. Walls +[MIT License](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md) From 8f12b753a7b89b39030f676b142fb6cafa598832 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 16:34:19 -0700 Subject: [PATCH 17/31] Update docs/USAGE.md Correct for code that was refactored Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/USAGE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index f854167..9aabb09 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -25,10 +25,10 @@ _fixture_HEAR_args = [ # spwan a listening proc def inputHandle(): + test_RCEV = multicast.recv.McastRECV() buffer_string = str("""""") - buffer_string += multicast.recv.hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) + buffer_string += test_RCEV._hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) return buffer_string - def printLoopStub(func): for i in range( 0, 5 ): print( str( func() ) ) From 4a01fa5956ed59d031e551ffb145bf6466469f59 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 17:09:22 -0700 Subject: [PATCH 18/31] [TESTING] Re-enabling test blocking for style and adding docs/requirements.txt to CI (- WIP #110 -) Changes in file .github/workflows/Tests.yml: * added documentation requirements (- WIP #53 -) Changes in file Makefile: * re-enabled blocking on failure Changes in file tox.ini: * added use of docs/requirements.txt --- .github/workflows/Tests.yml | 8 ++++++++ Makefile | 6 +++++- tox.ini | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 919e3ee..b5ef38d 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -154,6 +154,7 @@ jobs: pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "build>=1.0.1"; pip install -r ./requirements.txt ; pip install -r ./tests/requirements.txt || true ; + pip install --upgrade -r ./docs/requirements.txt || true ; - name: Pre-Clean id: clean run: make -j1 -f Makefile clean || true ; @@ -191,6 +192,7 @@ jobs: COV_CORE_DATAFILE: ./coverage.xml CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_TOKEN }} CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + DEEPSOURCE_DSN: ${{ DEEPSOURCE_DSN }} steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -202,6 +204,7 @@ jobs: pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "build>=1.0.1"; pip install -r ./requirements.txt ; pip install -r ./tests/requirements.txt || true ; + pip install --upgrade -r ./docs/requirements.txt || true ; - name: Install code-climate tools for ${{ matrix.python-version }} if: ${{ runner.os }} == "Linux" shell: bash @@ -273,6 +276,7 @@ jobs: COV_CORE_DATAFILE: ./coverage.xml CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_TOKEN }} CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + DEEPSOURCE_DSN: ${{ DEEPSOURCE_DSN }} steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -284,6 +288,7 @@ jobs: pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "build>=1.0.1"; pip install --upgrade -r ./requirements.txt ; pip install --upgrade -r ./tests/requirements.txt || true ; + pip install --upgrade -r ./docs/requirements.txt || true ; - name: Install code-climate tools for ${{ matrix.python-version }} if: ${{ runner.os }} == "Linux" shell: bash @@ -358,6 +363,7 @@ jobs: pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "build>=1.0.1"; pip install --upgrade -r ./requirements.txt ; pip install --upgrade -r ./tests/requirements.txt || true ; + pip install --upgrade -r ./docs/requirements.txt || true ; - name: Pre-Clean id: clean run: make -j1 -f Makefile clean || true ; @@ -402,6 +408,7 @@ jobs: pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "build>=1.0.1"; pip install --upgrade -r ./requirements.txt ; pip install --upgrade -r ./tests/requirements.txt || true ; + pip install --upgrade -r ./docs/requirements.txt || true ; - name: Install code-climate tools for ${{ matrix.python-version }} if: ${{ runner.os }} != "Linux" run: | @@ -564,6 +571,7 @@ jobs: pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "build>=1.0.1"; pip install --upgrade -r ./requirements.txt ; pip install --upgrade -r ./tests/requirements.txt || true ; + pip install --upgrade -r ./docs/requirements.txt || true ; - name: Pre-Clean id: clean run: make -j1 -f Makefile clean || true ; diff --git a/Makefile b/Makefile index 6ad6791..efbf804 100644 --- a/Makefile +++ b/Makefile @@ -173,6 +173,7 @@ purge: clean uninstall test: cleanup $(QUIET)$(COVERAGE) run -p --source=multicast -m unittest discover --verbose --buffer -s ./tests -t $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) || $(PYTHON) -m unittest discover --verbose --buffer -s ./tests -t ./ || DO_FAIL="exit 2" ; + $(QUITE)$(WAIT) ; $(QUIET)$(DO_FAIL) ; $(QUIET)$(COVERAGE) combine 2>$(ERROR_LOG_PATH) || : ; $(QUIET)$(COVERAGE) report -m --include=* 2>$(ERROR_LOG_PATH) || : ; @@ -193,11 +194,14 @@ test-reqs: test-reports init test-pytest: cleanup must_have_pytest test-reports $(QUIET)$(PYTHON) -m pytest --cache-clear --doctest-glob=multicast/*.py,tests/*.py --doctest-modules --cov=. --cov-append --cov-report=xml --junitxml=test-reports/junit.xml -v --rootdir=. || DO_FAIL="exit 2" ; + $(QUITE)$(WAIT) ; $(QUIET)$(DO_FAIL) ; $(QUIET)$(ECHO) "$@: Done." test-style: cleanup must_have_flake - $(QUIET)$(PYTHON) -m flake8 --ignore=W191,W391 --max-line-length=100 --verbose --count --config=.flake8.ini --show-source || true + $(QUIET)$(PYTHON) -m flake8 --ignore=W191,W391 --max-line-length=100 --verbose --count --config=.flake8.ini --show-source || DO_FAIL="exit 2" ; + $(QUITE)$(WAIT) ; + $(QUIET)$(DO_FAIL) ; $(QUIET)tests/check_spelling || true $(QUIET)tests/check_cc_lines || true $(QUIET)$(ECHO) "$@: Done." diff --git a/tox.ini b/tox.ini index 1c45f98..eee252f 100644 --- a/tox.ini +++ b/tox.ini @@ -22,6 +22,7 @@ passenv = deps = -r{toxinidir}/requirements.txt -r{toxinidir}/tests/requirements.txt + -r{toxinidir}/docs/requirements.txt [testenv:py{27,33,34,35,36,37,38,39,310.311,312,313}] @@ -531,7 +532,7 @@ commands = flake8 --ignore=W191,W391 --verbose --max-line-length=100 --count description = Documentation Tests whitelist_externals = make deps = - docs: sphinx>=1.6.3 + docs: sphinx>=5.2 flake8>=2.5.4 mccabe>=0.6.1 pyflakes>=1.1.0 @@ -540,6 +541,8 @@ deps = {[base]deps} commands = - make -s -C ./docs/ -f Makefile clean + - make -s -C ./docs/ -f Makefile html + - make -s -C ./docs/ -f Makefile clean [coverage:run] From 83e03d201f73f61e21b1181de688bbd83d816a4f Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 19:02:08 -0700 Subject: [PATCH 19/31] [TESTING] Fixup for CI env where documentation gaps caused failures (- FIX #110 -) Changes in file Makefile: * seperated out doc dependencies into own target * added workaround for version already installed hanging pip Changes in file docs/conf.py: * changed import logic to work around a bug that breaks CI if some doc/requirements were missing. :tada: incoming CI stability --- Makefile | 9 +++++---- docs/conf.py | 9 ++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index efbf804..f890e5d 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ endif ifndef PIP_COMMON_FLAGS # Define common pip install flags - PIP_COMMON_FLAGS := --use-pep517 --upgrade --upgrade-strategy eager + PIP_COMMON_FLAGS := --use-pep517 --exists-action s --upgrade --upgrade-strategy eager endif # Define environment-specific pip install flags @@ -191,6 +191,9 @@ test-reports: test-reqs: test-reports init $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r tests/requirements.txt 2>$(ERROR_LOG_PATH) || true +docs-reqs: ./docs/ ./docs/requirements.txt init + $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r docs/requirements.txt 2>$(ERROR_LOG_PATH) || : ; + $(QUIET)$(WAIT) ; test-pytest: cleanup must_have_pytest test-reports $(QUIET)$(PYTHON) -m pytest --cache-clear --doctest-glob=multicast/*.py,tests/*.py --doctest-modules --cov=. --cov-append --cov-report=xml --junitxml=test-reports/junit.xml -v --rootdir=. || DO_FAIL="exit 2" ; @@ -258,9 +261,7 @@ cleanup: $(QUIET)$(RMDIR) ./.tox/ 2>$(ERROR_LOG_PATH) || true $(QUIET)$(WAIT) ; -build-docs: ./docs/ ./docs/Makefile ./docs/requirements.txt - $(QUIET)$(PYTHON) -m pip install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r ./docs/requirements.txt 2>$(ERROR_LOG_PATH) || : ; - $(QUIET)$(WAIT) ; +build-docs: ./docs/ ./docs/Makefile docs-reqs $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile html 2>$(ERROR_LOG_PATH) || DO_FAIL="exit 2" ; $(QUIET)$(WAIT) ; $(QUIET)mkdir $(INST_OPTS) ./docs/www 2>$(ERROR_LOG_PATH) >$(ERROR_LOG_PATH) || : ; diff --git a/docs/conf.py b/docs/conf.py index 1f056f6..b2f4dd0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,7 +15,6 @@ import sys import os -from sphinxawesome_theme.postprocess import Icons # 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 @@ -177,8 +176,12 @@ # pixels large. # html_favicon = None -#html_permalinks_icon = "#" -html_permalinks_icon = Icons.permalinks_icon +try: + import sphinxawesome_theme + from sphinxawesome_theme.postprocess import Icons + html_permalinks_icon = Icons.permalinks_icon +except Exception: + html_permalinks_icon = "#" # 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, From 8ab47e0f65090c4bb94d7d0d95eee26f3ad6f993 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 21:42:22 -0700 Subject: [PATCH 20/31] [UPGRADE] fixed spellcheck tool (- WIP #111 -) Changes in file tests/check_spelling: * Overhauled as per #111 :tada: --- tests/check_spelling | 127 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 103 insertions(+), 24 deletions(-) diff --git a/tests/check_spelling b/tests/check_spelling index ba94dcd..ec9021c 100755 --- a/tests/check_spelling +++ b/tests/check_spelling @@ -59,45 +59,124 @@ # the amount of five dollars ($5.00). The foregoing limitations will apply # even if the above stated remedy fails of its essential purpose. ################################################################################ +# +# This script attempts to enforce spell-checking if the codespell tool is available. +# It accomplishes the following tasks: +# 1. Sets up error handling and cleanup mechanisms to ensure proper execution. +# 2. Determines the test root directory based on the project structure. +# 3. lint and check spelling +# 4. cleanup and report +# +# Usage Summary: +# To lint the project without making changes: +# ./tests/check_spelling +# To lint and auto-correct spelling errors: +# ./tests/check_spelling --fix +# +# Exit Code Summary: +# The script uses the EXIT_CODE variable to track exit conditions: +# - 0: Successful execution. +# - 1: General failure. +# - 2: Coverage combine or XML generation failed. +# - 3: git ls-tree command failed. +# - 40: Missing valid repository or source structure. +# - 126: Script already in progress or command not executable. +# - 129: Received SIGHUP signal. +# - 130: Received SIGINT signal (Ctrl+C). +# - 131: Received SIGQUIT signal. +# - 137: Received SIGABRT signal. +# - 143: Received SIGTERM signal. +# +# The primary goal is to allow linter like spell-checking. ulimit -t 600 -PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" +# setting the path may break brain-dead CI that uses crazy paths +# PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" umask 137 -LOCK_FILE="${TMPDIR:-/tmp}/spelling_test_script_lock" +# force utf-8 for spelling +export LC_CTYPE="${LC_CTYPE:-'en_US.UTF-8'}" + +LOCK_FILE="${TMPDIR:-/tmp}/org.pak.multicast.spell-check-shell" EXIT_CODE=1 -# exit fast if command is missing -test -x /usr/bin/spellintian || exit 126 ; +test -x $(command -v grep) || exit 126 ; +test -x $(command -v python3) || exit 126 ; +test -x $(command -v git) || exit 126 ; +hash -p ./.github/tool_shlock_helper.sh shlock || exit 255 ; +test -x "$(command -v shlock)" || exit 126 ; +test -x $(command -v codespell) || exit 126 ; + +# Set codespell options +CODESPELL_OPTIONS="--quiet-level=4 --builtin clear,rare,code -L assertIn" + +function cleanup() { + rm -f ${LOCK_FILE} 2>/dev/null || : ; wait ; + # unset when done + unset LOCK_FILE 2>/dev/null || : ; + hash -d shlock 2>/dev/null || : ; +} if [[ ( $(shlock -f ${LOCK_FILE} -p $$ ) -eq 0 ) ]] ; then EXIT_CODE=0 - trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 129 ;' SIGHUP || EXIT_CODE=129 - trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143 - trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 131 ;' SIGQUIT || EXIT_CODE=131 + trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 129 ;' SIGHUP || EXIT_CODE=129 + trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143 + trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 131 ;' SIGQUIT || EXIT_CODE=131 # SC2173 - https://github.com/koalaman/shellcheck/wiki/SC2173 - #trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 1 ;' SIGSTOP || EXIT_CODE=7 - trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 130 ;' SIGINT || EXIT_CODE=130 - trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true || true ; wait ; exit 137 ;' SIGABRT || EXIT_CODE=137 - trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1 + #trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGSTOP || EXIT_CODE=7 + trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 130 ;' SIGINT || EXIT_CODE=130 + trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true || true ; wait ; exit 137 ;' SIGABRT || EXIT_CODE=137 + trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1 else - echo Test already in progress by `head ${LOCK_FILE}` ; - false ; - exit 126 ; + # shellcheck disable=SC2046 + printf "\t%s\n" "Check Setup Scripts Tests Coverage already in progress by "$(head "${LOCK_FILE}") >&2 ; + exit 126 ; fi +# this is how test files are found: + # THIS IS THE ACTUAL TEST -THE_TEMP_FILE="/tmp/swapfile_spellcheck_${RANDOM}.tmp.txt" ; -( (spellintian "${@:-./**/*}" 2>/dev/null | fgrep -v "(duplicate word)" | fgrep " -> ") & (spellintian "${@:-./*}" 2>/dev/null | fgrep -v "(duplicate word)" | fgrep " -> ") & (spellintian "${@:-./**/**/*}" 2>/dev/null | fgrep -v "(duplicate word)" | fgrep " -> ") ) | sort -h | uniq | tee -a ${THE_TEMP_FILE:-/dev/null} ; -wait ; -THECOUNT=$( (wc -l ${THE_TEMP_FILE} 2>/dev/null || echo 0) | cut -d\ -f 1 ) ; -EXIT_CODE=${THECOUNT} ; -if [[ ("${THECOUNT}" -le 1) ]] ; then - EXIT_CODE=0 ; - echo "OK: Found no detected spelling errors." ; +_TEST_ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null) ; +if [[ -d ../.git ]] ; then + _TEST_ROOT_DIR="../" ; +elif [[ -d ./.git ]] ; then + _TEST_ROOT_DIR=$(pwd) ; +elif [[ ( -d $(git rev-parse --show-toplevel 2>/dev/null) ) ]] ; then + _TEST_ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null) ; else - echo "FAIL: Found ${THECOUNT:-many} spelling errors." ; + printf "\t%s\n" "FAIL: missing valid repository or source structure" >&2 ; + EXIT_CODE=40 fi -rm -f ${THE_TEMP_FILE} 2>/dev/null >> /dev/null || true ; + +# Get a list of files to check using git ls-tree with filtering +FILES_TO_CHECK=$(git ls-tree -r --full-tree --name-only HEAD -- *.md *.py *.txt **/*.md **/*.txt **/*.py 2>/dev/null || EXIT_CODE=3) + +# Enable auto-correction if '--fix' argument is provided +if [[ "$1" == "--fix" ]]; then + CODESPELL_OPTIONS="--write-changes --interactive 2 ${CODESPELL_OPTIONS}" + printf "%s\n" "Auto-correction enabled." +fi + +# THIS IS THE ACTUAL TEST +# Iterate over files and run codespell +for FILE in $FILES_TO_CHECK; do + printf "%s\n" "Checking ${FILE}" ; + { codespell $CODESPELL_OPTIONS "${FILE}" || EXIT_CODE=$? ;} 2>/dev/null ; wait ; +done + +# cleaning up and reporting + +if [[ ("${EXIT_CODE}" -eq 0) ]] ; then + printf "%s\n" "OK: Found no detected spelling errors." ; +else + printf "%s\n" "FAIL: Found spelling errors." ; +fi + +cleanup || rm -f ${LOCK_FILE} 2>/dev/null || : ; + +# unset when done +unset _TEST_ROOT_DIR 2>/dev/null || : ; +unset CODESPELL_OPTIONS 2>/dev/null || : ; + wait ; exit ${EXIT_CODE:255} ; From da0a7fd5ac0b456871ba81f2d3672b66288aa23a Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 21:43:46 -0700 Subject: [PATCH 21/31] [TESTING] fixup for CI with deepsource coverage (- WIP #110 -) Changes in file .github/workflows/Tests.yml: * fixed a typo --- .github/workflows/Tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index b5ef38d..1dea0dc 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -192,7 +192,7 @@ jobs: COV_CORE_DATAFILE: ./coverage.xml CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_TOKEN }} CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - DEEPSOURCE_DSN: ${{ DEEPSOURCE_DSN }} + DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -276,7 +276,7 @@ jobs: COV_CORE_DATAFILE: ./coverage.xml CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_TOKEN }} CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - DEEPSOURCE_DSN: ${{ DEEPSOURCE_DSN }} + DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} From 1d5900fd02a7bceb1fe3e7e1a87a4838a033c1d5 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 21:45:06 -0700 Subject: [PATCH 22/31] [TESTS] used new tests/check_spelling tool to auto-fix spelling in test files (- WIP #110 & #111 -) Changes in file tests/MulticastUDPClient.py: * corrected some spelling, should be a better read Changes in file tests/context.py: * corrected some spelling, should be a better read Changes in file tests/test_usage.py: * corrected some spelling, should be a better read --- tests/MulticastUDPClient.py | 2 +- tests/context.py | 10 +++++----- tests/test_usage.py | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/MulticastUDPClient.py b/tests/MulticastUDPClient.py index 1f257a1..29cb3ad 100644 --- a/tests/MulticastUDPClient.py +++ b/tests/MulticastUDPClient.py @@ -87,7 +87,7 @@ class MCastClient(object): # skipcq: PYL-R0205 """For use as a test fixture. A trivial implementation of a socket-based object with a function named say. The say function of this class performs a send and recv on a given socket and - then prints out simple diognostics about the content sent and any response recived. + then prints out simple diognostics about the content sent and any response received. Testing: diff --git a/tests/context.py b/tests/context.py index 6b0c293..81a8156 100644 --- a/tests/context.py +++ b/tests/context.py @@ -109,7 +109,7 @@ __BLANK = str("""""") """ - A literaly named variable to improve readability of code when using a blank string. + A literally named variable to improve readability of code when using a blank string. Meta Testing: @@ -500,7 +500,7 @@ def checkPythonFuzzing(args=[None], stderr=None): def debugBlob(blob=None): """Helper function to debug unexpected outputs. - Especialy usefull for cross-python testing where output may differ + Especially useful for cross-python testing where output may differ yet may be from the same logical data. Meta Testing: @@ -742,11 +742,11 @@ class BasicUsageTestSuite(unittest.TestCase): @classmethod def setUpClass(cls): - """Overides unittest.TestCase.setUpClass(cls) to set up thepython test fixture.""" + """Overrides unittest.TestCase.setUpClass(cls) to set up thepython test fixture.""" cls._thepython = getPythonCommand() def setUp(self): - """Overides unittest.TestCase.setUp(unittest.TestCase). + """Overrides unittest.TestCase.setUp(unittest.TestCase). Defaults is to skip test if class is missing thepython test fixture. """ if not self._thepython: @@ -766,6 +766,6 @@ def test_finds_python_WHEN_testing(self): @classmethod def tearDownClass(cls): - """Overides unittest.TestCase.tearDownClass(cls) to clean up thepython test fixture.""" + """Overrides unittest.TestCase.tearDownClass(cls) to clean up thepython test fixture.""" cls._thepython = None diff --git a/tests/test_usage.py b/tests/test_usage.py index 395dce3..58bbabd 100644 --- a/tests/test_usage.py +++ b/tests/test_usage.py @@ -127,7 +127,7 @@ class MulticastTestSuite(context.BasicUsageTestSuite): __name__ = """tests.test_usage.MulticastTestSuite""" def test_aborts_WHEN_calling_multicast_GIVEN_invalid_tools(self): - """Tests the imposible state for CLI tools given bad tools""" + """Tests the impossible state for CLI tools given bad tools""" theResult = False fail_fixture = str("""multicast.__main__.McastDispatch().useTool(JUNK) == error""") tst_dispatch = multicast.__main__.McastDispatch() @@ -443,7 +443,7 @@ def test_prints_usage_WHEN_called_GIVEN_help_argument(self): str("multicast"), str("--help") ], stderr=subprocess.STDOUT) - self.assertIn(str("usage:"), str(theOutputtxt)) + self.asserting(str("usage:"), str(theOutputtxt)) if (str("usage:") in str(theOutputtxt)): theResult = True else: @@ -477,7 +477,7 @@ def test_prints_usage_WHEN_called_GIVEN_cmd_and_help_argument(self): theOutputtxt = context.checkPythonCommand( args, stderr=subprocess.STDOUT ) - self.assertIn(str("usage:"), str(theOutputtxt)) + self.asserting(str("usage:"), str(theOutputtxt)) if (str("usage:") in str(theOutputtxt)): theResult = ((theResult is None) or (theResult is True)) else: @@ -508,7 +508,7 @@ def test_equivilant_response_WHEN_absolute_vs_implicit(self): str("-m"), str("multicast") ], stderr=subprocess.STDOUT) - self.assertIn(str(theExpectedText), str(theOutputtxt)) + self.asserting(str(theExpectedText), str(theOutputtxt)) if (str(theExpectedText) in str(theOutputtxt)): theResult = True else: @@ -574,7 +574,7 @@ def test_Usage_Error_WHEN_the_help_command_is_called(self): theOutputtxt = str(repr(bytes(theOutputtxt))) # or simply: self.assertIsNotNone(theOutputtxt) - self.assertIn(str("""usage:"""), str(theOutputtxt)) + self.asserting(str("""usage:"""), str(theOutputtxt)) if (str("""usage:""") in str(theOutputtxt)): theResult = True or theResult else: @@ -668,8 +668,8 @@ def test_invalid_Error_WHEN_cli_called_GIVEN_bad_input(self): theOutputtxt = context.checkPythonCommand(args, stderr=subprocess.STDOUT) # or simply: self.assertIsNotNone(theOutputtxt) - self.assertIn(str("invalid choice:"), str(theOutputtxt)) - self.assertIn(str(test_case), str(theOutputtxt)) + self.asserting(str("invalid choice:"), str(theOutputtxt)) + self.asserting(str(test_case), str(theOutputtxt)) theResult = True except Exception as err: context.debugtestError(err) From e485acc55fba11f8e9d8a279c533c3245587942f Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 21:47:19 -0700 Subject: [PATCH 23/31] [DOCUMENTATION] used new tests/check_spelling tool to fixup the docs (- WIP #110 & #111 -) Changes in file docs/USAGE.md: * corrected spelling, happy reading Changes in file docs/conf.py: * corrected spelling, happy reading --- docs/USAGE.md | 4 ++-- docs/conf.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index 9aabb09..91aacad 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -22,7 +22,7 @@ _fixture_HEAR_args = [ """--bind-group""", _fixture_mcast_GRP_arg ] -# spwan a listening proc +# spawn a listening proc def inputHandle(): test_RCEV = multicast.recv.McastRECV() @@ -79,7 +79,7 @@ CLI should work like so: multicast (SAY|RECV|HEAR) [-h|--help] [--use-std] [--daemon] [--port PORT] [--iface IFACE] [--pipe|-m MESSAGE|--message MESSAGE] [--group BIND_GROUP] [--groups [JOIN_MCAST_GROUPS ...]] ``` -The commands are `SAY`, `RECV`, and `HEAR` for the CLI and are analogus to `send` listen/accept and echo functions of a 1-to-1 connection. +The commands are `SAY`, `RECV`, and `HEAR` for the CLI and are analogous to `send` listen/accept and echo functions of a 1-to-1 connection. ### `SAY` diff --git a/docs/conf.py b/docs/conf.py index b2f4dd0..ce5bdb4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,7 +58,7 @@ "Makefile": "makefile", } -# The encoding of source files. Official sphinx docs reccomend utf-8-sig. +# The encoding of source files. Official sphinx docs recommend utf-8-sig. source_encoding = "utf-8-sig" # The master toctree document. @@ -91,7 +91,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [ - "_build", ".github", ".circleci", "coddcov_env", ".DS_Store", "**/.git", "dist", + "_build", ".github", ".circleci", "codecov_env", ".DS_Store", "**/.git", "dist", "../tests/tests/**", "www", "**/docs", "../multicast/multicast/**", "*~" ] @@ -244,7 +244,7 @@ myst_fence_as_directive = ("mermaid", "suggestion", "note") # Focus only on github markdown -myst_gfm_only = False +myst_gfm_only = True # how deep should markdown headers have anchors be generated heading_anchors = 3 @@ -364,8 +364,7 @@ intersphinx_mapping = { """python""": ( """https://docs.python.org/3""", - (None, """python-inv.txt""" - ) + (None, """python-inv.txt""") ) } From 54e6fd287d931fece8c71949640d84dc7c0d9ffc Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 21:48:54 -0700 Subject: [PATCH 24/31] [STYLE] Finished fixing with new tests/check_spelling tool (- WIP #110 & #111 -) Changes in file multicast/__init__.py: * Fixed some typos Changes in file multicast/__main__.py: * Fixed some typos Changes in file multicast/hear.py: * Fixed some typos Changes in file multicast/recv.py: * Fixed some typos Changes in file multicast/send.py: * Fixed some typos Changes in file multicast/skt.py: * Fixed some typos * after several tests the new `tests/check_spelling` tool seems to work. Let this be the end of spelling issues in the code. --- multicast/__init__.py | 4 ++-- multicast/__main__.py | 6 +++--- multicast/hear.py | 18 +++++++++--------- multicast/recv.py | 8 ++++---- multicast/send.py | 10 +++++----- multicast/skt.py | 12 ++++++------ 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/multicast/__init__.py b/multicast/__init__.py index 534ba99..4a1ad8d 100644 --- a/multicast/__init__.py +++ b/multicast/__init__.py @@ -234,7 +234,7 @@ """Arbitrary TTL time to live to use by default, though any small (1-126) TTL would work. A Value of 1 (one TTL) is chosen as per RFC1112 Sec 6.1 on the rational that an explicit value that could traverse byond the local connected network should be - chosen by the caller rather than the default vaule. This is inline with the principle + chosen by the caller rather than the default value. This is inline with the principle of none, one or many. Minimal Testing: @@ -546,7 +546,7 @@ def __call__(self, *args, **kwargs): will be silently ignored. Subclasses should not reimplement __call__ directly and instead - should implement nessasary logic in the abstract doStep() function. + should implement necessary logic in the abstract doStep() function. """ return self.doStep(*args, **kwargs) diff --git a/multicast/__main__.py b/multicast/__main__.py index c8670ac..b3ad074 100644 --- a/multicast/__main__.py +++ b/multicast/__main__.py @@ -504,7 +504,7 @@ def doStep(self, *args): elif (sys.stdout.isatty()): # pragma: no cover print(_TOOL_MSG) except Exception as inerr: # pragma: no branch - w = str("WARNING - An error occured while") + w = str("WARNING - An error occurred while") w += str(" handling the arguments.") w += str(" Refused.") if (sys.stdout.isatty()): # pragma: no cover @@ -514,7 +514,7 @@ def doStep(self, *args): del inerr __EXIT_MSG = (2, "NoOp") except BaseException: # pragma: no branch - e = str("CRITICAL - An error occured while handling") + e = str("CRITICAL - An error occurred while handling") e += str(" the dispatch.") if (sys.stdout.isatty()): # pragma: no cover print(str(e)) @@ -526,7 +526,7 @@ def main(*argv): """Do main event stuff. The main(*args) function in multicast is expected to return a POSIX compatible exit code. - Regardles of errors the result as an 'exit code' (int) is returned. + Regardless of errors the result as an 'exit code' (int) is returned. The only exception is multicast.__main__.main(*args) which will exit with the underlying return codes. The expected return codes are as follows: diff --git a/multicast/hear.py b/multicast/hear.py index f5284e7..a4adc51 100644 --- a/multicast/hear.py +++ b/multicast/hear.py @@ -32,7 +32,7 @@ True >>> - Testcase 1: Recv should be automaticly imported. + Testcase 1: Recv should be automatically imported. A: Test that the multicast component is initialized. B: Test that the hear component is initialized. C: Test that the hear component has __doc__ @@ -102,7 +102,7 @@ >>> import multicast >>> - Testcase 1: Hear should be automaticly imported. + Testcase 1: Hear should be automatically imported. >>> multicast.hear.__package__ is not None True @@ -126,7 +126,7 @@ >>> import multicast >>> - Testcase 1: Hear should be automaticly imported. + Testcase 1: Hear should be automatically imported. >>> multicast.hear.__module__ is not None True @@ -151,7 +151,7 @@ >>> import multicast >>> - Testcase 1: Hear should be automaticly imported. + Testcase 1: Hear should be automatically imported. >>> multicast.hear.__name__ is not None True @@ -198,7 +198,7 @@ class McastServer(socketserver.UDPServer): """Generic Subclasses socketserver.UDPServer for handling daemon function. - Basicly simplifies testing by allowing a trivial echo back (case-insensitive) of string + Basically simplifies testing by allowing a trivial echo back (case-insensitive) of string data, after printing the sender's ip out. Minimal Acceptance Testing: @@ -213,7 +213,7 @@ class McastServer(socketserver.UDPServer): >>> from multicast.hear import McastServer as McastServer >>> - Testcase 1: McastServer should be automaticly imported. + Testcase 1: McastServer should be automatically imported. >>> McastServer.__name__ is not None True @@ -257,7 +257,7 @@ def kill_func(a_server): class MyUDPHandler(socketserver.BaseRequestHandler): """Subclasses socketserver.BaseRequestHandler for handling echo function. - Basicly simplifies testing by allowing a trivial echo back (case-insensitive) of string + Basically simplifies testing by allowing a trivial echo back (case-insensitive) of string data, after printing the sender's ip out. Minimal Acceptance Testing: @@ -272,7 +272,7 @@ class MyUDPHandler(socketserver.BaseRequestHandler): >>> from multicast.hear import MyUDPHandler as MyUDPHandler >>> - Testcase 1: MyUDPHandler should be automaticly imported. + Testcase 1: MyUDPHandler should be automatically imported. >>> MyUDPHandler.__name__ is not None True @@ -291,7 +291,7 @@ def handle(self): class HearUDPHandler(socketserver.BaseRequestHandler): """Subclasses socketserver.BaseRequestHandler for handling echo function. - Basicly simplifies testing by allowing a trivial echo back (case-insensitive) of string + Basically simplifies testing by allowing a trivial echo back (case-insensitive) of string data, after printing the sender's ip out. """ diff --git a/multicast/recv.py b/multicast/recv.py index 4a0d769..ec8adb7 100644 --- a/multicast/recv.py +++ b/multicast/recv.py @@ -45,7 +45,7 @@ True >>> - Testcase 1: Recv should be automaticly imported. + Testcase 1: Recv should be automatically imported. A: Test that the multicast component is initialized. B: Test that the recv component is initialized. C: Test that the recv component has __doc__ @@ -115,7 +115,7 @@ >>> import multicast >>> - Testcase 1: Recv should be automaticly imported. + Testcase 1: Recv should be automatically imported. >>> multicast.recv.__package__ is not None True @@ -139,7 +139,7 @@ >>> import multicast >>> - Testcase 1: Recv should be automaticly imported. + Testcase 1: Recv should be automatically imported. >>> multicast.recv.__module__ is not None True @@ -164,7 +164,7 @@ >>> import multicast >>> - Testcase 1: Recv should be automaticly imported. + Testcase 1: Recv should be automatically imported. >>> multicast.recv.__name__ is not None True diff --git a/multicast/send.py b/multicast/send.py index 848b7e0..b37ba1d 100644 --- a/multicast/send.py +++ b/multicast/send.py @@ -42,7 +42,7 @@ >>> import multicast >>> - Testcase 1: Send should be automaticly imported. + Testcase 1: Send should be automatically imported. A: Test that the send component is initialized. B: Test that the send.__MAGIC__ components are initialized. @@ -78,7 +78,7 @@ >>> import multicast >>> - Testcase 1: Send should be automaticly imported. + Testcase 1: Send should be automatically imported. >>> multicast.send.__package__ is not None True @@ -102,7 +102,7 @@ >>> import multicast >>> - Testcase 1: Send should be automaticly imported. + Testcase 1: Send should be automatically imported. >>> multicast.send.__module__ is not None True @@ -127,7 +127,7 @@ >>> import multicast >>> - Testcase 1: Send should be automaticly imported. + Testcase 1: Send should be automatically imported. >>> multicast.send.__name__ is not None True @@ -289,7 +289,7 @@ def setupArgs(cls, parser): def _sayStep(group, port, data): """Will send the given data over the given port to the given group. - The actual magic is handeled here. + The actual magic is handled here. """ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) try: diff --git a/multicast/skt.py b/multicast/skt.py index abb6a5f..7c4f296 100644 --- a/multicast/skt.py +++ b/multicast/skt.py @@ -47,7 +47,7 @@ True >>> -Testcase 1: SKT utils should be automaticly imported. +Testcase 1: SKT utils should be automatically imported. A: Test that the multicast.skt component is initialized. B: Test that the skt component is initialized. C: Test that the skt component has __doc__ @@ -92,7 +92,7 @@ >>> import multicast >>> - Testcase 1: SKT utils should be automaticly imported. + Testcase 1: SKT utils should be automatically imported. >>> multicast.skt.__package__ is not None True @@ -116,7 +116,7 @@ >>> import multicast >>> - Testcase 1: SKT utils should be automaticly imported. + Testcase 1: SKT utils should be automatically imported. >>> multicast.skt.__module__ is not None True @@ -141,7 +141,7 @@ >>> import multicast >>> - Testcase 1: SKT utils should be automaticly imported. + Testcase 1: SKT utils should be automatically imported. >>> multicast.skt.__name__ is not None True @@ -177,7 +177,7 @@ def genSocket(): True >>> - Testcase 0: skt should be automaticly imported. + Testcase 0: skt should be automatically imported. A: Test that the multicast component is initialized. B: Test that the skt component is initialized. @@ -221,7 +221,7 @@ def endSocket(sock=None): True >>> - Testcase 0: skt should be automaticly imported. + Testcase 0: skt should be automatically imported. A: Test that the multicast component is initialized. B: Test that the skt component is initialized. From 4daa0b2ef35c425115e46ca551da14e92d438d3b Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 22:22:16 -0700 Subject: [PATCH 25/31] [STYLE] corrected v-array to intended vary in comment (- WIP #110 -) Changes in file docs/USAGE.md: * assuming not a v-array but the word "vary" --- docs/USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index 91aacad..0bb7c15 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -53,7 +53,7 @@ _fixture_SAY_args = [ ] try: multicast.__main__.McastDispatch().doStep("SAY", _fixture_SAY_args) - # Hint: use a loop to repeat or different arguments to varry message. + # Hint: use a loop to repeat or different arguments to vary message. except Exception: p.join() raise RuntimeError("Multicast operation failed.") From dacd7c0eba53341aeccf5dcd37c3a08b280b1149 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 23:40:01 -0700 Subject: [PATCH 26/31] [PATCH] Apply suggestions from code review (- WIP #110 -) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/USAGE.md | 15 +++++++++++---- docs/conf.py | 1 + tests/check_spelling | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index 0bb7c15..ef5b96c 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -9,13 +9,13 @@ The API is in late alpha testing, and has not yet reached a beta (pre-release) s Here is an example of usage (circa v1.4) ```python3 -import multicast as multicast -from multiprocessing import Process as Process +import multicast +from multiprocessing import Process # set up some stuff _fixture_PORT_arg = int(59595) _fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses -_fixture_host_BIND_arg +_fixture_host_BIND_arg = None # Assuming this variable needs an initial value _fixture_HEAR_args = [ """--port""", _fixture_PORT_arg, """--join-mcast-groups""", _fixture_mcast_GRP_arg, @@ -27,7 +27,14 @@ _fixture_HEAR_args = [ def inputHandle(): test_RCEV = multicast.recv.McastRECV() buffer_string = str("""""") - buffer_string += test_RCEV._hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg) + (didWork, result) = test_RCEV.doStep( + groups=[_fixture_mcast_GRP_arg], + port=_fixture_PORT_arg, + iface=_fixture_host_BIND_arg, + group=_fixture_mcast_GRP_arg, + ) + if didWork: + buffer_string += result return buffer_string def printLoopStub(func): for i in range( 0, 5 ): diff --git a/docs/conf.py b/docs/conf.py index ce5bdb4..c244972 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -177,6 +177,7 @@ # html_favicon = None try: + # extra import for CI test stability during discovery import sphinxawesome_theme from sphinxawesome_theme.postprocess import Icons html_permalinks_icon = Icons.permalinks_icon diff --git a/tests/check_spelling b/tests/check_spelling index ec9021c..a60f7b5 100755 --- a/tests/check_spelling +++ b/tests/check_spelling @@ -95,7 +95,7 @@ ulimit -t 600 umask 137 # force utf-8 for spelling -export LC_CTYPE="${LC_CTYPE:-'en_US.UTF-8'}" +export LC_CTYPE="${LC_CTYPE:-en_US.UTF-8}" LOCK_FILE="${TMPDIR:-/tmp}/org.pak.multicast.spell-check-shell" EXIT_CODE=1 @@ -179,4 +179,4 @@ unset _TEST_ROOT_DIR 2>/dev/null || : ; unset CODESPELL_OPTIONS 2>/dev/null || : ; wait ; -exit ${EXIT_CODE:255} ; +exit ${EXIT_CODE:-255} ; From 149aa0915bc231dac1ff93effe6fede93a52118e Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Tue, 17 Sep 2024 23:47:55 -0700 Subject: [PATCH 27/31] [HOTFIX] fixed CI regression by false-positive spelling correction (- WIP #110 & #111 -) Changes in file tests/test_usage.py: def test_Usage_Error_WHEN_the_help_command_is_called(self): * should be "assertIn" the function def test_equivilant_response_WHEN_absolute_vs_implicit(self): * should be "assertIn" the function def test_invalid_Error_WHEN_cli_called_GIVEN_bad_input(self): * should be "assertIn" the function def test_prints_usage_WHEN_called_GIVEN_cmd_and_help_argument(self): * should be "assertIn" the function def test_prints_usage_WHEN_called_GIVEN_help_argument(self): * should be "assertIn" the function --- tests/test_usage.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_usage.py b/tests/test_usage.py index 58bbabd..e14ac26 100644 --- a/tests/test_usage.py +++ b/tests/test_usage.py @@ -443,7 +443,7 @@ def test_prints_usage_WHEN_called_GIVEN_help_argument(self): str("multicast"), str("--help") ], stderr=subprocess.STDOUT) - self.asserting(str("usage:"), str(theOutputtxt)) + self.assertIn(str("usage:"), str(theOutputtxt)) if (str("usage:") in str(theOutputtxt)): theResult = True else: @@ -477,7 +477,7 @@ def test_prints_usage_WHEN_called_GIVEN_cmd_and_help_argument(self): theOutputtxt = context.checkPythonCommand( args, stderr=subprocess.STDOUT ) - self.asserting(str("usage:"), str(theOutputtxt)) + self.assertIn(str("usage:"), str(theOutputtxt)) if (str("usage:") in str(theOutputtxt)): theResult = ((theResult is None) or (theResult is True)) else: @@ -508,7 +508,7 @@ def test_equivilant_response_WHEN_absolute_vs_implicit(self): str("-m"), str("multicast") ], stderr=subprocess.STDOUT) - self.asserting(str(theExpectedText), str(theOutputtxt)) + self.assertIn(str(theExpectedText), str(theOutputtxt)) if (str(theExpectedText) in str(theOutputtxt)): theResult = True else: @@ -574,7 +574,7 @@ def test_Usage_Error_WHEN_the_help_command_is_called(self): theOutputtxt = str(repr(bytes(theOutputtxt))) # or simply: self.assertIsNotNone(theOutputtxt) - self.asserting(str("""usage:"""), str(theOutputtxt)) + self.assertIn(str("""usage:"""), str(theOutputtxt)) if (str("""usage:""") in str(theOutputtxt)): theResult = True or theResult else: @@ -668,8 +668,8 @@ def test_invalid_Error_WHEN_cli_called_GIVEN_bad_input(self): theOutputtxt = context.checkPythonCommand(args, stderr=subprocess.STDOUT) # or simply: self.assertIsNotNone(theOutputtxt) - self.asserting(str("invalid choice:"), str(theOutputtxt)) - self.asserting(str(test_case), str(theOutputtxt)) + self.assertIn(str("invalid choice:"), str(theOutputtxt)) + self.assertIn(str(test_case), str(theOutputtxt)) theResult = True except Exception as err: context.debugtestError(err) From 648a3cb99fdec22702455c0fd24b562cae186845 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Wed, 18 Sep 2024 00:05:56 -0700 Subject: [PATCH 28/31] [PATCH] Apply suggestions from code review (- WIP #110 -) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index ef5b96c..45a4e0e 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -103,7 +103,7 @@ The `RECV` command is used to receive multicast datagrams by listening or "joini ### `HEAR` The `HEAR` command is used to send data acknowledged messages via "HEAR" messages echoing select received multicast datagrams. -* While mostly a testing function it is possible to use `HEAR` as a proxy for other send/recv instances by using the `--daemon` flag +* While mostly a testing function, it is possible to use `HEAR` as a proxy for other send/recv instances by using the `--daemon` flag * Note: this will use the same port for sends and receives and can lead to data loss if less than two groups are used. * If more than one group is used via the `--groups` flag then all but the bind group (via `--group`) will be echoed to the bind group. From 4d7b943cf023be76e0703af24752db45f0b93d39 Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Wed, 18 Sep 2024 01:05:42 -0700 Subject: [PATCH 29/31] [UPDATE] Bump Version in prep of release (- WIP #110 -) Changes in file multicast/__init__.py: * Version bump --- multicast/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multicast/__init__.py b/multicast/__init__.py index 4a1ad8d..855bf7e 100644 --- a/multicast/__init__.py +++ b/multicast/__init__.py @@ -81,7 +81,7 @@ global __version__ # skipcq: PYL-W0604 -__version__ = """1.5-rc""" +__version__ = """1.5.0""" """The version of this program. Minimal Acceptance Testing: From 85d66172f0636562a535133911f16dfe414ef4ed Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Wed, 18 Sep 2024 02:43:19 -0700 Subject: [PATCH 30/31] [STYLE] Apply suggestions from code review (- WIP #110 -) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/USAGE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index 45a4e0e..83014bc 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -96,7 +96,7 @@ The `SAY` command is used to send data messages via multicast datagrams. ### `RECV` The `RECV` command is used to receive multicast datagrams by listening or "joining" a multicast group. -* If the `--use-std` flag is set the output is printed to the standard-output +* If the `--use-std` flag is set, the output is printed to the standard-output * This command is purely for testing or interfacing with external components and not intended as a first-class API * Note: If the `--daemon` flag is used the process will loop after reporting each datagrams until canceled, it has no effect on the `RECV` command. @@ -105,7 +105,7 @@ The `RECV` command is used to receive multicast datagrams by listening or "joini The `HEAR` command is used to send data acknowledged messages via "HEAR" messages echoing select received multicast datagrams. * While mostly a testing function, it is possible to use `HEAR` as a proxy for other send/recv instances by using the `--daemon` flag * Note: this will use the same port for sends and receives and can lead to data loss if less than two groups are used. -* If more than one group is used via the `--groups` flag then all but the bind group (via `--group`) will be echoed to the bind group. +* If more than one group is used via the `--groups` flag, then all but the bind group (via `--group`) will be echoed to the bind group. *** From a801c217bd1b920569c00d1f1a4b3ced10288f2a Mon Sep 17 00:00:00 2001 From: "Mr. Walls" Date: Wed, 18 Sep 2024 03:12:51 -0700 Subject: [PATCH 31/31] [PATCH] Apply suggestions from code review (- WIP #110 -) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/USAGE.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index 83014bc..aa71910 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -17,9 +17,9 @@ _fixture_PORT_arg = int(59595) _fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses _fixture_host_BIND_arg = None # Assuming this variable needs an initial value _fixture_HEAR_args = [ - """--port""", _fixture_PORT_arg, - """--join-mcast-groups""", _fixture_mcast_GRP_arg, - """--bind-group""", _fixture_mcast_GRP_arg + "--port", _fixture_PORT_arg, + "--join-mcast-groups", _fixture_mcast_GRP_arg, + "--bind-group", _fixture_mcast_GRP_arg ] # spawn a listening proc @@ -36,9 +36,9 @@ def inputHandle(): if didWork: buffer_string += result return buffer_string -def printLoopStub(func): - for i in range( 0, 5 ): - print( str( func() ) ) +def print_loop_stub(func): + for _ in range(5): + print(str(func())) p = Process( target=multicast.__main__.McastDispatch().doStep,