serverwatcher 6.dev27__py3-none-any.whl → 6.dev29__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.
- serverwatcher/livecli.py +24 -4
- serverwatcher/watcher.py +2 -2
- serverwatcher/watchercli.py +4 -4
- {serverwatcher-6.dev27.dist-info → serverwatcher-6.dev29.dist-info}/METADATA +1 -1
- {serverwatcher-6.dev27.dist-info → serverwatcher-6.dev29.dist-info}/RECORD +8 -8
- {serverwatcher-6.dev27.dist-info → serverwatcher-6.dev29.dist-info}/WHEEL +0 -0
- {serverwatcher-6.dev27.dist-info → serverwatcher-6.dev29.dist-info}/licenses/LICENSE +0 -0
- {serverwatcher-6.dev27.dist-info → serverwatcher-6.dev29.dist-info}/top_level.txt +0 -0
serverwatcher/livecli.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# livecli.py
|
|
2
|
-
|
|
3
1
|
from dataclasses import dataclass
|
|
4
2
|
import cmd
|
|
5
3
|
import sys
|
|
@@ -41,6 +39,7 @@ class ChildSpec:
|
|
|
41
39
|
self.flags = {}
|
|
42
40
|
self.args_meta = {}
|
|
43
41
|
self.desc = self._doc(func)
|
|
42
|
+
self._extract_args_block()
|
|
44
43
|
self._parse_args_meta()
|
|
45
44
|
self._infer_arg_requirement()
|
|
46
45
|
|
|
@@ -48,6 +47,27 @@ class ChildSpec:
|
|
|
48
47
|
d = f.__doc__
|
|
49
48
|
return d.strip().splitlines()[0].strip() if d else None
|
|
50
49
|
|
|
50
|
+
def _extract_args_block(self):
|
|
51
|
+
src = inspect.getsource(self.func)
|
|
52
|
+
lines = src.splitlines()
|
|
53
|
+
block = []
|
|
54
|
+
in_block = False
|
|
55
|
+
for line in lines:
|
|
56
|
+
s = line.strip()
|
|
57
|
+
if s.startswith('__args__'):
|
|
58
|
+
in_block = True
|
|
59
|
+
continue
|
|
60
|
+
if in_block:
|
|
61
|
+
if s.startswith("'''") or s.startswith('"""'):
|
|
62
|
+
if not block:
|
|
63
|
+
continue
|
|
64
|
+
else:
|
|
65
|
+
break
|
|
66
|
+
block.append(line)
|
|
67
|
+
if block:
|
|
68
|
+
raw = '\n'.join(l.strip() for l in block)
|
|
69
|
+
setattr(self.func, '__args__', raw)
|
|
70
|
+
|
|
51
71
|
def _parse_args_meta(self):
|
|
52
72
|
raw = getattr(self.func, '__args__', None)
|
|
53
73
|
if not raw:
|
|
@@ -134,8 +154,8 @@ class CommandSpec:
|
|
|
134
154
|
def _infer_namespace(self):
|
|
135
155
|
src = inspect.getsource(self.func)
|
|
136
156
|
body = src.split('\n', 1)[1]
|
|
137
|
-
stripped = [l.strip() for l in body.splitlines() if l.strip()]
|
|
138
|
-
return stripped == []
|
|
157
|
+
stripped = [l.strip() for l in body.splitlines() if l.strip() not in ('', 'pass')]
|
|
158
|
+
return stripped == []
|
|
139
159
|
|
|
140
160
|
def param(self, name, type=str, default=None):
|
|
141
161
|
def deco(f):
|
serverwatcher/watcher.py
CHANGED
|
@@ -237,7 +237,7 @@ class ServerWatcher:
|
|
|
237
237
|
if self.config.debug:
|
|
238
238
|
self.router.debug(f'RAM: {snap.ram}/{self.watcherconfig.threshold_ram}')
|
|
239
239
|
self.router.debug(f'CPU: {snap.cpu}/{self.watcherconfig.threshold_cpu}')
|
|
240
|
-
self.router.debug(f'Uptime: {snap.uptime // 3600}/{self.watcherconfig.threshold_uptime}')
|
|
240
|
+
self.router.debug(f'Uptime: {(snap.uptime // 1000) // 3600}/{self.watcherconfig.threshold_uptime}') # outputs raw ms, must convert to seconds first. this was changed in 6-dev.28
|
|
241
241
|
self.router.debug(f'TPS: {snap.tps}/{self.watcherconfig.threshold_tps}')
|
|
242
242
|
self.router.debug(f'Players: {snap.players}/{self.server.max_players}')
|
|
243
243
|
|
|
@@ -249,7 +249,7 @@ class ServerWatcher:
|
|
|
249
249
|
restart_reasons.append(self.res(self.messages.reason_cpu, cpu=snap.cpu, threshold=self.watcherconfig.threshold_cpu))
|
|
250
250
|
pro += self.watcherconfig.weight_cpu
|
|
251
251
|
|
|
252
|
-
if snap.uptime // 3600 >= self.watcherconfig.threshold_uptime:
|
|
252
|
+
if (snap.uptime // 1000) // 3600 >= self.watcherconfig.threshold_uptime: # outputs raw ms, must convert to seconds first. this was changed in 6-dev.28
|
|
253
253
|
restart_reasons.append(self.res(self.messages.reason_uptime, uptime=snap.uptime_formatted, threshold=self.watcherconfig.threshold_uptime))
|
|
254
254
|
pro += self.watcherconfig.weight_uptime
|
|
255
255
|
|
serverwatcher/watchercli.py
CHANGED
|
@@ -6,15 +6,15 @@ from .livecli import LiveCLI, command
|
|
|
6
6
|
setGlobalMaps(ascii_colors)
|
|
7
7
|
|
|
8
8
|
class BufferingStdout:
|
|
9
|
-
def __init__(self, buffer,
|
|
9
|
+
def __init__(self, buffer, real_stdout):
|
|
10
10
|
self.buffer = buffer
|
|
11
|
-
self.
|
|
11
|
+
self.real_stdout = real_stdout
|
|
12
12
|
def write(self, text):
|
|
13
13
|
if self.buffer.enabled and text.strip():
|
|
14
14
|
self.buffer.captured.append(text.rstrip('\n'))
|
|
15
|
-
self.
|
|
15
|
+
self.real_stdout.write(text)
|
|
16
16
|
def flush(self):
|
|
17
|
-
self.
|
|
17
|
+
self.real_stdout.flush()
|
|
18
18
|
|
|
19
19
|
class WatcherCLI(LiveCLI):
|
|
20
20
|
def __init__(self, watcher: ServerWatcher):
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
serverwatcher/__init__.py,sha256=Q_afN0XU29n48d6Gf0-LT2lLo3RiTWlHRT6rC_fYbjw,486
|
|
2
2
|
serverwatcher/__main__.py,sha256=5geaZQKgLSP1pxnpQPgFy9zAwyyPyTInlbcFxb9OiEw,3016
|
|
3
|
-
serverwatcher/livecli.py,sha256=
|
|
3
|
+
serverwatcher/livecli.py,sha256=2yjVajoh97y9FDAchz2QLx7_xuags85SG-bYPkHIA0Y,11926
|
|
4
4
|
serverwatcher/validator.py,sha256=aD6GHOz1S5VFC93Mj89WO9vZG1bTjhg7QZbdlvQf4wo,1778
|
|
5
|
-
serverwatcher/watcher.py,sha256=
|
|
6
|
-
serverwatcher/watchercli.py,sha256=
|
|
5
|
+
serverwatcher/watcher.py,sha256=QfWuyDIPZ59yToIdX5PdPMRcJrq-kFUW8d9Q39mA0uE,13769
|
|
6
|
+
serverwatcher/watchercli.py,sha256=UHPBRhpeVHIQOKBowXQR5KZj4C1YYl8FT3ygXuAlib0,3968
|
|
7
7
|
serverwatcher/configclasses/__init__.py,sha256=YS0KhxtAJGdMcaiFstqTRNxIPLnR7s9v3Tkt5h2uKE4,182
|
|
8
8
|
serverwatcher/configclasses/config.py,sha256=1Upor55QFE4UIOqL9ZYa4U5kbda48GG9HWdRXg8mb_Y,2418
|
|
9
9
|
serverwatcher/configclasses/messages.py,sha256=iOkCvwagngW4aeWD5I6hi6cqqDkzEsFJsLHSuqK-P1s,3467
|
|
@@ -13,8 +13,8 @@ serverwatcher/defaultconfigs/messages.yaml,sha256=jSVEl-RYqPHhe5U5KLl8zfJtUBymvy
|
|
|
13
13
|
serverwatcher/defaultconfigs/watcher.yaml,sha256=GlAEKCuzFUSF6wWOqQLFL1CeuPltb1ltfYxFe_FUClw,723
|
|
14
14
|
serverwatcher/tests/test.py,sha256=CqGBdfktVIyXz6wMoa6TBbEPlPvp_lA_VSzBuxwxrfs,2551
|
|
15
15
|
serverwatcher/tests/test2.py,sha256=DcvYiidXTe3SSOpiSPQ585YBN4PXrDMs0a3ZW_TbBsg,9564
|
|
16
|
-
serverwatcher-6.
|
|
17
|
-
serverwatcher-6.
|
|
18
|
-
serverwatcher-6.
|
|
19
|
-
serverwatcher-6.
|
|
20
|
-
serverwatcher-6.
|
|
16
|
+
serverwatcher-6.dev29.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
17
|
+
serverwatcher-6.dev29.dist-info/METADATA,sha256=zETtddrDTu9RXpKy4iqnq0fWCCg_9sAKsVIghmtStDs,2647
|
|
18
|
+
serverwatcher-6.dev29.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
19
|
+
serverwatcher-6.dev29.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
20
|
+
serverwatcher-6.dev29.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|