diff --git a/docs/README.html b/docs/README.html
index ff1b8dd..057eefb 100644
--- a/docs/README.html
+++ b/docs/README.html
@@ -4,7 +4,7 @@
-
+
PyNinja — PyNinja documentation
diff --git a/docs/index.html b/docs/index.html
index 582d899..72634e1 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -4,7 +4,7 @@
-
+
Welcome to PyNinja’s documentation! — PyNinja documentation
@@ -2284,7 +2284,7 @@ PyNinja - Monitor
Get CPU cores configured for a particular container using NanoCpus.
- Parameters:
@@ -2441,6 +2441,7 @@ PyNinja - Monitor
Returns:
diff --git a/pyninja/monitor/authenticator.py b/pyninja/monitor/authenticator.py
index 0fd5741..91a406e 100644
--- a/pyninja/monitor/authenticator.py
+++ b/pyninja/monitor/authenticator.py
@@ -161,7 +161,7 @@ async def validate_session(host: str, cookie_string: str, log: bool = True) -> N
if models.env.no_auth:
if log:
LOGGER.info("No auth set! Bypassing auth filters!")
- return True
+ return
try:
decoded_payload = base64.b64decode(cookie_string)
decoded_str = decoded_payload.decode("ascii")
diff --git a/pyninja/monitor/drive.py b/pyninja/monitor/drive.py
index 3d53866..5e9eec6 100644
--- a/pyninja/monitor/drive.py
+++ b/pyninja/monitor/drive.py
@@ -1,16 +1,17 @@
-import os
+import logging
from fastapi.responses import HTMLResponse
+LOGGER = logging.getLogger("uvicorn.default")
-def report():
- """Generated disk utility report and returns an HTMLResponse."""
- try:
- import pyudisk
- report_file = os.path.join(os.getcwd(), "disk-report.html")
- return HTMLResponse(
- content=pyudisk.generate_report(filepath=report_file, raw=True)
- )
- except Exception:
- return None
+async def report() -> HTMLResponse:
+ """Generates a disk report using pyudisk.
+
+ Returns:
+ HTMLResponse:
+ Returns an HTML response with the disk report.
+ """
+ import pyudisk
+
+ return HTMLResponse(content=pyudisk.generate_report(raw=True))
diff --git a/pyninja/monitor/resources.py b/pyninja/monitor/resources.py
index 5e247cf..5c6c977 100644
--- a/pyninja/monitor/resources.py
+++ b/pyninja/monitor/resources.py
@@ -63,7 +63,7 @@ def landing_page() -> Dict[str, Any]:
)
-def container_cpu_limit(container_name: str) -> int | None:
+def container_cpu_limit(container_name: str) -> int | float | None:
"""Get CPU cores configured for a particular container using NanoCpus.
Args:
diff --git a/pyninja/monitor/routes.py b/pyninja/monitor/routes.py
index 3b2731f..5c801d1 100644
--- a/pyninja/monitor/routes.py
+++ b/pyninja/monitor/routes.py
@@ -99,6 +99,7 @@ async def monitor_endpoint(
Args:
request: Reference to the FastAPI request object.
session_token: Session token set after verifying username and password.
+ render: Render option set by the UI.
Returns:
HTMLResponse:
@@ -132,8 +133,16 @@ async def monitor_endpoint(
)
elif render == "drive":
LOGGER.info("Rendering disk report!")
- response = monitor.drive.report()
- # If drive option is chosen during login page, the cookie is deleted once logged in!
+ try:
+ response = await monitor.drive.report()
+ # If drive option is chosen during login page, the cookie is deleted once logged in!
+ except Exception as error:
+ LOGGER.error(error)
+ response = await monitor.config.clear_session(
+ response=HTMLResponse(
+ content="Failed to generate disk report", status_code=500
+ )
+ )
response.delete_cookie(key="render")
return response
# todo: Implement a better way to handle this
@@ -145,6 +154,7 @@ async def monitor_endpoint(
"request": request,
"signin": "/login",
"version": f"v{version.__version__}",
+ "linux": models.OPERATING_SYSTEM == "linux",
},
)
diff --git a/pyninja/monitor/templates/index.html b/pyninja/monitor/templates/index.html
index 727aefd..ad515b3 100644
--- a/pyninja/monitor/templates/index.html
+++ b/pyninja/monitor/templates/index.html
@@ -150,9 +150,11 @@ This page requires JavaScript
-
-
-
+ {% if linux %}
+
+
+
+ {% endif %}