serverwatcher 5.28__tar.gz → 5.29__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.28/src/serverwatcher.egg-info → serverwatcher-5.29}/PKG-INFO +1 -1
  2. {serverwatcher-5.28 → serverwatcher-5.29}/pyproject.toml +1 -1
  3. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/configclasses/messages.py +4 -36
  4. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/configclasses/watcher.py +4 -4
  5. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/defaultconfigs/messages.yaml +4 -0
  6. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/watcher.py +28 -25
  7. {serverwatcher-5.28 → serverwatcher-5.29/src/serverwatcher.egg-info}/PKG-INFO +1 -1
  8. {serverwatcher-5.28 → serverwatcher-5.29}/LICENSE +0 -0
  9. {serverwatcher-5.28 → serverwatcher-5.29}/README.md +0 -0
  10. {serverwatcher-5.28 → serverwatcher-5.29}/setup.cfg +0 -0
  11. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/__init__.py +0 -0
  12. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/__main__.py +0 -0
  13. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/configclasses/__init__.py +0 -0
  14. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/configclasses/config.py +0 -0
  15. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/defaultconfigs/config.yaml +0 -0
  16. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/defaultconfigs/watcher.yaml +0 -0
  17. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher/validator.py +0 -0
  18. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher.egg-info/SOURCES.txt +0 -0
  19. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher.egg-info/dependency_links.txt +0 -0
  20. {serverwatcher-5.28 → serverwatcher-5.29}/src/serverwatcher.egg-info/requires.txt +0 -0
  21. {serverwatcher-5.28 → serverwatcher-5.29}/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.28
3
+ Version: 5.29
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.28"
10
+ version = "5.29"
11
11
  description = "A HungerLib-powered Minecraft server automation engine."
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.14"
@@ -10,24 +10,8 @@ class MessagesConfig:
10
10
 
11
11
  broadcast_restart_at: str = 'broadcast_restart_at'
12
12
 
13
- minute_120: str = 'broadcast_minutes.120'
14
- minute_60: str = 'broadcast_minutes.60'
15
- minute_45: str = 'broadcast_minutes.45'
16
- minute_30: str = 'broadcast_minutes.30'
17
- minute_15: str = 'broadcast_minutes.15'
18
- minute_5: str = 'broadcast_minutes.5'
19
- minute_1: str = 'broadcast_minutes.1'
20
-
21
- second_10: str = 'broadcast_seconds.10'
22
- second_9: str = 'broadcast_seconds.9'
23
- second_8: str = 'broadcast_seconds.8'
24
- second_7: str = 'broadcast_seconds.7'
25
- second_6: str = 'broadcast_seconds.6'
26
- second_5: str = 'broadcast_seconds.5'
27
- second_4: str = 'broadcast_seconds.4'
28
- second_3: str = 'broadcast_seconds.3'
29
- second_2: str = 'broadcast_seconds.2'
30
- second_1: str = 'broadcast_seconds.1'
13
+ minute_template: str = 'broadcast_templates.minutes'
14
+ second_template: str = 'broadcast_templates.seconds'
31
15
 
32
16
  startup: str = 'logging.startup'
33
17
  status_check: str = 'logging.status_check'
@@ -66,24 +50,8 @@ class fallbacks:
66
50
 
67
51
  broadcast_restart_at = '{prefix} The server will restart at {time} CDT.'
68
52
 
69
- minute_120 = '{prefix} The server will restart in 2 hours.'
70
- minute_60 = '{prefix} The server will restart in 1 hour.'
71
- minute_45 = '{prefix} The server will restart in 45 minutes.'
72
- minute_30 = '{prefix} The server will restart in 30 minutes.'
73
- minute_15 = '{prefix} The server will restart in 15 minutes.'
74
- minute_5 = '{prefix} The server will restart in 5 minutes.'
75
- minute_1 = '{prefix} The server will restart in 1 minute.'
76
-
77
- second_10 = '{prefix} <red>The server is restarting in 10 seconds!'
78
- second_9 = '{prefix} <red>The server is restarting in 9 seconds!'
79
- second_8 = '{prefix} <red>The server is restarting in 8 seconds!'
80
- second_7 = '{prefix} <red>The server is restarting in 7 seconds!'
81
- second_6 = '{prefix} <red>The server is restarting in 6 seconds!'
82
- second_5 = '{prefix} <red>The server is restarting in 5 seconds!'
83
- second_4 = '{prefix} <red>The server is restarting in 4 seconds!'
84
- second_3 = '{prefix} <red>The server is restarting in 3 seconds!'
85
- second_2 = '{prefix} <red>The server is restarting in 2 seconds!'
86
- second_1 = '{prefix} <red>The server is restarting in 1 second!'
53
+ minute_template = '{prefix} Restart in {n} minute{s}!'
54
+ second_template = '{prefix} <red>Restarting in {n} second{s}!'
87
55
 
88
56
  startup = 'ServerWatcher is running!'
89
57
  status_check = 'Checking server status...'
@@ -7,8 +7,8 @@ class WatcherConfig:
7
7
 
8
8
  watch_interval: int = 'watch_interval'
9
9
 
10
- sample_duration: float = 'sampling.duration'
11
- sample_interval: float = 'sampling.interval'
10
+ sample_duration: float | int = 'sampling.duration'
11
+ sample_interval: float | int = 'sampling.interval'
12
12
  sample_outlier_drop: int = 'sampling.drop_outliers'
13
13
 
14
14
  threshold_ram: int = 'thresholds.ram'
@@ -40,8 +40,8 @@ class WatcherConfig:
40
40
  class fallbacks:
41
41
  watch_interval = 300
42
42
 
43
- sample_duration = 5.0
44
- sample_interval = 1.0
43
+ sample_duration = 5
44
+ sample_interval = 1
45
45
  sample_outlier_drop = 1
46
46
 
47
47
  threshold_ram = 6
@@ -43,6 +43,10 @@ bullet: '-'
43
43
 
44
44
  broadcast_restart_at: '{prefix} The server will restart at {time} CDT.'
45
45
 
46
+ broadcast_templates:
47
+ minutes: '{prefix} Restart in {n} minute{s}!'
48
+ seconds: '{prefix} <red>Restarting in {n} second{s}!'
49
+
46
50
  broadcast_minutes: {}
47
51
  broadcast_seconds: {}
48
52
 
@@ -131,26 +131,35 @@ class ServerWatcher:
131
131
 
132
132
  self.router.broadcast(self.messages.broadcast_restart_at, time=time_str)
133
133
 
134
- # minute callbacks
134
+ def plural(n):
135
+ return '' if n == 1 else 's'
136
+
137
+ # minute message generator
138
+ def minute_msg(n):
139
+ raw = self.messages.minute_template
140
+ return self.res(raw, n=n, s=plural(n))
141
+
142
+ # second message generator
143
+ def second_msg(n):
144
+ raw = self.messages.second_template
145
+ return self.res(raw, n=n, s=plural(n))
146
+
147
+ # minute callbacks using template
135
148
  minute_callbacks = {
136
- int(k.split("_")[1]): (
137
- lambda raw=self.messages.as_map()[k]:
138
- (self.router.broadcast(self.res(raw)),
139
- self.router.origin(raw))
140
- )
141
- for k in self.messages.as_map()
142
- if k.startswith("minute_")
149
+ n: (lambda n=n: (
150
+ self.router.broadcast(minute_msg(n)),
151
+ self.router.origin(minute_msg(n))
152
+ ))
153
+ for n in self.watcherconfig.snap_minutes
143
154
  }
144
155
 
145
- # second callbacks
156
+ # second callbacks using template
146
157
  second_callbacks = {
147
- int(k.split("_")[1]): (
148
- lambda raw=self.messages.as_map()[k]:
149
- (self.router.broadcast(self.res(raw)),
150
- self.router.origin(raw))
151
- )
152
- for k in self.messages.as_map()
153
- if k.startswith("second_")
158
+ n: (lambda n=n: (
159
+ self.router.broadcast(second_msg(n)),
160
+ self.router.origin(second_msg(n))
161
+ ))
162
+ for n in range(1, 11)
154
163
  }
155
164
 
156
165
  utils.runCountdownEvents(
@@ -180,21 +189,15 @@ class ServerWatcher:
180
189
  no_restart_reasons = []
181
190
 
182
191
  if snap.ram >= self.watcherconfig.threshold_ram:
183
- restart_reasons.append(
184
- self.res(self.messages.reason_ram, ram=snap.ram, threshold=self.watcherconfig.threshold_ram)
185
- )
192
+ restart_reasons.append(self.res(self.messages.reason_ram, ram=snap.ram, threshold=self.watcherconfig.threshold_ram))
186
193
  pro += int(round(snap.ram, 0) - (self.watcherconfig.threshold_ram - 1))
187
194
 
188
195
  if snap.cpu >= self.watcherconfig.threshold_cpu:
189
- restart_reasons.append(
190
- self.res(self.messages.reason_cpu, cpu=snap.cpu, threshold=self.watcherconfig.threshold_cpu)
191
- )
196
+ restart_reasons.append(self.res(self.messages.reason_cpu, cpu=snap.cpu, threshold=self.watcherconfig.threshold_cpu))
192
197
  pro += self.watcherconfig.weight_cpu
193
198
 
194
199
  if snap.uptime // 3600 >= self.watcherconfig.threshold_uptime:
195
- restart_reasons.append(
196
- self.res(self.messages.reason_uptime, uptime=snap.uptime_formatted, threshold=self.watcherconfig.threshold_uptime)
197
- )
200
+ restart_reasons.append(self.res(self.messages.reason_uptime, uptime=snap.uptime_formatted, threshold=self.watcherconfig.threshold_uptime))
198
201
  pro += self.watcherconfig.weight_uptime
199
202
 
200
203
  if (snap.tps if snap.tps is not None else 20) <= self.watcherconfig.threshold_tps:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverwatcher
3
- Version: 5.28
3
+ Version: 5.29
4
4
  Summary: A HungerLib-powered Minecraft server automation engine.
5
5
  Author: iFamished
6
6
  License: GPL-3.0
File without changes
File without changes
File without changes