-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Statistics. * Dockerfiles.
- Loading branch information
Showing
10 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ maps/ | |
osmps/ | ||
queue.json | ||
history.json | ||
map_directory/ | ||
map_directory/ | ||
local.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ tests/data/ | |
osmps/ | ||
queue.json | ||
history.json | ||
map_directory/ | ||
map_directory/ | ||
local.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ tqdm | |
types-tqdm | ||
scipy | ||
streamlit-folium | ||
schedule | ||
schedule | ||
python-dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Module for sending settings to the statistics server.""" | ||
|
||
import os | ||
from typing import Any | ||
|
||
import requests | ||
|
||
from maps4fs.logger import Logger | ||
|
||
logger = Logger() | ||
|
||
try: | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv("local.env") | ||
except Exception: | ||
pass | ||
|
||
STATS_HOST = os.getenv("STATS_HOST") | ||
if not STATS_HOST: | ||
print("STATS_HOST not set in environment") | ||
API_TOKEN = os.getenv("API_TOKEN") | ||
if not API_TOKEN: | ||
print("API_TOKEN not set in environment") | ||
|
||
|
||
def send_settings(endpoint: str, data: dict[str, Any]) -> None: | ||
"""Send settings to the statistics server. | ||
Arguments: | ||
endpoint (str): The endpoint to send the settings to. | ||
data (dict[str, Any]): The settings to send. | ||
""" | ||
headers = {"Authorization": f"Bearer {API_TOKEN}", "Content-Type": "application/json"} | ||
response = requests.post(endpoint, headers=headers, json=data, timeout=10) | ||
if response.status_code != 200: | ||
logger.error("Failed to send settings: %s", response.text) | ||
else: | ||
logger.info("Settings sent successfully") | ||
|
||
|
||
def send_main_settings(data: dict[str, Any]) -> None: | ||
"""Send main settings to the statistics server. | ||
Arguments: | ||
data (dict[str, Any]): The main settings to send. | ||
""" | ||
endpoint = f"{STATS_HOST}/receive_main_settings" | ||
send_settings(endpoint, data) | ||
|
||
|
||
def send_advanced_settings(data: dict[str, Any]) -> None: | ||
"""Send advanced settings to the statistics server. | ||
Arguments: | ||
data (dict[str, Any]): The advanced settings to send. | ||
""" | ||
endpoint = f"{STATS_HOST}/receive_advanced_settings" | ||
send_settings(endpoint, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ owslib | |
tqdm | ||
scipy | ||
streamlit-folium | ||
schedule | ||
schedule | ||
python-dotenv |