forked from TrueCloudLab/frostfs-testlib
[#357] Synchronize client and CliCommand timeouts
Signed-off-by: Kirill Sosnovskikh <k.sosnovskikh@yadro.com>
This commit is contained in:
parent
97b9b5498a
commit
b00d080982
1 changed files with 13 additions and 11 deletions
|
@ -24,9 +24,7 @@ class CliCommand:
|
|||
def __init__(self, shell: Shell, cli_exec_path: str, **base_params):
|
||||
self.shell = shell
|
||||
self.cli_exec_path = cli_exec_path
|
||||
self.__base_params = " ".join(
|
||||
[f"--{param} {value}" for param, value in base_params.items() if value]
|
||||
)
|
||||
self.__base_params = " ".join([f"--{param} {value}" for param, value in base_params.items() if value])
|
||||
|
||||
def _format_command(self, command: str, **params) -> str:
|
||||
param_str = []
|
||||
|
@ -48,9 +46,7 @@ class CliCommand:
|
|||
val_str = str(value_item).replace("'", "\\'")
|
||||
param_str.append(f"--{param} '{val_str}'")
|
||||
elif isinstance(value, dict):
|
||||
param_str.append(
|
||||
f'--{param} \'{",".join(f"{key}={val}" for key, val in value.items())}\''
|
||||
)
|
||||
param_str.append(f'--{param} \'{",".join(f"{key}={val}" for key, val in value.items())}\'')
|
||||
else:
|
||||
if "'" in str(value):
|
||||
value_str = str(value).replace('"', '\\"')
|
||||
|
@ -63,12 +59,18 @@ class CliCommand:
|
|||
return f"{self.cli_exec_path} {self.__base_params} {command or ''} {param_str}"
|
||||
|
||||
def _execute(self, command: Optional[str], **params) -> CommandResult:
|
||||
return self.shell.exec(self._format_command(command, **params))
|
||||
|
||||
def _execute_with_password(self, command: Optional[str], password, **params) -> CommandResult:
|
||||
timeout = int(params["timeout"].rstrip("s")) if params.get("timeout") else None
|
||||
return self.shell.exec(
|
||||
self._format_command(command, **params),
|
||||
options=CommandOptions(
|
||||
interactive_inputs=[InteractiveInput(prompt_pattern="assword", input=password)]
|
||||
CommandOptions(timeout=timeout),
|
||||
)
|
||||
|
||||
def _execute_with_password(self, command: Optional[str], password, **params) -> CommandResult:
|
||||
timeout = int(params["timeout"].rstrip("s")) if params.get("timeout") else None
|
||||
return self.shell.exec(
|
||||
self._format_command(command, **params),
|
||||
CommandOptions(
|
||||
interactive_inputs=[InteractiveInput(prompt_pattern="assword", input=password)],
|
||||
timeout=timeout,
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue