serverwatcher 5.1__tar.gz → 5.1.2__tar.gz

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.
Files changed (21) hide show
  1. {serverwatcher-5.1/src/serverwatcher.egg-info → serverwatcher-5.1.2}/PKG-INFO +1 -1
  2. {serverwatcher-5.1 → serverwatcher-5.1.2}/pyproject.toml +1 -1
  3. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/__init__.py +1 -1
  4. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/configclasses/messages.py +7 -7
  5. serverwatcher-5.1.2/src/serverwatcher/configclasses/watcher.py +30 -0
  6. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/validator.py +9 -9
  7. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/watcher.py +21 -21
  8. {serverwatcher-5.1 → serverwatcher-5.1.2/src/serverwatcher.egg-info}/PKG-INFO +1 -1
  9. serverwatcher-5.1/src/serverwatcher/configclasses/watcher.py +0 -30
  10. {serverwatcher-5.1 → serverwatcher-5.1.2}/LICENSE +0 -0
  11. {serverwatcher-5.1 → serverwatcher-5.1.2}/README.md +0 -0
  12. {serverwatcher-5.1 → serverwatcher-5.1.2}/setup.cfg +0 -0
  13. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/configclasses/__init__.py +0 -0
  14. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/configclasses/config.py +0 -0
  15. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/defaultconfigs/config.yaml +0 -0
  16. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/defaultconfigs/messages.yaml +0 -0
  17. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher/defaultconfigs/watcher.yaml +0 -0
  18. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher.egg-info/SOURCES.txt +0 -0
  19. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
  20. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher.egg-info/requires.txt +0 -0
  21. {serverwatcher-5.1 → serverwatcher-5.1.2}/src/serverwatcher.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverwatcher
3
- Version: 5.1
3
+ Version: 5.1.2
4
4
  Summary: A HungerLib-powered Minecraft server automation engine.
5
5
  Author: iFamished
6
6
  License: GPL-3.0
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "serverwatcher"
10
- version = "5.1"
10
+ version = "5.1.2"
11
11
  description = "A HungerLib-powered Minecraft server automation engine."
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.10"
@@ -7,7 +7,7 @@ except PackageNotFoundError:
7
7
  __version__ = '0.0.0'
8
8
 
9
9
  from .watcher import ServerWatcher
10
- from .configclasses.global_config import GlobalConfig
10
+ from .configclasses.config import GlobalConfig
11
11
  from .configclasses.messages import MessagesConfig
12
12
  from .configclasses.watcher import WatcherConfig
13
13
 
@@ -44,13 +44,13 @@ class MessagesConfig:
44
44
  pro_restart_splash: str = yaml_key("reasons.pro_restart_splash")
45
45
  anti_restart_splash: str = yaml_key("reasons.anti_restart_splash")
46
46
 
47
- reasons.restart_soon: str = yaml_key("reasons.restart_soon")
48
- reasons.ram: str = yaml_key("reasons.ram")
49
- reasons.cpu: str = yaml_key("reasons.cpu")
50
- reasons.uptime: str = yaml_key("reasons.uptime")
51
- reasons.tps: str = yaml_key("reasons.tps")
52
- reasons.low_uptime: str = yaml_key("reasons.low_uptime")
53
- reasons.players: str = yaml_key("reasons.players")
47
+ reason_restart_soon: str = yaml_key("reasons.restart_soon")
48
+ reason_ram: str = yaml_key("reasons.ram")
49
+ reason_cpu: str = yaml_key("reasons.cpu")
50
+ reason_uptime: str = yaml_key("reasons.uptime")
51
+ reason_tps: str = yaml_key("reasons.tps")
52
+ reason_low_uptime: str = yaml_key("reasons.low_uptime")
53
+ reason_players: str = yaml_key("reasons.players")
54
54
 
55
55
  pro_restart_number: str = yaml_key("reasons.pro_restart_number")
56
56
  anti_restart_number: str = yaml_key("reasons.anti_restart_number")
@@ -0,0 +1,30 @@
1
+ from dataclasses import dataclass, field
2
+
3
+ def yaml_key(path: str):
4
+ return field(metadata={"yaml_key": path})
5
+
6
+ @dataclass
7
+ class WatcherConfig:
8
+ schedule_control: bool = yaml_key("schedule_control.enabled")
9
+ restart_soon_id: int = yaml_key("schedule_control.restart_soon_id")
10
+
11
+ threshold_ram: int = yaml_key("thresholds.ram")
12
+ threshold_cpu: int = yaml_key("thresholds.cpu")
13
+ threshold_uptime_hours: int = yaml_key("thresholds.uptime")
14
+ threshold_tps: float = yaml_key("thresholds.tps")
15
+
16
+ weight_restart_soon: int = yaml_key("weights.restart_soon")
17
+ weight_ram: int = yaml_key("weights.ram")
18
+ weight_cpu: int = yaml_key("weights.cpu")
19
+ weight_uptime: int = yaml_key("weights.uptime")
20
+ weight_tps: int = yaml_key("weights.tps")
21
+
22
+ weight_low_uptime: int = yaml_key("weights.low_uptime")
23
+ weight_per_player: int = yaml_key("weights.per_player")
24
+
25
+ low_gap_minutes: int = yaml_key("gaps.low_gap_minutes")
26
+ high_gap_minutes: int = yaml_key("gaps.high_gap_minutes")
27
+
28
+ restart_wait_seconds: int = yaml_key("restart.wait_seconds")
29
+ restart_timeout: int = yaml_key("restart.online_timeout")
30
+ restart_online_interval: int = yaml_key("restart.online_interval")
@@ -60,17 +60,17 @@ def validate_global_config(config, errors):
60
60
 
61
61
 
62
62
  def validate_watcher_config(watcherconfig, errors):
63
- if watcherconfig.restart.wait_seconds < 1:
64
- errors.append(f"restart.wait_seconds: must be >= 1 (got {watcherconfig.restart.wait_seconds})")
63
+ if watcherconfig.restart_wait_seconds < 1:
64
+ errors.append(f"restart_wait_seconds: must be >= 1 (got {watcherconfig.restart_wait_seconds})")
65
65
 
66
- if watcherconfig.thresholds.cpu <= 0:
67
- errors.append(f"thresholds.cpu: must not be less than 1 (got {watcherconfig.thresholds.cpu})")
66
+ if watcherconfig.threshold_cpu <= 0:
67
+ errors.append(f"threshold_cpu: must not be less than 1 (got {watcherconfig.threshold_cpu})")
68
68
 
69
- if watcherconfig.thresholds.ram <= 0:
70
- errors.append(f"thresholds.ram: must be > 0 (got {watcherconfig.thresholds.ram})")
69
+ if watcherconfig.threshold_ram <= 0:
70
+ errors.append(f"threshold_ram: must be > 0 (got {watcherconfig.threshold_ram})")
71
71
 
72
- if watcherconfig.thresholds.tps <= 0 or watcherconfig.thresholds.tps > 20:
73
- errors.append(f"thresholds.tps: must be 1–20 (got {watcherconfig.thresholds.tps})")
72
+ if watcherconfig.threshold_tps <= 0 or watcherconfig.threshold_tps > 20:
73
+ errors.append(f"threshold_tps: must be 1–20 (got {watcherconfig.threshold_tps})")
74
74
 
75
75
 
76
76
  def validate_messages_config(messages, errors):
@@ -108,7 +108,7 @@ def validate_all():
108
108
  errors = []
109
109
  defaults = []
110
110
 
111
- config = loadConfig("config/global.yaml", "/defaultconfigs/global.yaml", GlobalConfig)
111
+ config = loadConfig("config/config.yaml", "/defaultconfigs/config.yaml", GlobalConfig)
112
112
  messages = loadConfig("config/messages.yaml", "/defaultconfigs/messages.yaml", MessagesConfig)
113
113
  watcher = loadConfig("config/watcher.yaml", "/defaultconfigs/watcher.yaml", WatcherConfig)
114
114
 
@@ -97,13 +97,13 @@ class ServerWatcher:
97
97
  self.origin.disableSchedule(self.watcherconfig.restart_soon_id)
98
98
  self.server.restart()
99
99
  self.say(self.messages.restart_action_sent)
100
- time.sleep(self.watcherconfig.restart.wait_seconds)
100
+ time.sleep(self.watcherconfig.restart_wait_seconds)
101
101
 
102
102
  self.say(self.messages.log_status_check, level="warn")
103
103
  alive = waitForOnline(
104
104
  self.server,
105
- timeout=self.watcherconfig.restart.timeout,
106
- interval=self.watcherconfig.restart.online_interval,
105
+ timeout=self.watcherconfig.restart_timeout,
106
+ interval=self.watcherconfig.restart_online_interval,
107
107
  )
108
108
 
109
109
  if alive:
@@ -161,37 +161,37 @@ class ServerWatcher:
161
161
  no_restart_reasons = []
162
162
 
163
163
  if self.watcherconfig.schedule_control and self.server.getSchedule(self.watcherconfig.restart_soon_id)["is_active"]:
164
- restart_reasons.append(self.messages.reasons.restart_soon)
165
- pro += self.watcherconfig.weights.restart_soon
164
+ restart_reasons.append(self.messages.reason_restart_soon)
165
+ pro += self.watcherconfig.weight_restart_soon
166
166
 
167
- if snap.ram >= self.watcherconfig.thresholds.ram:
168
- restart_reasons.append(self.fmt(self.messages.reasons.ram, ram=snap.ram, threshold=self.watcherconfig.thresholds.ram))
169
- pro += int(round(snap.ram, 0) - (self.watcherconfig.thresholds.ram - 1))
167
+ if snap.ram >= self.watcherconfig.threshold_ram:
168
+ restart_reasons.append(self.fmt(self.messages.reason_ram, ram=snap.ram, threshold=self.watcherconfig.threshold_ram))
169
+ pro += int(round(snap.ram, 0) - (self.watcherconfig.threshold_ram - 1))
170
170
 
171
- if snap.cpu >= self.watcherconfig.thresholds.cpu:
172
- restart_reasons.append(self.fmt(self.messages.reasons.cpu, cpu=snap.cpu, threshold=self.watcherconfig.thresholds.cpu))
173
- pro += self.watcherconfig.weights.cpu
171
+ if snap.cpu >= self.watcherconfig.threshold_cpu:
172
+ restart_reasons.append(self.fmt(self.messages.reason_cpu, cpu=snap.cpu, threshold=self.watcherconfig.threshold_cpu))
173
+ pro += self.watcherconfig.weight_cpu
174
174
 
175
- if snap.uptime // 3600 >= self.watcherconfig.thresholds.uptime:
175
+ if snap.uptime // 3600 >= self.watcherconfig.threshold_uptime:
176
176
  restart_reasons.append(
177
- self.fmt(self.messages.reasons.uptime, uptime=snap.uptime_formatted,
178
- threshold=self.watcherconfig.thresholds.uptime)
177
+ self.fmt(self.messages.reason_uptime, uptime=snap.uptime_formatted,
178
+ threshold=self.watcherconfig.threshold_uptime)
179
179
  )
180
180
  pro += self.watcherconfig.weight_uptime
181
181
 
182
- if (snap.tps if snap.tps is not None else 0) <= self.watcherconfig.thresholds.tps:
183
- restart_reasons.append(self.fmt(self.messages.reasons.tps, tps=snap.tps, threshold=self.watcherconfig.thresholds.tps))
184
- pro += self.watcherconfig.weights.tps
182
+ if (snap.tps if snap.tps is not None else 0) <= self.watcherconfig.threshold_tps:
183
+ restart_reasons.append(self.fmt(self.messages.reason_tps, tps=snap.tps, threshold=self.watcherconfig.threshold_tps))
184
+ pro += self.watcherconfig.weight_tps
185
185
 
186
186
  if snap.uptime // 60 < 30:
187
- no_restart_reasons.append(self.fmt(self.messages.reasons.low_uptime, uptime=snap.uptime_formatted))
188
- anti += self.watcherconfig.weights.low_uptime
187
+ no_restart_reasons.append(self.fmt(self.messages.reason_low_uptime, uptime=snap.uptime_formatted))
188
+ anti += self.watcherconfig.weight_low_uptime
189
189
 
190
190
  if snap.players > 0:
191
191
  verb = "are" if snap.players != 1 else "is"
192
192
  plural = "players" if snap.players != 1 else "player"
193
- no_restart_reasons.append(self.fmt(self.messages.reasons.players, verb=verb, count=snap.players, plural=plural))
194
- anti += snap.players * self.watcherconfig.weights.per_player
193
+ no_restart_reasons.append(self.fmt(self.messages.reason_players, verb=verb, count=snap.players, plural=plural))
194
+ anti += snap.players * self.watcherconfig.weight_per_player
195
195
 
196
196
  if restart_reasons:
197
197
  self.say(self.messages.pro_restart_splash, level="warn")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverwatcher
3
- Version: 5.1
3
+ Version: 5.1.2
4
4
  Summary: A HungerLib-powered Minecraft server automation engine.
5
5
  Author: iFamished
6
6
  License: GPL-3.0
@@ -1,30 +0,0 @@
1
- from dataclasses import dataclass, field
2
-
3
- def yaml_key(path: str):
4
- return field(metadata={"yaml_key": path})
5
-
6
- @dataclass
7
- class WatcherConfig:
8
- schedule_control: bool = yaml_key("schedule_control.enabled")
9
- restart_soon_id: int = yaml_key("schedule_control.restart_soon_id")
10
-
11
- thresholds.ram: int = yaml_key("thresholds.ram")
12
- thresholds.cpu: int = yaml_key("thresholds.cpu")
13
- thresholds.uptime_hours: int = yaml_key("thresholds.uptime")
14
- thresholds.tps: float = yaml_key("thresholds.tps")
15
-
16
- weights.restart_soon: int = yaml_key("weights.restart_soon")
17
- weights.ram: int = yaml_key("weights.ram")
18
- weights.cpu: int = yaml_key("weights.cpu")
19
- weights.uptime: int = yaml_key("weights.uptime")
20
- weights.tps: int = yaml_key("weights.tps")
21
-
22
- weights.low_uptime: int = yaml_key("weights.low_uptime")
23
- weights.per_player: int = yaml_key("weights.per_player")
24
-
25
- low_gap_minutes: int = yaml_key("gaps.low_gap_minutes")
26
- high_gap_minutes: int = yaml_key("gaps.high_gap_minutes")
27
-
28
- restart.wait_seconds: int = yaml_key("restart.wait_seconds")
29
- restart.timeout: int = yaml_key("restart.online_timeout")
30
- restart.online_interval: int = yaml_key("restart.online_interval")
File without changes
File without changes
File without changes