Skip to content

Commit

Permalink
Merge 38f5f2c into b29a05b
Browse files Browse the repository at this point in the history
  • Loading branch information
sarnold authored Sep 20, 2023
2 parents b29a05b + 38f5f2c commit aca245e
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 84 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ jobs:
else
EXPORT_VALUE="${TMP_GITHUB_REF}"
fi
echo "##[set-output name=branch;]${EXPORT_VALUE}"
echo "branch=${EXPORT_VALUE}" >> $GITHUB_OUTPUT
- name: Set up Python 3.9
uses: actions/setup-python@v2
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: '3.10'

- name: Install tox
run: |
python -m pip install --upgrade pip wheel
pip install tox tox-gh-actions
pip install tox
#- name: Run tox
#- name: Run tox bare-ass
#run: |
#bash -c 'tox -e lint'
#tox -e lint

- name: Run pylint
id: analyze
Expand All @@ -59,33 +59,33 @@ jobs:
run: |
rating=$(bash -c 'tox -e lint' | grep 'Your code has been rated at' | cut -f7 -d " ")
echo "Pylint score: ${rating}"
echo "##[set-output name=rating;]${rating}"
echo "##[set-output name=path;]${BADGE_PATH}"
echo "rating=${rating}" >> $GITHUB_OUTPUT
echo "path=${BADGE_PATH}" >> $GITHUB_OUTPUT
badge:
# Only generate and publish if these conditions are met:
# - The previous job/analyze step ended successfully
# - At least one of these is true:
# - This is a push event and the push event is on branch 'master' or 'develop'
# - This is a push event and the push event is on branch 'main' or 'develop'
# Note: if this repo is personal (ie, not an org repo) then you can
# use the following to change the scope of the next 2 jobs
# instead of running on branch push as shown below:
# - This is a pull request event and the pull actor is the same as the repo owner
# if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/master' }}
# if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/main' }}
name: Generate badge image with pylint score
runs-on: ubuntu-20.04
needs: [pylint]
if: ${{ github.event_name == 'push' }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: badges
path: badges

# Use the output from the `analyze` step
- name: Create pylint badge
uses: emibcn/badge-action@v1
uses: emibcn/badge-action@v2.0.2
id: badge
with:
label: 'Pylint score'
Expand All @@ -99,8 +99,8 @@ jobs:
FILE: 'pylint-score.svg'
working-directory: ./badges
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
mkdir -p "${BRANCH}"
mv "${FILE}" "${BRANCH}"
git add "${BRANCH}/${FILE}"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __pycache__/
# generated/user and test files
*.swu
ext/
pyserv/_version.py
src/pyserv/_version.py

# Distribution / packaging
.Python
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
- --install-types
- --non-interactive
- --ignore-missing-imports
files: pyserv/
files: src/

- repo: "https://github.com/asottile/blacken-docs"
rev: "1.15.0"
Expand Down Expand Up @@ -79,7 +79,7 @@ repos:
rev: v2.2.0
hooks:
- id: autoflake
files: pyserv/
files: src/
args:
- --in-place
- --remove-all-unused-imports
Expand All @@ -90,15 +90,15 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
files: pyserv/
files: src/
additional_dependencies: ["flake8-bugbear"]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["-ll", "-q"]
files: pyserv/
files: src/

# - repo: https://github.com/lovesegfault/beautysh
# rev: v6.2.1
Expand Down
33 changes: 23 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,30 @@ of your OTA update file.

.. _OTA: https://en.wikipedia.org/wiki/Over-the-air_programming


Daemons and Console Entry Points
================================

Pyserv contains modules with some backported features and a fix for broken
OTA clients. It provides multiple console commands for different protocols,
and two daemon wrappers for http and tftp.

* console commands with simple arguments to run, well, from the console, or
for running via Procfile_ with something like Honcho_
* daemon scripts to run in the background for workflows that need a simple
HTTP/WSGI server or TFTP server

.. _Procfile: https://devcenter.heroku.com/articles/procfile
.. _Honcho: https://honcho.readthedocs.io/en/latest/index.html

Console command options
-----------------------

This package now installs several different command line interfaces to
support multiple protocols:

* HTTP - the ``serv`` command and ``httpdaemon`` script
* HTTP - the ``serv`` console command
* WSGI - the ``wsgi`` console command
* TFTP - the ``tftpd`` console command and ``tftpdaemon`` script
* TFTP - the ``tftpd`` console command

The standard Python console entry points all have these minimal/default
The above standard Python console entry points all have these minimal/default
"features" with no arguments:

* the document/server root is always the current directory
Expand All @@ -73,7 +86,7 @@ The standard Python console entry points all have these minimal/default
+ TFTP: default port is ``8069`` and the server listens on localhost

* the *only* allowed args are either port, or port *and* interface (or
app and port for WSGI)
app_name and port for WSGI)

.. note:: *All* of the above are configurable via environment variables
defined in the ``settings`` module (with the above defaults).
Expand Down Expand Up @@ -150,7 +163,7 @@ Once installed in a virtual environment, check the ``help`` output::


Install with pip
----------------
================

This refactored fork of pyserv is *not* published on PyPI, thus use one of
the following commands to install the latest pyserv in a Python virtual
Expand Down Expand Up @@ -305,9 +318,9 @@ Original gist: https://gist.github.com/mdonkers/63e115cc0c79b4f6b8b3a6b797e485c7


Pre-commit
----------
==========

This repo is now pre-commit_ enabled for python/rst source and file-type
This repo is pre-commit_ enabled for python/rst source and file-type
linting. The checks run automatically on commit and will fail the commit
(if not clean) and perform simple file corrections. For example, if the
mypy check fails on commit, you must first fix any fatal errors for the
Expand Down
24 changes: 13 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import os
import sys

import pkg_resources
if sys.version_info < (3, 8):
from importlib_metadata import version
else:
from importlib.metadata import version


sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'pyserv')))

__version__ = pkg_resources.get_distribution('pyserv').version
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))

# -- Project information -----------------------------------------------------

Expand All @@ -27,9 +27,9 @@
author = 'Stephen Arnold'

# The full version, including alpha/beta/rc tags
version = __version__
release = version

release = version('pyserv')
# The short X.Y version.
version = '.'.join(release.split('.')[:2])

# -- General configuration ------------------------------------------------

Expand All @@ -41,18 +41,20 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_git',
'sphinxcontrib.apidoc',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'recommonmark',
]

apidoc_module_dir = '../../pyserv/'
apidoc_module_dir = '../../src/pyserv/'
apidoc_output_dir = 'api'
apidoc_excluded_paths = ['test']
apidoc_excluded_paths = ['tests']
apidoc_separate_modules = True

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -69,7 +71,7 @@

# Brief project description
#
description = 'Simple HTTP server to handle GET requests for local files.'
description = 'A collection of simple servers for HTTP, WSGI, and TFTP'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
7 changes: 7 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Welcome to the pyserv documentation!
====================================

.. git_commit_detail::
:branch:
:commit:
:sha_length: 10
:uncommitted:
:untracked:

.. toctree::
:caption: Contents:
:maxdepth: 3
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ markers = "subscript"
[tool.coverage.run]
branch = true
source = [
"pyserv/",
"src/",
".tox/py*/lib/python*/site-packages/",
]
omit = [
Expand All @@ -26,7 +26,7 @@ omit = [
]

[tool.coverage.paths]
source = ["pyserv"]
source = ["src"]

[tool.coverage.report]
fail_under = 80
Expand Down Expand Up @@ -79,4 +79,4 @@ dirty = "{version}+d{build_date:%Y%m%d}"
distance-dirty = "{next_version}.dev{distance}"

[tool.versioningit.write]
file = "pyserv/_version.py"
file = "src/pyserv/_version.py"
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# daemon requirements, useful for tox/pip
daemonizer @ git+https://github.com/sarnold/python-daemonizer.git@0.3.5#5f6bc3c80a90344b2c8e4cc24ed0b8c098a7af50; platform_system!="Windows"
daemonizer @ git+https://github.com/sarnold/python-daemonizer.git@0.4.0#5e0fd72b9176fdcda8c9386f8b0905f2c434b61f; platform_system!="Windows"
tftpy @ git+https://github.com/VCTLabs/tftpy.git@0.8.2.1#58d1f5c60af2e3759fbb137b89816954d8ea6bc9
appdirs
platformdirs
3 changes: 2 additions & 1 deletion scripts/httpdaemon
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ from pathlib import Path
from daemon import Daemon
from daemon.parent_logger import setup_logging

from pyserv import GetServer, __version__
from pyserv import GetServer
from pyserv._version import __version__
from pyserv.settings import (
DEBUG,
DOCROOT,
Expand Down
4 changes: 1 addition & 3 deletions scripts/tftpdaemon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ TFTP daemon script using pyserv and py3tftp (see settings.py for env vars).
"""

import argparse
import logging
import os
import sys
from pathlib import Path
Expand All @@ -13,7 +12,7 @@ import tftpy
from daemon import Daemon
from daemon.parent_logger import setup_logging

from pyserv import __version__
from pyserv._version import __version__
from pyserv.settings import (
DEBUG,
DOCROOT,
Expand All @@ -31,7 +30,6 @@ from pyserv.settings import (
LPNAME = os.getenv('LPNAME', default='tftpd')
IFACE = os.getenv('IFACE', default='0.0.0.0')
PORT = os.getenv('PORT', default='9069')
logger = logging.getLogger(__name__)


class ServDaemon(Daemon):
Expand Down
14 changes: 9 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[metadata]
name = pyserv
version = attr: pyserv.__version__
description = attr: pyserv.__doc__
description = A collection of simple servers for HTTP, WSGI, and TFTP
url = https://github.com/sarnold/pyserv
author = Stephen L Arnold
email = nerdboy@gentoo.org
long_description = file: README.rst
long_description_content_type = text/rst; charset=UTF-8
license: MIT
license_expression = MIT
license_files = LICENSE
classifiers =
Expand All @@ -33,18 +34,20 @@ keywords =
[options]
python_requires = >= 3.6
install_requires =
appdirs
daemonizer @ git+https://github.com/sarnold/python-daemonizer.git@0.3.5#5f6bc3c80a90344b2c8e4cc24ed0b8c098a7af50
daemonizer @ git+https://github.com/sarnold/python-daemonizer.git@0.4.0#5e0fd72b9176fdcda8c9386f8b0905f2c434b61f
platformdirs
tftpy @ git+https://github.com/VCTLabs/tftpy.git@0.8.2.1#58d1f5c60af2e3759fbb137b89816954d8ea6bc9

packages = find:
zip_safe = True
packages = find_namespace:
package_dir =
=src

scripts =
scripts/httpdaemon
scripts/tftpdaemon

[options.packages.find]
where = src
exclude =
examples*
docs*
Expand All @@ -61,6 +64,7 @@ console_scripts =
[options.extras_require]
doc =
sphinx
sphinx_git
recommonmark
sphinx_rtd_theme
sphinxcontrib-apidoc
Expand Down
Loading

0 comments on commit aca245e

Please sign in to comment.