From 018e7097eb51a66381b15636b1b0c41eebf4c13f Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Thu, 11 Jan 2024 14:36:01 +0000 Subject: [PATCH] Initial commit --- .gitignore | 141 +++++++++++++++++++++++++++++++++++++++++ LICENSE | 9 +++ Makefile | 33 ++++++++++ Pipfile | 15 +++++ README.rst | 30 +++++++++ setup.cfg | 2 + setup.py | 22 +++++++ src/cli/__init__.py | 1 + src/cli/cli.py | 3 + tests/test_cli_main.py | 9 +++ 10 files changed, 265 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 Pipfile create mode 100644 README.rst create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 src/cli/__init__.py create mode 100644 src/cli/cli.py create mode 100644 tests/test_cli_main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bdb2ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,141 @@ +# Swap file +*.swp +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8057c19 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023 $REPO_OWNER + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aefafcb --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +.PHONY: default install wheel dev test coverage black-check black-diff safety tag + +guard-%: + @ if [ "${${*}}" = "" ]; then echo "Run 'pipenv shell' before command"; exit 1; fi + +default: test + +install: guard-PIPENV_ACTIVE + pip install -e . + +wheel: guard-PIPENV_ACTIVE coverage black-check safety + python setup.py bdist_wheel + +dev: guard-PIPENV_ACTIVE + pipenv install --dev --skip-lock + +test: guard-PIPENV_ACTIVE + PYTHONPATH=./src pytest + +coverage: guard-PIPENV_ACTIVE + PYTHONPATH=./src pytest --cov-report term --cov=./src/cli ./tests --cov-report term-missing + +black-check: guard-PIPENV_ACTIVE + black --check src/ tests/ + +black-diff: guard-PIPENV_ACTIVE + black --diff src/ tests/ + +safety: guard-PIPENV_ACTIVE + pipenv lock --requirements | safety check --stdin + +upload: guard-PIPENV_ACTIVE + python3 -m twine upload --repository gitea dist/* diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..90d2d50 --- /dev/null +++ b/Pipfile @@ -0,0 +1,15 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] +pytest = "*" +pytest-mock = "*" +pytest-cov = "*" +black = "*" +safety = "*" +twine = "*" + +[requires] +python_version = "3.6" diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..402adf3 --- /dev/null +++ b/README.rst @@ -0,0 +1,30 @@ +webcheck +=== + +simple tool to check http(s) response code on remote web service + + +Preparing for Development +------------------------- + +1. Ensure ``pip`` and ``pipenv`` are installed +2. Clone repository: ``git clone https://github.com/SweBarre/sps.git`` +3. ``cd`` into repository +4. Activate virtualenv: ``pipenv shell`` +5. Fetch development dependencies ``make dev`` + + +Running Tests +------------- + +Run tests locally using ``make`` if virtualenv is active: + +:: + + $ make test + +If virtualenv isn't active then use: + +:: + + $ pipenv run make diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..a9a649e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +python-tag = py36 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d3052be --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +from setuptools import setup, find_packages +from src.cli import __version__ as version + +with open("README.rst", encoding="UTF-8") as f: + readme = f.read() + +setup( + name="webcheck", + version=version, + description="simple tool to check http(s) response code on remote web service", + long_description=readme, + author="jonas", + author_email="", + packages=find_packages("src"), + package_dir={"": "src"}, + install_requires=[], + entry_points={ + "console_scripts": [ + "webcheck=cli.cli:main", + ] + } +) diff --git a/src/cli/__init__.py b/src/cli/__init__.py new file mode 100644 index 0000000..f102a9c --- /dev/null +++ b/src/cli/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/src/cli/cli.py b/src/cli/cli.py new file mode 100644 index 0000000..858bc01 --- /dev/null +++ b/src/cli/cli.py @@ -0,0 +1,3 @@ +def main(): + """The main program logic""" + print("Hello") diff --git a/tests/test_cli_main.py b/tests/test_cli_main.py new file mode 100644 index 0000000..c68e3f9 --- /dev/null +++ b/tests/test_cli_main.py @@ -0,0 +1,9 @@ +import pytest +from cli import cli + + +def test_cli_main(capsys): + output = "Hello\n" + cli.main() + captured = capsys.readouterr() + assert captured.out == output