added tools and bugfix
This commit is contained in:
@@ -27,7 +27,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: glance-helper
|
- name: glance-helper
|
||||||
image: python:3.12-slim
|
image: python:3.12-bookworm
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
env:
|
env:
|
||||||
- name: IDOKEP_URL
|
- name: IDOKEP_URL
|
||||||
@@ -39,21 +39,29 @@ spec:
|
|||||||
- name: TANDOOR_PUBLIC_URL
|
- name: TANDOOR_PUBLIC_URL
|
||||||
value: https://tandoor.dooplex.hu
|
value: https://tandoor.dooplex.hu
|
||||||
- name: TANDOOR_TOKEN
|
- name: TANDOOR_TOKEN
|
||||||
value: 'tda_8a8b169c_5d1f_4962_83a2_0f2719c7d61a'
|
value: tda_8a8b169c_5d1f_4962_83a2_0f2719c7d61a
|
||||||
- name: GLANCE_HELPER_PUBLIC_URL
|
- name: GLANCE_HELPER_PUBLIC_URL
|
||||||
value: https://glance-helper.dooplex.hu
|
value: https://glance-helper.dooplex.hu
|
||||||
- name: DATA_DIR
|
- name: DATA_DIR
|
||||||
value: /data
|
value: /data
|
||||||
- name: GLANCE_HELPER_KEY
|
- name: GLANCE_HELPER_KEY
|
||||||
value: 'oplQqnLnJK2vErRVYJpvVUcSDBOSbCHZSbsYY2bwSifgTMfT'
|
value: oplQqnLnJK2vErRVYJpvVUcSDBOSbCHZSbsYY2bwSifgTMfT
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
- -lc
|
- -lc
|
||||||
args:
|
args:
|
||||||
- 'pip install --no-cache-dir fastapi uvicorn requests beautifulsoup4 prometheus-client
|
- 'set -eux;
|
||||||
&&
|
|
||||||
|
apt-get update;
|
||||||
|
|
||||||
|
apt-get install -y --no-install-recommends curl ca-certificates iputils-ping
|
||||||
|
dnsutils;
|
||||||
|
|
||||||
|
rm -rf /var/lib/apt/lists/*;
|
||||||
|
|
||||||
|
pip install --no-cache-dir fastapi uvicorn requests beautifulsoup4 prometheus-client;
|
||||||
|
|
||||||
python -c "import uvicorn; uvicorn.run(''app:APP'', host=''0.0.0.0'', port=8000)"
|
python -c "import uvicorn; uvicorn.run(''app:APP'', host=''0.0.0.0'', port=8000)"
|
||||||
|
|
||||||
@@ -79,24 +87,31 @@ metadata:
|
|||||||
namespace: glance-system
|
namespace: glance-system
|
||||||
data:
|
data:
|
||||||
app.py: "import os\nimport time\nimport re\nfrom typing import List, Dict, Any,\
|
app.py: "import os\nimport time\nimport re\nfrom typing import List, Dict, Any,\
|
||||||
\ Optional\n\nimport json\nimport random\nfrom datetime import datetime\nfrom zoneinfo import ZoneInfo\nfrom pathlib import Path\nfrom urllib.parse import urlparse, urlunparse\n\nimport requests\nfrom bs4 import BeautifulSoup\nfrom fastapi import\
|
\ Optional\n\nimport json\nimport random\nfrom datetime import datetime\nfrom\
|
||||||
\ FastAPI, Response, Request, HTTPException, Query\nfrom fastapi.responses import\
|
\ zoneinfo import ZoneInfo\nfrom pathlib import Path\nfrom urllib.parse import\
|
||||||
\ JSONResponse, RedirectResponse\nfrom prometheus_client import Counter, Histogram,\
|
\ urlparse, urlunparse\n\nimport requests\nfrom bs4 import BeautifulSoup\nfrom\
|
||||||
\ Gauge, generate_latest, CONTENT_TYPE_LATEST\n\nAPP = FastAPI()\n\nIDOKEP_URL\
|
\ fastapi import FastAPI, Response, Request, HTTPException, Query\nfrom fastapi.responses\
|
||||||
\ = os.getenv(\n \"IDOKEP_URL\",\n \"https://www.idokep.hu/idojaras/Budapest%20VIII.%20ker\"\
|
\ import JSONResponse, RedirectResponse\nfrom prometheus_client import Counter,\
|
||||||
|
\ Histogram, Gauge, generate_latest, CONTENT_TYPE_LATEST\n\nAPP = FastAPI()\n\n\
|
||||||
|
IDOKEP_URL = os.getenv(\n \"IDOKEP_URL\",\n \"https://www.idokep.hu/idojaras/Budapest%20VIII.%20ker\"\
|
||||||
,\n)\nPLACE_NAME = os.getenv(\"PLACE_NAME\", \"Budapest VIII. ker\")\nSOURCE_NAME\
|
,\n)\nPLACE_NAME = os.getenv(\"PLACE_NAME\", \"Budapest VIII. ker\")\nSOURCE_NAME\
|
||||||
\ = \"Id\u0151k\xE9p\"\n\nUA = os.getenv(\n \"USER_AGENT\",\n \"Mozilla/5.0\
|
\ = \"Id\u0151k\xE9p\"\n\nUA = os.getenv(\n \"USER_AGENT\",\n \"Mozilla/5.0\
|
||||||
\ (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome Safari\",\n\
|
\ (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome Safari\",\n\
|
||||||
)\n\n# Prometheus metrics (optional)\nSCRAPES = Counter(\"idokep_scrapes_total\"\
|
)\n\n# Glance-helper config\nDATA_DIR = os.getenv(\"DATA_DIR\", \"/data\")\nTANDOOR_INTERNAL_URL\
|
||||||
, \"Total Id\u0151k\xE9p scrapes\", [\"place\", \"status\"])\nSCRAPE_SECONDS =\
|
\ = os.getenv(\"TANDOOR_INTERNAL_URL\", \"\").rstrip(\"/\")\nTANDOOR_PUBLIC_URL\
|
||||||
\ Histogram(\"idokep_scrape_seconds\", \"Id\u0151k\xE9p scrape duration in seconds\"\
|
\ = os.getenv(\"TANDOOR_PUBLIC_URL\", \"\").rstrip(\"/\")\nGLANCE_HELPER_PUBLIC_URL\
|
||||||
, [\"place\"])\nCURRENT_TEMP = Gauge(\"idokep_current_temp_c\", \"Current temperature\
|
\ = os.getenv(\"GLANCE_HELPER_PUBLIC_URL\", \"\").rstrip(\"/\")\nGLANCE_HELPER_KEY\
|
||||||
\ in Celsius\", [\"place\"])\nDAILY_TMIN = Gauge(\"idokep_daily_tmin_c\", \"Daily\
|
\ = os.getenv(\"GLANCE_HELPER_KEY\", \"\")\n\n\n# Prometheus metrics (optional)\n\
|
||||||
\ minimum temperature in Celsius\", [\"place\", \"dow\"])\nDAILY_TMAX = Gauge(\"\
|
SCRAPES = Counter(\"idokep_scrapes_total\", \"Total Id\u0151k\xE9p scrapes\",\
|
||||||
idokep_daily_tmax_c\", \"Daily maximum temperature in Celsius\", [\"place\", \"\
|
\ [\"place\", \"status\"])\nSCRAPE_SECONDS = Histogram(\"idokep_scrape_seconds\"\
|
||||||
dow\"])\nHOURLY_TEMP = Gauge(\"idokep_hourly_temp_c\", \"Hourly temperature in\
|
, \"Id\u0151k\xE9p scrape duration in seconds\", [\"place\"])\nCURRENT_TEMP =\
|
||||||
\ Celsius\", [\"place\", \"time\"])\n\n\ndef _abs_url(maybe_relative: Optional[str])\
|
\ Gauge(\"idokep_current_temp_c\", \"Current temperature in Celsius\", [\"place\"\
|
||||||
\ -> Optional[str]:\n if not maybe_relative:\n return None\n if maybe_relative.startswith(\"\
|
])\nDAILY_TMIN = Gauge(\"idokep_daily_tmin_c\", \"Daily minimum temperature in\
|
||||||
|
\ Celsius\", [\"place\", \"dow\"])\nDAILY_TMAX = Gauge(\"idokep_daily_tmax_c\"\
|
||||||
|
, \"Daily maximum temperature in Celsius\", [\"place\", \"dow\"])\nHOURLY_TEMP\
|
||||||
|
\ = Gauge(\"idokep_hourly_temp_c\", \"Hourly temperature in Celsius\", [\"place\"\
|
||||||
|
, \"time\"])\n\n\ndef _abs_url(maybe_relative: Optional[str]) -> Optional[str]:\n\
|
||||||
|
\ if not maybe_relative:\n return None\n if maybe_relative.startswith(\"\
|
||||||
http://\") or maybe_relative.startswith(\"https://\"):\n return maybe_relative\n\
|
http://\") or maybe_relative.startswith(\"https://\"):\n return maybe_relative\n\
|
||||||
\ # Id\u0151k\xE9p uses /assets/... paths\n return \"https://www.idokep.hu\"\
|
\ # Id\u0151k\xE9p uses /assets/... paths\n return \"https://www.idokep.hu\"\
|
||||||
\ + maybe_relative\n\n\ndef _to_int_temp(s: str) -> Optional[float]:\n if not\
|
\ + maybe_relative\n\n\ndef _to_int_temp(s: str) -> Optional[float]:\n if not\
|
||||||
|
|||||||
Reference in New Issue
Block a user