serverwatcher 6.dev4__py3-none-any.whl → 6.dev6__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/cli.py +231 -211
- {serverwatcher-6.dev4.dist-info → serverwatcher-6.dev6.dist-info}/METADATA +1 -1
- {serverwatcher-6.dev4.dist-info → serverwatcher-6.dev6.dist-info}/RECORD +6 -6
- {serverwatcher-6.dev4.dist-info → serverwatcher-6.dev6.dist-info}/WHEEL +0 -0
- {serverwatcher-6.dev4.dist-info → serverwatcher-6.dev6.dist-info}/licenses/LICENSE +0 -0
- {serverwatcher-6.dev4.dist-info → serverwatcher-6.dev6.dist-info}/top_level.txt +0 -0
serverwatcher/cli.py
CHANGED
|
@@ -11,10 +11,6 @@ from .watcher import ServerWatcher
|
|
|
11
11
|
|
|
12
12
|
setGlobalMaps(maps.ascii_colors)
|
|
13
13
|
|
|
14
|
-
# command registry
|
|
15
|
-
COMMANDS: dict[str, callable] = {}
|
|
16
|
-
|
|
17
|
-
|
|
18
14
|
# parsed arguments
|
|
19
15
|
@dataclass
|
|
20
16
|
class ParsedArgs:
|
|
@@ -36,10 +32,10 @@ def parse_line(raw: str) -> ParsedArgs:
|
|
|
36
32
|
params: dict[str, str] = {}
|
|
37
33
|
|
|
38
34
|
for token in parts[1:]:
|
|
39
|
-
if token.startswith(
|
|
35
|
+
if token.startswith('--'):
|
|
40
36
|
flags[token[2:]] = True
|
|
41
|
-
elif
|
|
42
|
-
key, value = token.split(
|
|
37
|
+
elif ':' in token:
|
|
38
|
+
key, value = token.split(':', 1)
|
|
43
39
|
params[key.lower()] = value
|
|
44
40
|
else:
|
|
45
41
|
positional.append(token)
|
|
@@ -47,49 +43,75 @@ def parse_line(raw: str) -> ParsedArgs:
|
|
|
47
43
|
return ParsedArgs(sub, positional, flags, params)
|
|
48
44
|
|
|
49
45
|
|
|
50
|
-
# command
|
|
51
|
-
class
|
|
52
|
-
def __init__(self,
|
|
53
|
-
self.
|
|
54
|
-
self.
|
|
46
|
+
# command model
|
|
47
|
+
class ParamSpec:
|
|
48
|
+
def __init__(self, name: str, type_: callable, default: object):
|
|
49
|
+
self.name = name
|
|
50
|
+
self.type = type_
|
|
51
|
+
self.default = default
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class FlagSpec:
|
|
55
|
+
def __init__(self, name: str):
|
|
56
|
+
self.name = name
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ChildSpec:
|
|
60
|
+
def __init__(self, name: str, func: callable):
|
|
61
|
+
self.name = name
|
|
62
|
+
self.func = func
|
|
63
|
+
self.params: dict[str, ParamSpec] = {}
|
|
64
|
+
self.flags: dict[str, FlagSpec] = {}
|
|
55
65
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
|
|
67
|
+
class CommandSpec:
|
|
68
|
+
def __init__(self, name: str, func: callable):
|
|
69
|
+
self.name = name
|
|
70
|
+
self.func = func
|
|
71
|
+
self.children: dict[str, ChildSpec] = {}
|
|
61
72
|
|
|
62
73
|
|
|
63
74
|
# DSL object
|
|
64
75
|
class CommandDSL:
|
|
65
76
|
def __init__(self):
|
|
66
|
-
self.registry: dict[str,
|
|
77
|
+
self.registry: dict[str, CommandSpec] = {}
|
|
78
|
+
self._current_command: CommandSpec | None = None
|
|
79
|
+
self._current_child: ChildSpec | None = None
|
|
67
80
|
|
|
68
81
|
def __call__(self, name: str):
|
|
69
82
|
def deco(func: callable):
|
|
70
|
-
|
|
83
|
+
cmd = CommandSpec(name, func)
|
|
84
|
+
self.registry[name] = cmd
|
|
85
|
+
self._current_command = cmd
|
|
86
|
+
self._current_child = None
|
|
71
87
|
return func
|
|
72
88
|
return deco
|
|
73
89
|
|
|
74
90
|
def child(self, name: str):
|
|
75
91
|
def deco(func: callable):
|
|
76
|
-
|
|
92
|
+
if self._current_command is None:
|
|
93
|
+
raise RuntimeError('child() used outside of a command')
|
|
94
|
+
child = ChildSpec(name, func)
|
|
95
|
+
self._current_command.children[name] = child
|
|
96
|
+
self._current_child = child
|
|
77
97
|
return func
|
|
78
98
|
return deco
|
|
79
99
|
|
|
80
100
|
def param(self, name: str, type: callable = str, default: object = None):
|
|
81
101
|
def deco(func: callable):
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
if self._current_child is None:
|
|
103
|
+
raise RuntimeError('param() used outside of a child')
|
|
104
|
+
spec = ParamSpec(name, type, default)
|
|
105
|
+
self._current_child.params[name] = spec
|
|
86
106
|
return func
|
|
87
107
|
return deco
|
|
88
108
|
|
|
89
109
|
def flag(self, name: str):
|
|
90
110
|
def deco(func: callable):
|
|
91
|
-
|
|
92
|
-
|
|
111
|
+
if self._current_child is None:
|
|
112
|
+
raise RuntimeError('flag() used outside of a child')
|
|
113
|
+
spec = FlagSpec(name)
|
|
114
|
+
self._current_child.flags[name] = spec
|
|
93
115
|
return func
|
|
94
116
|
return deco
|
|
95
117
|
|
|
@@ -97,53 +119,9 @@ class CommandDSL:
|
|
|
97
119
|
command = CommandDSL()
|
|
98
120
|
|
|
99
121
|
|
|
100
|
-
# bind nested functions (children, params, flags)
|
|
101
|
-
def bind_nested_functions(ctx: CommandContext, namespace: dict):
|
|
102
|
-
for name, obj in namespace.items():
|
|
103
|
-
if not callable(obj):
|
|
104
|
-
continue
|
|
105
|
-
|
|
106
|
-
# children
|
|
107
|
-
if hasattr(obj, "__child_name__"):
|
|
108
|
-
child_name = obj.__child_name__
|
|
109
|
-
ctx.children[child_name] = obj
|
|
110
|
-
|
|
111
|
-
# params / flags
|
|
112
|
-
if hasattr(obj, "__arg_kind__"):
|
|
113
|
-
kind = obj.__arg_kind__
|
|
114
|
-
argname = obj.__arg_name__
|
|
115
|
-
default = getattr(obj, "__arg_default__", None)
|
|
116
|
-
type_ = getattr(obj, "__arg_type__", str)
|
|
117
|
-
|
|
118
|
-
if kind == "flag":
|
|
119
|
-
present = argname in ctx.parsed.flags
|
|
120
|
-
|
|
121
|
-
def wrapper(present=present):
|
|
122
|
-
return present
|
|
123
|
-
|
|
124
|
-
namespace[name] = wrapper
|
|
125
|
-
|
|
126
|
-
elif kind == "param":
|
|
127
|
-
if argname in ctx.parsed.params:
|
|
128
|
-
raw = ctx.parsed.params[argname]
|
|
129
|
-
|
|
130
|
-
def wrapper(raw=raw, type_=type_, default=default):
|
|
131
|
-
try:
|
|
132
|
-
return type_(raw)
|
|
133
|
-
except Exception:
|
|
134
|
-
return default
|
|
135
|
-
|
|
136
|
-
namespace[name] = wrapper
|
|
137
|
-
else:
|
|
138
|
-
def wrapper(default=default):
|
|
139
|
-
return default
|
|
140
|
-
|
|
141
|
-
namespace[name] = wrapper
|
|
142
|
-
|
|
143
|
-
|
|
144
122
|
# base CLI
|
|
145
123
|
class CLIBase:
|
|
146
|
-
def safePrint(self, msg: object =
|
|
124
|
+
def safePrint(self, msg: object = '', end: str = '\n') -> None:
|
|
147
125
|
print(str(msg), end=end)
|
|
148
126
|
|
|
149
127
|
def bprint(self, msg: object) -> None:
|
|
@@ -156,25 +134,58 @@ def dispatch(cli: CLIBase, line: str):
|
|
|
156
134
|
if not parsed.subcommand:
|
|
157
135
|
return
|
|
158
136
|
|
|
159
|
-
|
|
160
|
-
if
|
|
161
|
-
cli.safePrint(f
|
|
137
|
+
cmd = command.registry.get(parsed.subcommand)
|
|
138
|
+
if cmd is None:
|
|
139
|
+
cli.safePrint(f'Unknown command \'{parsed.subcommand}\'')
|
|
162
140
|
return
|
|
163
141
|
|
|
164
|
-
|
|
165
|
-
|
|
142
|
+
# run command handler to allow any setup logic
|
|
143
|
+
cmd.func(cli, parsed)
|
|
144
|
+
|
|
145
|
+
# first positional selects child
|
|
146
|
+
child_name = parsed.positional[0] if parsed.positional else None
|
|
147
|
+
if not child_name:
|
|
148
|
+
cli.safePrint('Missing subcommand')
|
|
149
|
+
return
|
|
150
|
+
|
|
151
|
+
child = cmd.children.get(child_name)
|
|
152
|
+
if child is None:
|
|
153
|
+
cli.safePrint(f'Unknown subcommand \'{child_name}\'')
|
|
154
|
+
return
|
|
155
|
+
|
|
156
|
+
# second positional is the main argument (stat, etc.)
|
|
157
|
+
stat = parsed.positional[1] if len(parsed.positional) > 1 else None
|
|
158
|
+
|
|
159
|
+
# build wrappers for params and flags
|
|
160
|
+
wrappers: dict[str, callable] = {}
|
|
161
|
+
|
|
162
|
+
for pname, pspec in child.params.items():
|
|
163
|
+
if pname in parsed.params:
|
|
164
|
+
raw = parsed.params[pname]
|
|
166
165
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
166
|
+
def make_param(raw=raw, pspec=pspec):
|
|
167
|
+
try:
|
|
168
|
+
return pspec.type(raw)
|
|
169
|
+
except Exception:
|
|
170
|
+
return pspec.default
|
|
171
|
+
|
|
172
|
+
wrappers[pname] = make_param
|
|
173
|
+
else:
|
|
174
|
+
def make_default(pspec=pspec):
|
|
175
|
+
return pspec.default
|
|
176
|
+
|
|
177
|
+
wrappers[pname] = make_default
|
|
178
|
+
|
|
179
|
+
for fname, _fspec in child.flags.items():
|
|
180
|
+
present = fname in parsed.flags
|
|
181
|
+
|
|
182
|
+
def make_flag(present=present):
|
|
183
|
+
return present
|
|
184
|
+
|
|
185
|
+
wrappers[fname] = make_flag
|
|
186
|
+
|
|
187
|
+
# call child with stat and wrappers injected
|
|
188
|
+
return child.func(cli, stat, **wrappers)
|
|
178
189
|
|
|
179
190
|
|
|
180
191
|
# buffering stdout
|
|
@@ -185,7 +196,7 @@ class BufferingStdout:
|
|
|
185
196
|
|
|
186
197
|
def write(self, text: str) -> None:
|
|
187
198
|
if self.buffer.enabled and text.strip():
|
|
188
|
-
self.buffer.captured.append(text.rstrip(
|
|
199
|
+
self.buffer.captured.append(text.rstrip('\n'))
|
|
189
200
|
self.real_stdout.write(text)
|
|
190
201
|
|
|
191
202
|
def flush(self) -> None:
|
|
@@ -194,7 +205,7 @@ class BufferingStdout:
|
|
|
194
205
|
|
|
195
206
|
# main CLI
|
|
196
207
|
class WatcherCLI(cmd.Cmd, CLIBase):
|
|
197
|
-
prompt =
|
|
208
|
+
prompt = ''
|
|
198
209
|
|
|
199
210
|
def __init__(self, watcher: ServerWatcher):
|
|
200
211
|
self.watcher = watcher
|
|
@@ -202,7 +213,7 @@ class WatcherCLI(cmd.Cmd, CLIBase):
|
|
|
202
213
|
self.real_stdout = sys.stdout
|
|
203
214
|
self.cli_stdout = BufferingStdout(self.buffer, self.real_stdout)
|
|
204
215
|
super().__init__(stdout=self.cli_stdout)
|
|
205
|
-
self.outputMode =
|
|
216
|
+
self.outputMode = 'both'
|
|
206
217
|
self.use_rawinput = False
|
|
207
218
|
|
|
208
219
|
def read_line_raw(self) -> str:
|
|
@@ -213,10 +224,10 @@ class WatcherCLI(cmd.Cmd, CLIBase):
|
|
|
213
224
|
chars: list[str] = []
|
|
214
225
|
while True:
|
|
215
226
|
ch = sys.stdin.read(1)
|
|
216
|
-
if ch in (
|
|
227
|
+
if ch in ('\r', '\n'):
|
|
217
228
|
break
|
|
218
229
|
chars.append(ch)
|
|
219
|
-
return
|
|
230
|
+
return ''.join(chars)
|
|
220
231
|
finally:
|
|
221
232
|
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
|
222
233
|
|
|
@@ -227,7 +238,7 @@ class WatcherCLI(cmd.Cmd, CLIBase):
|
|
|
227
238
|
line = line.strip()
|
|
228
239
|
if not line:
|
|
229
240
|
continue
|
|
230
|
-
if self.buffer.enabled and not line.startswith(
|
|
241
|
+
if self.buffer.enabled and not line.startswith('view'):
|
|
231
242
|
self.buffer.captured.append(line)
|
|
232
243
|
stop = await asyncio.to_thread(self.onecmd, line)
|
|
233
244
|
if stop:
|
|
@@ -243,121 +254,127 @@ class WatcherCLI(cmd.Cmd, CLIBase):
|
|
|
243
254
|
return dispatch(self, line)
|
|
244
255
|
|
|
245
256
|
def printHeader(self) -> None:
|
|
246
|
-
self.safePrint(res(
|
|
247
|
-
self.safePrint(res(
|
|
248
|
-
self.safePrint(res(
|
|
249
|
-
self.safePrint(
|
|
257
|
+
self.safePrint(res('<yellow>-----------------------------------'))
|
|
258
|
+
self.safePrint(res('<yellow>-------- <aqua>ServerWatcher CLI <yellow>--------'))
|
|
259
|
+
self.safePrint(res('<yellow>-----------------------------------'))
|
|
260
|
+
self.safePrint('\n')
|
|
250
261
|
|
|
251
262
|
|
|
252
263
|
# stats command
|
|
253
|
-
@command(
|
|
254
|
-
def stats(self: WatcherCLI,
|
|
264
|
+
@command('stats')
|
|
265
|
+
def stats(self: WatcherCLI, parsed: ParsedArgs):
|
|
266
|
+
# no setup needed for stats right now
|
|
267
|
+
pass
|
|
255
268
|
|
|
256
|
-
@command.child("get")
|
|
257
|
-
def get(stat: str):
|
|
258
269
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
270
|
+
@command.child('get')
|
|
271
|
+
def stats_get(self: WatcherCLI, stat: str,
|
|
272
|
+
rounding, mode, raw, formatted, no_formatted):
|
|
262
273
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
274
|
+
@command.param('rounding', type=int, default=2)
|
|
275
|
+
def _rounding(value):
|
|
276
|
+
return value
|
|
266
277
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
278
|
+
@command.param('mode', type=str, default='current')
|
|
279
|
+
def _mode(value):
|
|
280
|
+
return value
|
|
270
281
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
282
|
+
@command.flag('raw')
|
|
283
|
+
def _raw():
|
|
284
|
+
return False
|
|
274
285
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
@command.flag('formatted')
|
|
287
|
+
def _formatted():
|
|
288
|
+
return True
|
|
278
289
|
|
|
279
|
-
|
|
290
|
+
@command.flag('no-formatted')
|
|
291
|
+
def _no_formatted():
|
|
292
|
+
return False
|
|
293
|
+
|
|
294
|
+
self.watcher.server.refresh()
|
|
295
|
+
|
|
296
|
+
gb = not raw()
|
|
297
|
+
if formatted():
|
|
298
|
+
fmt = True
|
|
299
|
+
elif no_formatted():
|
|
300
|
+
fmt = False
|
|
301
|
+
else:
|
|
302
|
+
fmt = True
|
|
303
|
+
|
|
304
|
+
unit = ''
|
|
305
|
+
match stat:
|
|
306
|
+
case 'ram':
|
|
307
|
+
value = self.watcher.server.getRAM(rounding=rounding(), gb=gb)
|
|
308
|
+
name = 'RAM'
|
|
309
|
+
unit = ' GB' if gb else ' MB'
|
|
310
|
+
case 'cpu':
|
|
311
|
+
value = self.watcher.server.getCPU(rounding=rounding())
|
|
312
|
+
name = 'CPU'
|
|
313
|
+
unit = '%'
|
|
314
|
+
case 'uptime':
|
|
315
|
+
value = self.watcher.server.getUptime(formatted=fmt)
|
|
316
|
+
name = 'Uptime'
|
|
317
|
+
unit = '' if fmt else 'ms'
|
|
318
|
+
case 'tps':
|
|
319
|
+
value = self.watcher.server.getTPS(rounding=rounding(), mode=mode())
|
|
320
|
+
name = 'TPS'
|
|
321
|
+
case 'players':
|
|
322
|
+
value = self.watcher.server.getPlayers()
|
|
323
|
+
name = 'Players'
|
|
324
|
+
case 'version':
|
|
325
|
+
value = self.watcher.server.version
|
|
326
|
+
name = 'Minecraft version'
|
|
327
|
+
case 'platform':
|
|
328
|
+
value = self.watcher.server.platform
|
|
329
|
+
name = 'Server platform'
|
|
330
|
+
case _:
|
|
331
|
+
return self.safePrint('Unknown stat')
|
|
332
|
+
|
|
333
|
+
self.bprint(f'{name}: {value}{unit}')
|
|
280
334
|
|
|
281
|
-
self.watcher.server.refresh()
|
|
282
335
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
else:
|
|
289
|
-
fmt = True
|
|
290
|
-
|
|
291
|
-
unit = ""
|
|
292
|
-
match stat:
|
|
293
|
-
case "ram":
|
|
294
|
-
value = self.watcher.server.getRAM(rounding=rounding(), gb=gb)
|
|
295
|
-
name = "RAM"
|
|
296
|
-
unit = " GB" if gb else " MB"
|
|
297
|
-
case "cpu":
|
|
298
|
-
value = self.watcher.server.getCPU(rounding=rounding())
|
|
299
|
-
name = "CPU"
|
|
300
|
-
unit = "%"
|
|
301
|
-
case "uptime":
|
|
302
|
-
value = self.watcher.server.getUptime(formatted=fmt)
|
|
303
|
-
name = "Uptime"
|
|
304
|
-
unit = "" if fmt else "ms"
|
|
305
|
-
case "tps":
|
|
306
|
-
value = self.watcher.server.getTPS(rounding=rounding(), mode=mode())
|
|
307
|
-
name = "TPS"
|
|
308
|
-
case "players":
|
|
309
|
-
value = self.watcher.server.getPlayers()
|
|
310
|
-
name = "Players"
|
|
311
|
-
case "version":
|
|
312
|
-
value = self.watcher.server.version
|
|
313
|
-
name = "Minecraft version"
|
|
314
|
-
case "platform":
|
|
315
|
-
value = self.watcher.server.platform
|
|
316
|
-
name = "Server platform"
|
|
317
|
-
case _:
|
|
318
|
-
return self.safePrint("Unknown stat")
|
|
319
|
-
|
|
320
|
-
self.bprint(f"{name}: {value}{unit}")
|
|
336
|
+
# view command
|
|
337
|
+
@command('view')
|
|
338
|
+
def view(self: WatcherCLI, parsed: ParsedArgs):
|
|
339
|
+
# no setup needed for view
|
|
340
|
+
pass
|
|
321
341
|
|
|
322
342
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
self.
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
self.printHeader()
|
|
343
|
-
for msg in self.watcher.router.buffer.captured:
|
|
344
|
-
self.safePrint(msg)
|
|
345
|
-
|
|
346
|
-
bind_nested_functions(ctx, locals())
|
|
343
|
+
@command.child('cli')
|
|
344
|
+
def view_cli(self: WatcherCLI, _stat: str):
|
|
345
|
+
self.watcher.router.disableOriginOutput()
|
|
346
|
+
self.outputMode = 'cli'
|
|
347
|
+
self.buffer.enabled = True
|
|
348
|
+
utils.clearTerminal()
|
|
349
|
+
self.printHeader()
|
|
350
|
+
for msg in self.buffer.captured:
|
|
351
|
+
self.safePrint(msg)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
@command.child('watcher')
|
|
355
|
+
def view_watcher(self: WatcherCLI, _stat: str):
|
|
356
|
+
self.watcher.router.enableOriginOutput()
|
|
357
|
+
self.outputMode = 'both'
|
|
358
|
+
utils.clearTerminal()
|
|
359
|
+
self.printHeader()
|
|
360
|
+
for msg in self.watcher.router.buffer.captured:
|
|
361
|
+
self.safePrint(msg)
|
|
347
362
|
|
|
348
363
|
|
|
349
364
|
# clear command
|
|
350
|
-
@command(
|
|
351
|
-
def clear(self: WatcherCLI,
|
|
365
|
+
@command('clear')
|
|
366
|
+
def clear(self: WatcherCLI, parsed: ParsedArgs):
|
|
367
|
+
# no setup needed
|
|
368
|
+
pass
|
|
352
369
|
|
|
353
|
-
@command.param("buffer", type=str, default="true")
|
|
354
|
-
def buffer_param(value: str):
|
|
355
|
-
return value.lower() == "true"
|
|
356
370
|
|
|
357
|
-
|
|
371
|
+
@command.child('buffer')
|
|
372
|
+
def clear_buffer(self: WatcherCLI, _stat: str, buffer):
|
|
373
|
+
@command.param('buffer', type=str, default='true')
|
|
374
|
+
def _buffer(value: str):
|
|
375
|
+
return value.lower() == 'true'
|
|
358
376
|
|
|
359
|
-
|
|
360
|
-
if buf:
|
|
377
|
+
if buffer():
|
|
361
378
|
self.buffer.clear()
|
|
362
379
|
|
|
363
380
|
utils.clearTerminal()
|
|
@@ -365,27 +382,30 @@ def clear(self: WatcherCLI, ctx: CommandContext):
|
|
|
365
382
|
|
|
366
383
|
|
|
367
384
|
# watcher command
|
|
368
|
-
@command(
|
|
369
|
-
def watcher(self: WatcherCLI,
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
@command('watcher')
|
|
386
|
+
def watcher(self: WatcherCLI, parsed: ParsedArgs):
|
|
387
|
+
# no setup needed
|
|
388
|
+
pass
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
@command.child('restart')
|
|
392
|
+
def watcher_restart(self: WatcherCLI, _stat: str):
|
|
393
|
+
self.watcher.restart_and_wait()
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
@command.child('schedule')
|
|
397
|
+
def watcher_schedule(self: WatcherCLI, _stat: str, minutes):
|
|
398
|
+
@command.param('minutes', type=int, default=None)
|
|
399
|
+
def _minutes(value: int):
|
|
400
|
+
return value
|
|
401
|
+
|
|
402
|
+
val = minutes()
|
|
403
|
+
if val is None:
|
|
404
|
+
return self.safePrint('Usage: watcher schedule <minutes>')
|
|
405
|
+
self.watcher.schedule_restart(val)
|
|
406
|
+
|
|
390
407
|
|
|
391
|
-
|
|
408
|
+
@command.child('shutdown')
|
|
409
|
+
def watcher_shutdown(self: WatcherCLI, _stat: str):
|
|
410
|
+
self.watcher.shutdown()
|
|
411
|
+
return True
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
serverwatcher/__init__.py,sha256=Q_afN0XU29n48d6Gf0-LT2lLo3RiTWlHRT6rC_fYbjw,486
|
|
2
2
|
serverwatcher/__main__.py,sha256=XjGcQ_-8p4ttuVYlYEvYKUEvcAsvZUQaEA0mX0ajRbU,3097
|
|
3
|
-
serverwatcher/cli.py,sha256=
|
|
3
|
+
serverwatcher/cli.py,sha256=PUQW0yoTPRsV7hFqy07TN5z9ISDQNvbUBGfrqiuWNyU,11116
|
|
4
4
|
serverwatcher/validator.py,sha256=aD6GHOz1S5VFC93Mj89WO9vZG1bTjhg7QZbdlvQf4wo,1778
|
|
5
5
|
serverwatcher/watcher.py,sha256=ZiocJpeyhKTGOwYYak36MXNEFpLnpdl9v6BnMPGrBmM,13593
|
|
6
6
|
serverwatcher/configclasses/__init__.py,sha256=YS0KhxtAJGdMcaiFstqTRNxIPLnR7s9v3Tkt5h2uKE4,182
|
|
@@ -12,8 +12,8 @@ serverwatcher/defaultconfigs/messages.yaml,sha256=jSVEl-RYqPHhe5U5KLl8zfJtUBymvy
|
|
|
12
12
|
serverwatcher/defaultconfigs/watcher.yaml,sha256=GlAEKCuzFUSF6wWOqQLFL1CeuPltb1ltfYxFe_FUClw,723
|
|
13
13
|
serverwatcher/tests/test.py,sha256=yvt0ExSpKCwmWGs5tXS_MTmWLcEW6gCOwz0PR4_tgek,1768
|
|
14
14
|
serverwatcher/tests/test2.py,sha256=pDFB3LTZZXdrkofCF9tDGlkUzNXq3AzK225Ww6H2EAw,1702
|
|
15
|
-
serverwatcher-6.
|
|
16
|
-
serverwatcher-6.
|
|
17
|
-
serverwatcher-6.
|
|
18
|
-
serverwatcher-6.
|
|
19
|
-
serverwatcher-6.
|
|
15
|
+
serverwatcher-6.dev6.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
16
|
+
serverwatcher-6.dev6.dist-info/METADATA,sha256=DGtR-Ua5UqCYb_Tj9ZIQbXXa1UrN9JXZAEChAG427lM,2646
|
|
17
|
+
serverwatcher-6.dev6.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
18
|
+
serverwatcher-6.dev6.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
19
|
+
serverwatcher-6.dev6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|