|
|
|
@ -152,7 +152,6 @@ class Connection(_Connection):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
return self.receive(obj)
|
|
|
|
return self.receive(obj)
|
|
|
|
except (socket.timeout, AttributeError) as exc:
|
|
|
|
except (socket.timeout, AttributeError) as exc:
|
|
|
|
#display.debug(traceback.format_exc())
|
|
|
|
|
|
|
|
display.vvv(traceback.format_exc())
|
|
|
|
display.vvv(traceback.format_exc())
|
|
|
|
raise AnsibleConnectionFailure("timeout trying to send command: %s" % command.strip())
|
|
|
|
raise AnsibleConnectionFailure("timeout trying to send command: %s" % command.strip())
|
|
|
|
|
|
|
|
|
|
|
|
@ -164,9 +163,12 @@ class Connection(_Connection):
|
|
|
|
|
|
|
|
|
|
|
|
def _handle_prompt(self, resp, obj):
|
|
|
|
def _handle_prompt(self, resp, obj):
|
|
|
|
"""Matches the command prompt and responds"""
|
|
|
|
"""Matches the command prompt and responds"""
|
|
|
|
prompt = re.compile(obj['prompt'], re.I)
|
|
|
|
if not isinstance(obj['prompt'], list):
|
|
|
|
|
|
|
|
obj['prompt'] = [obj['prompt']]
|
|
|
|
|
|
|
|
prompts = [re.compile(r, re.I) for r in obj['prompt']]
|
|
|
|
answer = obj['answer']
|
|
|
|
answer = obj['answer']
|
|
|
|
match = prompt.search(resp)
|
|
|
|
for regex in prompts:
|
|
|
|
|
|
|
|
match = regex.search(resp)
|
|
|
|
if match:
|
|
|
|
if match:
|
|
|
|
self._shell.sendall('%s\r' % answer)
|
|
|
|
self._shell.sendall('%s\r' % answer)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|