mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 18:19:26 +08:00
add: check alas prev status
This commit is contained in:
@@ -237,6 +237,14 @@ from module.instance_watcher import InstanceWatcher
|
||||
|
||||
|
||||
class ProcessManager(ProcessManager):
|
||||
class DetailInstanceStatus:
|
||||
Alive = 1
|
||||
NoRenderables = 2
|
||||
ManualStop = 3
|
||||
Finish = 4
|
||||
Update = 5
|
||||
Error = 6
|
||||
|
||||
def start(self, *args, **kwargs):
|
||||
super().start(*args, **kwargs)
|
||||
InstanceWatcher.get_instance().try_add_instance(self.config_name)
|
||||
@@ -244,3 +252,23 @@ class ProcessManager(ProcessManager):
|
||||
def stop(self, *args, **kwargs):
|
||||
InstanceWatcher.get_instance().remove_instance(self.config_name)
|
||||
super().stop(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def detailed_instance_status(self) -> int:
|
||||
if self.alive:
|
||||
return ProcessManager.DetailInstanceStatus.Alive
|
||||
elif len(self.renderables) == 0:
|
||||
return ProcessManager.DetailInstanceStatus.NoRenderables
|
||||
else:
|
||||
console = Console(no_color=True)
|
||||
with console.capture() as capture:
|
||||
console.print(self.renderables[-1])
|
||||
s = capture.get().strip()
|
||||
if s.endswith("Reason: Manual stop"):
|
||||
return ProcessManager.DetailInstanceStatus.ManualStop
|
||||
elif s.endswith("Reason: Finish"):
|
||||
return ProcessManager.DetailInstanceStatus.Finish
|
||||
elif s.endswith("Reason: Update"):
|
||||
return ProcessManager.DetailInstanceStatus.Update
|
||||
else:
|
||||
return ProcessManager.DetailInstanceStatus.Error
|
||||
|
||||
Reference in New Issue
Block a user