Skip to content

Commit

Permalink
info
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-usielski committed Nov 13, 2024
1 parent 4a4a69a commit 41dd8b9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion moler/config/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
%% %%% %%% %% %%% %% %%% %%%%%%%%% %%% %%%%%%%
%% %%%%% %% %%% %% %%% %%% %%% %%%
%% %%% %% %%%%%%%%%%% %%%%%%%%% %%%%%%%%%% %%% %%%
Prompt detecting v1.
Prompt detecting v2.
"""


Expand Down
14 changes: 8 additions & 6 deletions moler/device/proxy_pc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def on_connection_made(self, connection):
self._prompt_detected = False # prompt not defined in SM
self._set_state(PROXY_PC)
self._detect_after_open_prompt(self._set_after_open_prompt)
self._detect_prompt_get_cmd()

def on_connection_lost(self, connection):
"""
Expand All @@ -257,7 +258,7 @@ def on_connection_lost(self, connection):
self._set_state(NOT_CONNECTED)

def _detect_after_open_prompt(self, set_callback):
self.logger.debug("Command to detect prompt will be sent.")
self.logger.info(f"Command to detect prompt will be sent. Callback: {set_callback}")
self._prompt_detected = False
self._after_open_prompt_detector = Wait4(
detect_patterns=[rf'^(.+){self._detecting_prompt_cmd}'],
Expand All @@ -277,20 +278,21 @@ def _set_after_open_prompt(self, event):
occurrence = event.get_last_occurrence()
prompt = occurrence['groups'][0].rstrip()
state = self._get_current_state()
self.logger.debug(f"ProxyPc2 for state '{state}' new prompt '{prompt}' reverse_state_prompts_dict: '{self._reverse_state_prompts_dict}'.")
self.logger.info(f"ProxyPc2 for state '{state}' new prompt '{prompt}' reverse_state_prompts_dict: '{self._reverse_state_prompts_dict}'.")
with self._state_prompts_lock:
old_prompt = self._state_prompts.get(state, None)
prompt = re.escape(prompt)
self._state_prompts[state] = prompt
if old_prompt is not None and prompt != old_prompt:
self.logger.info(f"Different prompt candidates: '{old_prompt}' -> '{prompt}' for state {state}.")
self.logger.debug(f"New prompts: {self._state_prompts}")
self.logger.info(f"New prompts: {self._state_prompts}")
self._prepare_reverse_state_prompts_dict()
self.logger.debug(f"After prepare_reverse_state_prompts_dict: {self._reverse_state_prompts_dict}")
self.logger.info(f"After prepare_reverse_state_prompts_dict: {self._reverse_state_prompts_dict}")
if self._prompts_event is not None:
self.logger.debug("prompts event is not none")
self.logger.info("prompts event is not none")
self._prompts_event.change_prompts(prompts=self._reverse_state_prompts_dict)
self._prompt_detected = True
self.logger.info("Prompt detected")

def _prepare_state_prompts(self):
"""
Expand Down Expand Up @@ -452,7 +454,7 @@ def get_cmd(self, cmd_name, cmd_params=None, check_state=True, for_state=None):
for_state=for_state)

def _detect_prompt_get_cmd(self):
self.logger.debug("get_cmd was called but prompt has not been detected yet.")
self.logger.info("get_cmd was called but prompt has not been detected yet.")
if self._after_open_prompt_detector is None or not self._after_open_prompt_detector.running():
self._detect_after_open_prompt(self._set_after_open_prompt)
self._after_open_prompt_detector.await_done(timeout=self._prompt_detector_timeout)
Expand Down
13 changes: 7 additions & 6 deletions moler/device/unixremote2.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,27 +391,28 @@ def _set_after_open_prompt(self, event):
occurrence = event.get_last_occurrence()
prompt = occurrence['groups'][0].rstrip()
state = self._get_current_state()
self.logger.debug(f"UnixRemote2 for state '{state}' new prompt '{prompt}' reverse_state_prompts_dict: '{self._reverse_state_prompts_dict}'.")
self.logger.info(f"UnixRemote2 for state '{state}' new prompt '{prompt}' reverse_state_prompts_dict: '{self._reverse_state_prompts_dict}'.")
with self._state_prompts_lock:
old_prompt = self._state_prompts.get(state, None)
prompt = re.escape(prompt)
self._state_prompts[state] = prompt
self.logger.debug(f"state_prompts after change: {self._state_prompts}")
self.logger.info(f"state_prompts after change: {self._state_prompts}")
self._prepare_reverse_state_prompts_dict()
if old_prompt is not None and prompt != old_prompt:
self.logger.info(f"Different prompt candidates: '{old_prompt}' -> '{prompt}' for state {state}.")
if state == UNIX_REMOTE:
self._update_depending_on_ux_prompt()
elif state == PROXY_PC:
self._update_depending_on_proxy_prompt()
self.logger.debug(f"UnixRemote2. updated _reverse_state_prompts_dict: {self._reverse_state_prompts_dict}")
self.logger.info(f"UnixRemote2. updated _reverse_state_prompts_dict: {self._reverse_state_prompts_dict}")
if self._prompts_event is not None:
self.logger.debug("prompts event is not none")
self.logger.info("prompts event is not none")
self._prompts_event.change_prompts(
prompts=self._reverse_state_prompts_dict)
self.logger.debug(f"New prompts: {self._state_prompts}")
self.logger.debug(f"After prepare_reverse_state_prompts_dict: {self._reverse_state_prompts_dict}")
self.logger.info(f"New prompts: {self._state_prompts}")
self.logger.info(f"After prepare_reverse_state_prompts_dict: {self._reverse_state_prompts_dict}")
self._prompt_detected = True
self.logger.info("Prompt detected")

@mark_to_call_base_class_method_with_same_name
def _prepare_state_prompts_with_proxy_pc(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='moler',
version='3.12.150',
version='3.12.152',
description='Moler is a library for working with terminals, mainly for automated tests', # Required
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 41dd8b9

Please sign in to comment.