Flush confirmation messages

Confirmation messages for cluster, profile, policy, receiver and node
deletions are printed using sys.stdout.write.  However sys.stdout.write
output is line-buffered [1].  Since the confirmation message does not
contain a newline, the message may not appear in the user's terminal.

[1] https://docs.python.org/3/library/sys.html#sys.stdout

Change-Id: I829811df362bcfd7d074523958d2aa5232da6f09
Closes-Bug: 1861042
This commit is contained in:
Duc Truong 2020-01-27 23:10:06 +00:00
parent 6d2ad89b1f
commit d9430360be
5 changed files with 5 additions and 0 deletions

View File

@ -345,6 +345,7 @@ class DeleteCluster(command.Command):
sys.stdout.write( sys.stdout.write(
_("Are you sure you want to delete this cluster(s)" _("Are you sure you want to delete this cluster(s)"
" [y/N]?")) " [y/N]?"))
sys.stdout.flush()
prompt_response = sys.stdin.readline().lower() prompt_response = sys.stdin.readline().lower()
if not prompt_response.startswith('y'): if not prompt_response.startswith('y'):
return return

View File

@ -331,6 +331,7 @@ class DeleteNode(command.Command):
sys.stdout.write( sys.stdout.write(
_("Are you sure you want to delete this node(s)" _("Are you sure you want to delete this node(s)"
" [y/N]?")) " [y/N]?"))
sys.stdout.flush()
prompt_response = sys.stdin.readline().lower() prompt_response = sys.stdin.readline().lower()
if not prompt_response.startswith('y'): if not prompt_response.startswith('y'):
return return

View File

@ -241,6 +241,7 @@ class DeletePolicy(command.Command):
sys.stdout.write( sys.stdout.write(
_("Are you sure you want to delete this policy(s)" _("Are you sure you want to delete this policy(s)"
" [y/N]?")) " [y/N]?"))
sys.stdout.flush()
prompt_response = sys.stdin.readline().lower() prompt_response = sys.stdin.readline().lower()
if not prompt_response.startswith('y'): if not prompt_response.startswith('y'):
return return

View File

@ -176,6 +176,7 @@ class DeleteProfile(command.Command):
sys.stdout.write( sys.stdout.write(
_("Are you sure you want to delete this profile(s)" _("Are you sure you want to delete this profile(s)"
" [y/N]?")) " [y/N]?"))
sys.stdout.flush()
prompt_response = sys.stdin.readline().lower() prompt_response = sys.stdin.readline().lower()
if not prompt_response.startswith('y'): if not prompt_response.startswith('y'):
return return

View File

@ -294,6 +294,7 @@ class DeleteReceiver(command.Command):
sys.stdout.write( sys.stdout.write(
_("Are you sure you want to delete this receiver(s)" _("Are you sure you want to delete this receiver(s)"
" [y/N]?")) " [y/N]?"))
sys.stdout.flush()
prompt_response = sys.stdin.readline().lower() prompt_response = sys.stdin.readline().lower()
if not prompt_response.startswith('y'): if not prompt_response.startswith('y'):
return return