maps4fs 1.8.219__py3-none-any.whl → 1.8.221__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.
- maps4fs/generator/map.py +19 -0
- maps4fs/generator/statistics.py +59 -0
- {maps4fs-1.8.219.dist-info → maps4fs-1.8.221.dist-info}/METADATA +1 -1
- {maps4fs-1.8.219.dist-info → maps4fs-1.8.221.dist-info}/RECORD +7 -6
- {maps4fs-1.8.219.dist-info → maps4fs-1.8.221.dist-info}/LICENSE.md +0 -0
- {maps4fs-1.8.219.dist-info → maps4fs-1.8.221.dist-info}/WHEEL +0 -0
- {maps4fs-1.8.219.dist-info → maps4fs-1.8.221.dist-info}/top_level.txt +0 -0
maps4fs/generator/map.py
CHANGED
@@ -20,6 +20,7 @@ from maps4fs.generator.settings import (
|
|
20
20
|
SplineSettings,
|
21
21
|
TextureSettings,
|
22
22
|
)
|
23
|
+
from maps4fs.generator.statistics import send_advanced_settings, send_main_settings
|
23
24
|
from maps4fs.logger import Logger
|
24
25
|
|
25
26
|
|
@@ -74,6 +75,19 @@ class Map:
|
|
74
75
|
self.coordinates = coordinates
|
75
76
|
self.map_directory = map_directory
|
76
77
|
|
78
|
+
try:
|
79
|
+
main_settings = {
|
80
|
+
"game": game.code,
|
81
|
+
"coordinates": coordinates,
|
82
|
+
"size": size,
|
83
|
+
"rotation": rotation,
|
84
|
+
"dtm_provider": dtm_provider.name(),
|
85
|
+
"custom_osm": bool(custom_osm),
|
86
|
+
}
|
87
|
+
send_main_settings(main_settings)
|
88
|
+
except Exception as e:
|
89
|
+
self.logger.error("Error sending main settings: %s", e)
|
90
|
+
|
77
91
|
log_entry = ""
|
78
92
|
log_entry += f"Map instance created for Game: {game.code}. "
|
79
93
|
log_entry += f"Coordinates: {coordinates}. Size: {size}. Rotation: {rotation}. "
|
@@ -128,6 +142,11 @@ class Map:
|
|
128
142
|
for setting in settings:
|
129
143
|
settings_json[setting.__class__.__name__] = setting.model_dump()
|
130
144
|
|
145
|
+
try:
|
146
|
+
send_advanced_settings(settings_json)
|
147
|
+
except Exception as e:
|
148
|
+
self.logger.error("Error sending advanced settings: %s", e)
|
149
|
+
|
131
150
|
save_path = os.path.join(self.map_directory, "generation_settings.json")
|
132
151
|
|
133
152
|
with open(save_path, "w", encoding="utf-8") as file:
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"""Module for sending settings to the statistics server."""
|
2
|
+
|
3
|
+
import os
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
import requests
|
7
|
+
|
8
|
+
from maps4fs.logger import Logger
|
9
|
+
|
10
|
+
logger = Logger()
|
11
|
+
|
12
|
+
try:
|
13
|
+
from dotenv import load_dotenv
|
14
|
+
|
15
|
+
load_dotenv("local.env")
|
16
|
+
except Exception:
|
17
|
+
pass
|
18
|
+
|
19
|
+
STATS_HOST = os.getenv("STATS_HOST")
|
20
|
+
if not STATS_HOST:
|
21
|
+
print("STATS_HOST not set in environment")
|
22
|
+
API_TOKEN = os.getenv("API_TOKEN")
|
23
|
+
if not API_TOKEN:
|
24
|
+
print("API_TOKEN not set in environment")
|
25
|
+
|
26
|
+
|
27
|
+
def send_settings(endpoint: str, data: dict[str, Any]) -> None:
|
28
|
+
"""Send settings to the statistics server.
|
29
|
+
|
30
|
+
Arguments:
|
31
|
+
endpoint (str): The endpoint to send the settings to.
|
32
|
+
data (dict[str, Any]): The settings to send.
|
33
|
+
"""
|
34
|
+
headers = {"Authorization": f"Bearer {API_TOKEN}", "Content-Type": "application/json"}
|
35
|
+
response = requests.post(endpoint, headers=headers, json=data, timeout=10)
|
36
|
+
if response.status_code != 200:
|
37
|
+
logger.error("Failed to send settings: %s", response.text)
|
38
|
+
else:
|
39
|
+
logger.info("Settings sent successfully")
|
40
|
+
|
41
|
+
|
42
|
+
def send_main_settings(data: dict[str, Any]) -> None:
|
43
|
+
"""Send main settings to the statistics server.
|
44
|
+
|
45
|
+
Arguments:
|
46
|
+
data (dict[str, Any]): The main settings to send.
|
47
|
+
"""
|
48
|
+
endpoint = f"{STATS_HOST}/receive_main_settings"
|
49
|
+
send_settings(endpoint, data)
|
50
|
+
|
51
|
+
|
52
|
+
def send_advanced_settings(data: dict[str, Any]) -> None:
|
53
|
+
"""Send advanced settings to the statistics server.
|
54
|
+
|
55
|
+
Arguments:
|
56
|
+
data (dict[str, Any]): The advanced settings to send.
|
57
|
+
"""
|
58
|
+
endpoint = f"{STATS_HOST}/receive_advanced_settings"
|
59
|
+
send_settings(endpoint, data)
|
@@ -3,9 +3,10 @@ maps4fs/logger.py,sha256=HQrDyj72mUjVYo25aR_-_SxVn2rfFjDCNbj-JKJdSnE,1488
|
|
3
3
|
maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
4
4
|
maps4fs/generator/dem.py,sha256=a9B3tatj7pzvvdLIyLw7BA3JoDTibFczpqiXJnx054U,12864
|
5
5
|
maps4fs/generator/game.py,sha256=NZaxj5z7WzMiHzAvQyr-TvVjGoHgqGldM6ZsItuYyzA,11292
|
6
|
-
maps4fs/generator/map.py,sha256=
|
6
|
+
maps4fs/generator/map.py,sha256=D63BZGfC_D7AsloCPApv8rcnrEuffT2_XyUS6Tjj_zg,11838
|
7
7
|
maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
|
8
8
|
maps4fs/generator/settings.py,sha256=d3NaMpyFh-IZWtHV2UQMMqUfuPP76lv7mIN2d7mORqA,6747
|
9
|
+
maps4fs/generator/statistics.py,sha256=itae_EeAxxEMTpV_G3SsX6soUqDz8uGEFoit8GVrV5o,1621
|
9
10
|
maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
|
10
11
|
maps4fs/generator/component/background.py,sha256=ppxK2RheCYrLRnBkLeZUst6Ciopo9Z_zUyjS-n8YwGE,18794
|
11
12
|
maps4fs/generator/component/config.py,sha256=RitKgFDZPzjA1fi8GcEi1na75qqaueUvpcITHjBvCXc,3674
|
@@ -52,8 +53,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
|
|
52
53
|
maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
|
53
54
|
maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
|
54
55
|
maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
|
55
|
-
maps4fs-1.8.
|
56
|
-
maps4fs-1.8.
|
57
|
-
maps4fs-1.8.
|
58
|
-
maps4fs-1.8.
|
59
|
-
maps4fs-1.8.
|
56
|
+
maps4fs-1.8.221.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
57
|
+
maps4fs-1.8.221.dist-info/METADATA,sha256=mKcyPDVMXiJWond1oRLdKSysUvETuZEwzkduzTmNAHw,45770
|
58
|
+
maps4fs-1.8.221.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
59
|
+
maps4fs-1.8.221.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
60
|
+
maps4fs-1.8.221.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|