Skip to content

Commit

Permalink
hf2
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-usielski committed Nov 5, 2024
1 parent d207caf commit 019748b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
13 changes: 8 additions & 5 deletions moler/device/proxy_pc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import abc

from moler.device.unixlocal import UnixLocal
from moler.exceptions import DeviceFailure


@six.add_metaclass(abc.ABCMeta)
Expand Down Expand Up @@ -148,11 +149,13 @@ def _prepare_state_prompts(self):
:return: None.
"""
super(ProxyPc, self)._prepare_state_prompts()

if self._use_proxy_pc:
state_prompts = self._prepare_state_prompts_with_proxy_pc()
else:
state_prompts = self._prepare_state_prompts_without_proxy_pc()
try:
if self._use_proxy_pc:
state_prompts = self._prepare_state_prompts_with_proxy_pc()
else:
state_prompts = self._prepare_state_prompts_without_proxy_pc()
except KeyError as ke:
raise DeviceFailure(f"Wrong configuration. Cannot get prompts. {ke} {repr(ke)}")

self._update_dict(self._state_prompts, state_prompts)

Expand Down
30 changes: 17 additions & 13 deletions moler/device/unixremote.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from moler.device.proxy_pc import ProxyPc
from moler.helpers import call_base_class_method_with_same_name, mark_to_call_base_class_method_with_same_name
from moler.exceptions import DeviceFailure


@call_base_class_method_with_same_name
Expand Down Expand Up @@ -434,20 +435,23 @@ def _overwrite_prompts(self):
"""
Overwrite prompts for some states to easily configure the SM.
"""
if self._use_proxy_pc:
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote][UnixRemote.proxy_pc][
"command_params"]["expected_prompt"] = \
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.proxy_pc][
"command_params"]["expected_prompt"]
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][
"command_params"]["expected_prompt"] = \
self._configurations[UnixRemote.connection_hops][UnixRemote.proxy_pc][UnixRemote.unix_remote][
"command_params"]["expected_prompt"]
else:
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][
"command_params"]["expected_prompt"] = \
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.unix_remote][
try:
if self._use_proxy_pc:
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote][UnixRemote.proxy_pc][
"command_params"]["expected_prompt"] = \
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.proxy_pc][
"command_params"]["expected_prompt"]
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][
"command_params"]["expected_prompt"] = \
self._configurations[UnixRemote.connection_hops][UnixRemote.proxy_pc][UnixRemote.unix_remote][
"command_params"]["expected_prompt"]
else:
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_remote_root][UnixRemote.unix_remote][
"command_params"]["expected_prompt"] = \
self._configurations[UnixRemote.connection_hops][UnixRemote.unix_local][UnixRemote.unix_remote][
"command_params"]["expected_prompt"]
except KeyError as ke:
raise DeviceFailure(f"Wrong configuration. Cannot get prompts. {ke} {repr(ke)}")

def _get_packages_for_state(self, state, observer):
"""
Expand Down

0 comments on commit 019748b

Please sign in to comment.