haraka 0.2.46__py3-none-any.whl → 0.2.48__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.
- haraka/PyFast/Runtime.py +47 -0
- haraka/PyFast/__init__.py +2 -0
- haraka/__init__.py +2 -1
- haraka/utils/logging/log_util.py +5 -3
- {haraka-0.2.46.dist-info → haraka-0.2.48.dist-info}/METADATA +1 -1
- {haraka-0.2.46.dist-info → haraka-0.2.48.dist-info}/RECORD +8 -6
- {haraka-0.2.46.dist-info → haraka-0.2.48.dist-info}/WHEEL +0 -0
- {haraka-0.2.46.dist-info → haraka-0.2.48.dist-info}/top_level.txt +0 -0
haraka/PyFast/Runtime.py
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
from fastapi import FastAPI
|
2
|
+
import socket
|
3
|
+
from haraka.utils import Logger
|
4
|
+
|
5
|
+
class Lifecycle:
|
6
|
+
"""
|
7
|
+
A helper class to handle initialization and shutdown messaging for a FastAPI application.
|
8
|
+
"""
|
9
|
+
def __init__(self, variant: str = "PyFast"):
|
10
|
+
"""
|
11
|
+
Initializes the PyFast instance with a logger.
|
12
|
+
|
13
|
+
Args:
|
14
|
+
variant (str): A string identifier for the application. Default is 'PyFast'.
|
15
|
+
"""
|
16
|
+
self.variant = variant
|
17
|
+
self.logger = Logger(self.variant).start_logger()
|
18
|
+
|
19
|
+
def start(self, settings, app: FastAPI):
|
20
|
+
"""
|
21
|
+
Initializes the application and logs Swagger UI availability.
|
22
|
+
|
23
|
+
Args:
|
24
|
+
settings: A settings object containing application configuration (e.g., port).
|
25
|
+
app (FastAPI): The FastAPI application instance.
|
26
|
+
"""
|
27
|
+
try:
|
28
|
+
port = settings.port
|
29
|
+
docs_path = app.docs_url or "/docs" # Default to '/docs' if not set
|
30
|
+
local_url = f"http://localhost:{port}{docs_path}"
|
31
|
+
|
32
|
+
# Resolve the network-accessible hostname
|
33
|
+
host = socket.gethostbyname(socket.gethostname())
|
34
|
+
network_url = f"http://{host}:{port}{docs_path}"
|
35
|
+
|
36
|
+
# Log the Swagger UI URLs
|
37
|
+
self.logger.info(f"Swagger UI available at: {local_url}")
|
38
|
+
self.logger.info(f"Network Swagger UI available at: {network_url}")
|
39
|
+
|
40
|
+
except Exception as e:
|
41
|
+
self.logger.warn(f"Failed to determine network URL: {e}")
|
42
|
+
|
43
|
+
def destroy(self):
|
44
|
+
"""
|
45
|
+
Logs a shutdown message when the application is shutting down.
|
46
|
+
"""
|
47
|
+
self.logger.info("🛑 Application is shutting down!")
|
haraka/__init__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
"""cookiecutter post-generation helper package."""
|
2
2
|
from haraka.post_gen.runner import main
|
3
3
|
from haraka.post_gen.config import PostGenConfig
|
4
|
-
|
4
|
+
from haraka.PyFast.Runtime import Lifecycle
|
5
|
+
__all__ = ["main", "PostGenConfig", "PyFast"]
|
haraka/utils/logging/log_util.py
CHANGED
@@ -9,7 +9,7 @@ class Logger:
|
|
9
9
|
self.verbose = verbose
|
10
10
|
self.evm = evm # Extreme Verbosity Mode (In-depth debug logs)
|
11
11
|
|
12
|
-
def start_logger(self, verbose) -> Logger:
|
12
|
+
def start_logger(self, verbose: bool = False) -> Logger:
|
13
13
|
label = Logger.get_label(self.label)
|
14
14
|
return Logger(label, verbose)
|
15
15
|
|
@@ -21,14 +21,16 @@ class Logger:
|
|
21
21
|
print(f"🔴 DEBUG: {msg}")
|
22
22
|
|
23
23
|
def warn(self, msg: str, file: TextIO = sys.stderr) -> None:
|
24
|
-
print(f"{self.label} WARNING: {msg}", file=file)
|
24
|
+
print(f"{self.label} ⚠️ WARNING: {msg}", file=file)
|
25
25
|
|
26
26
|
def error(self, msg: str, file: TextIO = sys.stderr) -> None:
|
27
|
-
print(f"{self.label} ERROR: {msg}", file=file)
|
27
|
+
print(f"{self.label} ❌ ERROR: {msg}", file=file)
|
28
28
|
|
29
29
|
@staticmethod
|
30
30
|
def get_label(variant: str) -> str:
|
31
31
|
if variant == "go":
|
32
32
|
return f"[🔥Go Fast: post_gen]"
|
33
|
+
if variant == "PyFast":
|
34
|
+
return f"[🐍 PyFast]:"
|
33
35
|
return f"[🔥post_gen ({variant})]"
|
34
36
|
|
@@ -1,4 +1,6 @@
|
|
1
|
-
haraka/__init__.py,sha256=
|
1
|
+
haraka/__init__.py,sha256=LfTpqagx32Rssxza1oNqPDVIhGteC0vuP_MYk9QvKyY,230
|
2
|
+
haraka/PyFast/Runtime.py,sha256=uRkz-kGbQxxeC1NgZtEtiM_v9sZPRBQF45WlbbrB_80,1670
|
3
|
+
haraka/PyFast/__init__.py,sha256=3tsJzYntILAUj5vb4E8f_0onP1ldjfOj-XTDCf1tYC4,53
|
2
4
|
haraka/art/__init__.py,sha256=-b1KHQiLkaI2sXaHS05XDaE27tZfXvVLitILjJfSiKs,112
|
3
5
|
haraka/art/create.py,sha256=D2VPJtuwI0Ed7CcreHRHhxSN1VzV7PQfC1q-NW8l0DY,631
|
4
6
|
haraka/art/ascii/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -24,12 +26,12 @@ haraka/utils/__init__.py,sha256=3Cp4u0dyAGcmqes-tIr95KFsNsJx5Ji5Yzkto9546Hs,168
|
|
24
26
|
haraka/utils/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
27
|
haraka/utils/common/utils.py,sha256=kMnMXe_hcxGkD0MKGmR1lIwsRND7BaFPRbGN4PwonfM,360
|
26
28
|
haraka/utils/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
-
haraka/utils/logging/log_util.py,sha256=
|
29
|
+
haraka/utils/logging/log_util.py,sha256=Atlhutx4tKTtme9nj0JjObZNiCkwpEixGjhsGvI9544,1143
|
28
30
|
haraka/utils/manifests/GoUltraFast.yml,sha256=LBSlT2QyOi_reUfZ7AAvs0U6Ju47K94eG_fjs7SNuN8,975
|
29
31
|
haraka/utils/manifests/JavaFein.yml,sha256=TSTo45Q-NMMqaDS4ogYwU0PpxW-sl0MCYj-RG-Hc_M0,989
|
30
32
|
haraka/utils/manifests/PyFast.yml,sha256=dfUXDsxWj-Ex_DQX9sNNezIjfAW_ipjHEh1g8sEs8eQ,924
|
31
33
|
haraka/utils/manifests/go-grpc-gateway-buf.yml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
|
-
haraka-0.2.
|
33
|
-
haraka-0.2.
|
34
|
-
haraka-0.2.
|
35
|
-
haraka-0.2.
|
34
|
+
haraka-0.2.48.dist-info/METADATA,sha256=8aNoMJHmTymPlYvz_7jjsf7so93i1zjOJ3HTTf3-J74,579
|
35
|
+
haraka-0.2.48.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
36
|
+
haraka-0.2.48.dist-info/top_level.txt,sha256=1khpwypLKWoklVd_CgFiwAfcctVSXRoRPc3BI9lyIXo,7
|
37
|
+
haraka-0.2.48.dist-info/RECORD,,
|
File without changes
|
File without changes
|