Skip to content

Commit

Permalink
Notification in run: Preparing for automation, please wait (#948)
Browse files Browse the repository at this point in the history
Co-authored-by: Rick Elrod <rick@elrod.me>
  • Loading branch information
cidrblock and relrod authored Feb 14, 2022
1 parent 7ca6c2f commit c8ec130
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog-fragments.d/948.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added state notification when running a playbook during initialization. -- by {user}`cidrblock`
13 changes: 13 additions & 0 deletions src/ansible_navigator/actions/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from ..ui_framework import Interaction
from ..ui_framework import dict_to_form
from ..ui_framework import form_to_dict
from ..ui_framework import nonblocking_notification
from ..ui_framework import warning_notification
from ..utils import abs_user_path
from ..utils import human_time
Expand Down Expand Up @@ -204,6 +205,8 @@ def __init__(self, args: ApplicationConfiguration):
self.runner: CommandAsync
self._runner_finished: bool
self._auto_scroll = False
#: Flag when the first message is received from runner
self._first_message_received: bool = False

self._plays = Step(
name="plays",
Expand Down Expand Up @@ -279,6 +282,14 @@ def run(self, interaction: Interaction, app: AppPublic) -> Union[Interaction, No

self.steps.append(self._plays)

# Show a notification until the first the first message from the queue is processed
if self._subaction_type == "run":
messages = ["Preparing for automation, please wait..."]
notification = nonblocking_notification(messages=messages)
interaction.ui.show(notification)
while not self._first_message_received:
self.update()

while True:
self.update()

Expand Down Expand Up @@ -603,6 +614,8 @@ def _dequeue(self) -> None:
"""Drain the runner queue"""
drain_count = 0
while not self._queue.empty():
if not self._first_message_received:
self._first_message_received = True
message = self._queue.get()
self._handle_message(message)
drain_count += 1
Expand Down

0 comments on commit c8ec130

Please sign in to comment.