Fix first moler prompt catch
@@ -22,7 +22,7 @@ class ThreadedTerminal(IOConnection):
"""
def __init__(self, moler_connection, cmd="/bin/bash", select_timeout=0.002,
- read_buffer_size=4096, first_prompt=r'[%$#]+', target_prompt=r'^moler_bash#',
+ read_buffer_size=4096, first_prompt=r'[%$#]+', target_prompt=r'moler_bash#',
set_prompt_cmd='export PS1="moler_bash# "\n', dimensions=(100, 300)):
"""
:param moler_connection: Moler's connection to join with
@@ -48,6 +48,7 @@ class ThreadedTerminal(IOConnection):
self.target_prompt = target_prompt
self._cmd = [cmd]
self.set_prompt_cmd = set_prompt_cmd
+ self._re_set_prompt_cmd = re.sub("['\"].*['\"]", "", self.set_prompt_cmd.strip())
def open(self):
"""Open ThreadedTerminal connection & start thread pulling data from it."""
@@ -125,9 +126,7 @@ class ThreadedTerminal(IOConnection):
lines = self.read_buffer.splitlines()
for line in lines:
- if re.search(self.set_prompt_cmd.strip(), line):
- continue
- if re.search(self.target_prompt, line):
+ if not re.search(self._re_set_prompt_cmd, line) and re.search(self.target_prompt, line):
self._notify_on_connect()
self._shell_operable.set()
data = re.sub(self.target_prompt, '', self.read_buffer, re.MULTILINE)
