From 7faea8d4ab3c6b5c2a20bc8c0ee12432bfb350cd Mon Sep 17 00:00:00 2001 From: Aleh Strakachuk Date: Mon, 16 Jan 2023 22:08:45 +0200 Subject: [PATCH] Rename project to graceful_shutdown --- README.rst | 18 +++++++++--------- docs/source/api-docs/api-docs-index.rst | 4 ++-- docs/source/index.rst | 2 +- requirements-test.txt | 4 ++-- setup.cfg | 14 +++++++------- .../__init__.py | 16 +++++++++++----- src/tests/__init__.py | 0 src/tests/gracefull_shutdown_test.py | 17 +++++++++++++++-- tox.ini | 11 +++++------ 9 files changed, 52 insertions(+), 34 deletions(-) rename src/{gracefull_shutdown => graceful_shutdown}/__init__.py (66%) create mode 100644 src/tests/__init__.py diff --git a/README.rst b/README.rst index 933b760..f537139 100644 --- a/README.rst +++ b/README.rst @@ -1,9 +1,9 @@ |License| |Release| |Supported versions| |Docs| |Contact| |Blog| -gracefull-shutdown-py +graceful-shutdown-py ===================== -Helps to support gracefull shutdown for your python application. +Helps to support graceful shutdown for your python application. Example of usage ---------------- @@ -11,22 +11,22 @@ Simple ^^^^^^ .. code:: python - from gracefull_shutdown import ExitSignalHandler + from graceful_shutdown import ExitSignalHandler shutdown = ExitSignalHandler() while not shutdown.triggered: sleep(1) -.. |Release| image:: https://img.shields.io/github/release/zifter/gracefull-shutdown-py.svg - :target: https://github.com/zifter/gracefull-shutdown-py/releases -.. |Supported versions| image:: https://img.shields.io/pypi/pyversions/gracefull-shutdown-py.svg - :target: https://pypi.org/project/gracefull-shutdown-py/ +.. |Release| image:: https://img.shields.io/github/release/zifter/graceful-shutdown-py.svg + :target: https://github.com/zifter/graceful-shutdown-py/releases +.. |Supported versions| image:: https://img.shields.io/pypi/pyversions/graceful-shutdown-py.svg + :target: https://pypi.org/project/graceful-shutdown-py/ .. |Contact| image:: https://img.shields.io/badge/telegram-write%20me-blue.svg :target: https://t.me/zifter .. |Blog| image:: https://img.shields.io/badge/site-my%20blog-yellow.svg :target: https://zifter.github.io/ .. |License| image:: https://img.shields.io/badge/License-MIT-yellow.svg :target: https://opensource.org/licenses/MIT -.. |Docs| image:: https://readthedocs.org/projects/gracefull-shutdown-py/badge/?version=latest&style=flat - :target: https://gracefull-shutdown-py.readthedocs.io/en/latest/ +.. |Docs| image:: https://readthedocs.org/projects/graceful-shutdown-py/badge/?version=latest&style=flat + :target: https://graceful-shutdown-py.readthedocs.io/en/latest/ diff --git a/docs/source/api-docs/api-docs-index.rst b/docs/source/api-docs/api-docs-index.rst index e3ee7fd..64dcec3 100644 --- a/docs/source/api-docs/api-docs-index.rst +++ b/docs/source/api-docs/api-docs-index.rst @@ -1,7 +1,7 @@ -Gracefull shutdown +graceful shutdown ============== -.. automodule:: gracefull_shutdown +.. automodule:: graceful_shutdown :members: .. toctree:: diff --git a/docs/source/index.rst b/docs/source/index.rst index 6c8e7ed..5f0ce94 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,7 +3,7 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to gracefull-shutdown-py's documentation! +Welcome to graceful-shutdown-py's documentation! ===================================================================== .. include:: ../../README.rst diff --git a/requirements-test.txt b/requirements-test.txt index e4a3e26..811ee3c 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==6.2.1 -pytest-cov==2.10.1 +pytest==6.2.5 +pytest-cov==3.0.0 diff --git a/setup.cfg b/setup.cfg index 7786bfe..de26387 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,18 +1,18 @@ # https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c [metadata] -name = gracefull-shutdown-py -version = 0.2.2 +name = graceful-shutdown-py +version = 0.3.0 author = Aleh Strakachuk author_email = zifter.ai@gmail.com -home-page = https://github.com/zifter/gracefull-shutdown-py -description = attr: gracefull_shutdown.__doc__ +home-page = https://github.com/zifter/graceful-shutdown-py +description = attr: graceful_shutdown.__doc__ long-description = file: README.rst long_description_content_type = text/x-rst license = MIT license-file = LICENSE platform = any -keywords = gracefull,shutdown +keywords = graceful,shutdown classifiers = Development Status :: 5 - Production/Stable License :: OSI Approved :: MIT License @@ -31,10 +31,10 @@ zip_safe = false include_package_data = true python_requires = >= 3.5 package_dir = - gracefull_shutdown=src/gracefull_shutdown + graceful_shutdown=src/graceful_shutdown tests=src/tests packages = - gracefull_shutdown + graceful_shutdown test_suite = tests setup_requires = setuptools >=30.3.0 # minimal version for `setup.cfg` diff --git a/src/gracefull_shutdown/__init__.py b/src/graceful_shutdown/__init__.py similarity index 66% rename from src/gracefull_shutdown/__init__.py rename to src/graceful_shutdown/__init__.py index 08aea4f..78f1982 100644 --- a/src/gracefull_shutdown/__init__.py +++ b/src/graceful_shutdown/__init__.py @@ -1,10 +1,10 @@ """ -Package with gracefull shutdown functionality +Package with graceful shutdown functionality """ import signal from logging import getLogger -_logger = getLogger("gracefull-shutdown") +_logger = getLogger("graceful-shutdown") class ExitSignalHandler: @@ -18,10 +18,10 @@ def __init__(self): """ self._triggered: bool = False - signal.signal(signal.SIGINT, self._exit_gracefully) - signal.signal(signal.SIGTERM, self._exit_gracefully) + signal.signal(signal.SIGINT, self.exit_gracefuly) + signal.signal(signal.SIGTERM, self.exit_gracefuly) - def _exit_gracefully(self, _signum, _frame): + def exit_gracefuly(self, _signum, _frame): """ Signal handler """ @@ -44,6 +44,12 @@ def triggered(self) -> bool: """ return self._triggered + def __bool__(self) -> bool: + """ + Cast to bool + """ + return self.triggered + __all__ = [ "ExitSignalHandler", diff --git a/src/tests/__init__.py b/src/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/gracefull_shutdown_test.py b/src/tests/gracefull_shutdown_test.py index e494afd..2d44c34 100644 --- a/src/tests/gracefull_shutdown_test.py +++ b/src/tests/gracefull_shutdown_test.py @@ -1,7 +1,20 @@ """ -Tests for gracefull shutdown +Tests for graceful shutdown """ -from gracefull_shutdown import ExitSignalHandler +from graceful_shutdown import ExitSignalHandler + + +def test_trigger_like_signal_ok(): + """ + Check correct creation and trigger as signal handler + """ + shutdown = ExitSignalHandler() + + assert shutdown.triggered is False + + shutdown.exit_gracefuly(None, None) + + assert shutdown.triggered is True def test_trigger_ok(): diff --git a/tox.ini b/tox.ini index acbf40f..12e036f 100644 --- a/tox.ini +++ b/tox.ini @@ -48,15 +48,14 @@ deps = black==22.3.0 commands = black --check src/ [testenv:coverage_report] -passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_* APPVEYOR APPVEYOR_* deps = - coverage==5.0.2 + coverage==6.4.3 codecov==2.0.15 commands = coverage html - coverage report --include="src/*" --fail-under=100 -m + coverage report --include="src/graceful_shutdown/*" --fail-under=99 -m + coverage report --include="src/tests/*" --fail-under=100 -m coverage xml - codecov -f coverage.xml --token=2455dcfa-f9fc-4b3a-b94d-9765afe87f0f [testenv:gen_docs] skip_install = True @@ -82,7 +81,7 @@ commands = [testenv:test_venv] skip_install = True commands = - pip install --extra-index-url https://pypi.org/simple -i https://test.pypi.org/simple/ gracefull-shutdown-py + pip install --extra-index-url https://pypi.org/simple -i https://test.pypi.org/simple/ graceful-shutdown-py [testenv:pypi_upload] deps = @@ -100,7 +99,7 @@ commands = skip_install = True deps = commands = - pip install gracefull-shutdown-py + pip install graceful-shutdown-py ########