Skip to content

Commit

Permalink
Fix system command processing during logging in user tools (#633)
Browse files Browse the repository at this point in the history
* Fix incorrect splitting of system cmd having string type

Signed-off-by: Partho Sarthi <[email protected]>

* Fix subscriptable type

Signed-off-by: Partho Sarthi <[email protected]>

* Concise if-else condition

Signed-off-by: Partho Sarthi <[email protected]>

---------

Signed-off-by: Partho Sarthi <[email protected]>
  • Loading branch information
parthosa authored Oct 27, 2023
1 parent a96e0d7 commit 6f1a573
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions user_tools/src/spark_rapids_pytools/cloud_api/sp_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from dataclasses import dataclass, field
from enum import Enum
from logging import Logger
from typing import Type, Any, List, Callable
from typing import Type, Any, List, Callable, Union

from spark_rapids_tools import EnumeratedType, CspEnv
from spark_rapids_pytools.common.prop_manager import AbstractPropertiesContainer, JSONPropertiesContainer, \
Expand Down Expand Up @@ -369,7 +369,7 @@ def validate_env(self):
self._handle_inconsistent_configurations(incorrect_envs)

def run_sys_cmd(self,
cmd,
cmd: Union[str, list],
cmd_input: str = None,
fail_ok: bool = False,
env_vars: dict = None) -> str:
Expand All @@ -393,7 +393,9 @@ def process_streams(std_out, std_err):
if len(stdout_splits) > 0:
std_out_lines = Utils.gen_multiline_str([f'\t| {line}' for line in stdout_splits])
stdout_str = f'\n\t<STDOUT>\n{std_out_lines}'
cmd_log_str = Utils.gen_joined_str(' ', process_credentials_option(cmd))
# if the command is already a list, use it as-is. Otherwise, split the string into a list.
cmd_list = cmd if isinstance(cmd, list) else cmd.split(' ')
cmd_log_str = Utils.gen_joined_str(' ', process_credentials_option(cmd_list))
if len(stderr_splits) > 0:
std_err_lines = Utils.gen_multiline_str([f'\t| {line}' for line in stderr_splits])
stderr_str = f'\n\t<STDERR>\n{std_err_lines}'
Expand Down

0 comments on commit 6f1a573

Please sign in to comment.