1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Make 'pause: prompt=…' print the prompt

In stable-1.9, the prompt string is passed to raw_input(), which prints
it without an extra \n. Here we're just print()ing it, so the \n would
be doubled.
This commit is contained in:
Abhijit Menon-Sen 2015-08-02 20:08:28 +05:30
parent 9936c5f9f6
commit 861da614cc

View file

@ -58,7 +58,7 @@ class ActionModule(ActionBase):
# Is 'args' empty, then this is the default prompted pause # Is 'args' empty, then this is the default prompted pause
if self._task.args is None or len(self._task.args.keys()) == 0: if self._task.args is None or len(self._task.args.keys()) == 0:
pause_type = 'prompt' pause_type = 'prompt'
prompt = "[%s]\nPress enter to continue:\n" % self._task.get_name().strip() prompt = "[%s]\nPress enter to continue:" % self._task.get_name().strip()
# Are 'minutes' or 'seconds' keys that exist in 'args'? # Are 'minutes' or 'seconds' keys that exist in 'args'?
elif 'minutes' in self._task.args or 'seconds' in self._task.args: elif 'minutes' in self._task.args or 'seconds' in self._task.args:
@ -79,7 +79,7 @@ class ActionModule(ActionBase):
# Is 'prompt' a key in 'args'? # Is 'prompt' a key in 'args'?
elif 'prompt' in self._task.args: elif 'prompt' in self._task.args:
pause_type = 'prompt' pause_type = 'prompt'
prompt = "[%s]\n%s:\n" % (self._task.get_name().strip(), self._task.args['prompt']) prompt = "[%s]\n%s:" % (self._task.get_name().strip(), self._task.args['prompt'])
else: else:
# I have no idea what you're trying to do. But it's so wrong. # I have no idea what you're trying to do. But it's so wrong.
@ -100,7 +100,7 @@ class ActionModule(ActionBase):
print("Pausing for %d seconds" % seconds) print("Pausing for %d seconds" % seconds)
print("(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)\r"), print("(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)\r"),
else: else:
print("(press enter to continue, ctrl+C to abort)") print(prompt)
# save the attributes on the existing (duped) stdin so # save the attributes on the existing (duped) stdin so
# that we can restore them later after we set raw mode # that we can restore them later after we set raw mode