simple-http-checker-r-version 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,53 @@
1
+ import logging
2
+ import requests
3
+ from typing import Collection
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ def check_urls(
9
+ urls: Collection[str], timeout: int = 5
10
+ ) -> dict[str, str]:
11
+ """
12
+ Checks a list of URLs and returns their status.
13
+
14
+ Args:
15
+ urls: A list of URLs strings to check.
16
+ timeout: Maximum time in seconds to wait for each request. Defaults to 5.
17
+
18
+ Returns:
19
+ A dictionary mapping each URL to its status string.
20
+ """
21
+
22
+ logger.info(
23
+ f"Starting check for {len(urls)} URLs with a timeout of {timeout}"
24
+ )
25
+ results: dict[str, str] = {}
26
+ for url in urls:
27
+ status = "UNKNOWN"
28
+ try:
29
+ logger.debug(f"Checking URL: {url}")
30
+ response = requests.get(url, timeout=timeout)
31
+ if response.ok:
32
+ status = f"{response.status_code} OK"
33
+ else:
34
+ status = (
35
+ f"{response.status_code} {response.reason}"
36
+ )
37
+ except requests.exceptions.Timeout:
38
+ status = "TIMEOUT"
39
+ logger.warning(f"Request to {url} timed out.")
40
+ except requests.exceptions.ConnectionError:
41
+ status = "CONNECTION_ERROR"
42
+ logger.warning(f"Connection error for {url}.")
43
+ except requests.exceptions.RequestException as e:
44
+ status = f"REQUEST_ERROR: {type(e).__name__}"
45
+ logger.error(
46
+ f"An unexpected error occurred for {url}: {e}",
47
+ exc_info=True,
48
+ )
49
+
50
+ results[url] = status
51
+ logger.info(f"Checked {url:<40} -> {status}")
52
+ logger.info(" URL check finished.")
53
+ return results
@@ -0,0 +1,49 @@
1
+ import logging
2
+ import click
3
+ from typing import Collection
4
+ from .checker import check_urls
5
+
6
+ logging.basicConfig(
7
+ level=logging.INFO,
8
+ format="[%(asctime)s] %(levelname)-8s %(name)s:%(message)s",
9
+ datefmt="%Y-%m-%d %H:%M:%S",
10
+ )
11
+ logger = logging.getLogger(__name__)
12
+
13
+
14
+ @click.command()
15
+ @click.argument("urls", nargs=-1)
16
+ @click.option(
17
+ "--timeout",
18
+ default=5,
19
+ help="Timeout in seconds for each request.",
20
+ )
21
+ @click.option(
22
+ "--verbose", "-v", is_flag=True, help="Enable debug logging."
23
+ )
24
+ def main(urls: Collection[str], timeout: int, verbose: bool):
25
+ if verbose:
26
+ logging.getLogger().setLevel(logging.DEBUG)
27
+ logger.debug("Verbose logging enabled.")
28
+
29
+ logger.debug(f"Received urls: {urls}")
30
+ logger.debug(f"Received timeout: {timeout}")
31
+ logger.debug(f"Received verbose: {verbose}")
32
+
33
+ if not urls:
34
+ logger.warning("No URLs provided to check.")
35
+ click.echo("Usage: check-urls <URL1> <URL2> ...")
36
+ return
37
+
38
+ logger.info(f"Starting check for {len(urls)} URLs.")
39
+
40
+ results = check_urls(urls, timeout)
41
+
42
+ click.echo("\n--- Results ---")
43
+ for url, status in results.items():
44
+ if "OK" in status:
45
+ fg_color = "green"
46
+
47
+ else:
48
+ fg_color = "red"
49
+ click.secho(f"{url:<40} -> {status}", fg=fg_color)
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: simple-http-checker-r-version
3
+ Version: 1.3.0
4
+ Summary: A simple CLI tool to check the status of URLs.
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: requests<3.9,>=2.28
9
+ Requires-Dist: click<9.0,>=8.0
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest; extra == "dev"
12
+ Requires-Dist: pytest-mock; extra == "dev"
13
+ Requires-Dist: ruff; extra == "dev"
14
+ Requires-Dist: black; extra == "dev"
15
+ Requires-Dist: mypy; extra == "dev"
16
+ Requires-Dist: bandit; extra == "dev"
17
+ Requires-Dist: types-requests; extra == "dev"
18
+ Dynamic: license-file
19
+
20
+ # Python for DevOps: CI/CD for Python Projects
21
+
22
+ This repository contains the complete CI/CD implementation for the CI/CD section of my **Python for DevOps: Mastering Real-World Automation** course. Here, you'll learn how to build a robust, automated pipeline for Python projects using GitHub Actions. Make sure to join the course to learn comprehensive Python automation skills for DevOps and infrastructure management!
23
+
24
+
25
+ **Note:** Here is the link to the main code repository for the project: [https://github.com/mohamedrabie92/python-devops-cicd-project](https://github.com/mohamedrabie92/python-devops-cicd-project)
26
+
27
+ ## 🎯 Project Overview
28
+
29
+ This project demonstrates a complete CI/CD pipeline for a Python package called **Simple HTTP Checker** - a command-line tool for checking HTTP endpoint availability. Through this hands-on example, you'll learn modern Python development practices and automated deployment workflows.
30
+
31
+ ## ✅ What we implement in this repository
32
+
33
+ - [X] **Implement the project (code files)** - Complete Python package with proper structure
34
+ - [x] **Add a simple GHA workflow** - Basic GitHub Actions setup and execution
35
+ - [x] **Add linting (ruff) and format checks (black)** - Code quality automation
36
+ - [x] **Add typing (mypy) and security checks (bandit)** - Static analysis and security scanning
37
+ - [x] **Add test automation** - Comprehensive test suite with pytest
38
+ - [X] **Build our Python project** - Automated package building
39
+ - [X] **Publish the project to both TestPyPI and PyPI** - Automated package publishing on releases
40
+
41
+ ## 📚 Learning Objectives
42
+
43
+ Through this project, you'll master:
44
+
45
+ - **Modern Python packaging** with `pyproject.toml`
46
+ - **GitHub Actions** for CI/CD automation
47
+ - **Code quality tools** (Black, Ruff, MyPy, Bandit)
48
+ - **Automated testing** with pytest
49
+ - **Package publishing** to PyPI repositories
50
+ - **Release management** with Git tags and GitHub releases
@@ -0,0 +1,9 @@
1
+ simple_http_checker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ simple_http_checker/checker.py,sha256=GYOqLJnLP1yyrDZlVoowwPdN1EuJe2jH6TC3WZmPsLU,1653
3
+ simple_http_checker/cli.py,sha256=TbYqdysEi6PBuI8d42svZYv9aMEsRk6_W91L8BRxSh0,1310
4
+ simple_http_checker_r_version-1.3.0.dist-info/licenses/LICENSE,sha256=-4wwLE_h81Mp7Q6e73ACcBOeBBDqnJh6JVJG281dIWI,1071
5
+ simple_http_checker_r_version-1.3.0.dist-info/METADATA,sha256=tu_qNU_tu_OHjCW8kD8Zdne_IMuBYiSjFSSukT-Vkzk,2510
6
+ simple_http_checker_r_version-1.3.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ simple_http_checker_r_version-1.3.0.dist-info/entry_points.txt,sha256=UF_7hQD8GGstiCxqZgH6XC6YbiUxh7ZDf5o8Wg0NhDE,60
8
+ simple_http_checker_r_version-1.3.0.dist-info/top_level.txt,sha256=Q2N-cYyXd23OQxUK_TdugtDVBHGsKaM2V2JOF5ygKtk,20
9
+ simple_http_checker_r_version-1.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ check-urls = simple_http_checker.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mohamedrabie92
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ simple_http_checker