Make app start/stop observable
This commit is contained in:
parent
929e8d9a60
commit
d3455b5dcd
@ -63,11 +63,15 @@ def uninstall(app_name):
|
|||||||
|
|
||||||
def start(app_name):
|
def start(app_name):
|
||||||
# Start all application containers
|
# Start all application containers
|
||||||
App(app_name).start()
|
queue = ActionQueue()
|
||||||
|
queue.start_app(App(app_name))
|
||||||
|
queue.process()
|
||||||
|
|
||||||
def stop(app_name):
|
def stop(app_name):
|
||||||
# Stop all application containers
|
# Stop all application containers
|
||||||
App(app_name).stop()
|
queue = ActionQueue()
|
||||||
|
queue.stop_app(App(app_name))
|
||||||
|
queue.process()
|
||||||
|
|
||||||
def status(app_name):
|
def status(app_name):
|
||||||
# Print status of all application containers
|
# Print status of all application containers
|
||||||
|
@ -133,15 +133,23 @@ class App:
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def start(self):
|
def start(self, observer=None):
|
||||||
# Start all application containers
|
# Start all application containers
|
||||||
|
if observer:
|
||||||
|
observer.units_total = len(self.containers)
|
||||||
for container in self.containers:
|
for container in self.containers:
|
||||||
container.start()
|
container.start()
|
||||||
|
if observer:
|
||||||
|
observer.units_done += 1
|
||||||
|
|
||||||
def stop(self):
|
def stop(self, observer=None):
|
||||||
# Stop all application containers
|
# Stop all application containers
|
||||||
|
if observer:
|
||||||
|
observer.units_total = len(self.containers)
|
||||||
for container in self.containers:
|
for container in self.containers:
|
||||||
container.stop()
|
container.stop()
|
||||||
|
if observer:
|
||||||
|
observer.units_done += 1
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
# Return status fo all application containers
|
# Return status fo all application containers
|
||||||
|
@ -54,6 +54,12 @@ class ActionQueue:
|
|||||||
def uninstall_app(self, app):
|
def uninstall_app(self, app):
|
||||||
self.queue.append(ActionItem(f'Uninstalling application {app.name}', app.uninstall))
|
self.queue.append(ActionItem(f'Uninstalling application {app.name}', app.uninstall))
|
||||||
|
|
||||||
|
def start_app(self, app):
|
||||||
|
self.queue.append(ActionItem(f'Starting application {app.name}', app.start))
|
||||||
|
|
||||||
|
def stop_app(self, app):
|
||||||
|
self.queue.append(ActionItem(f'Stopping application {app.name}', app.stop))
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
index = 0
|
index = 0
|
||||||
queue_length = len(self.queue)
|
queue_length = len(self.queue)
|
||||||
|
Loading…
Reference in New Issue
Block a user