Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix system command processing during logging in user tools #633

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 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,11 @@ 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 isinstance(cmd, list):
cmd_list = cmd
else:
cmd_list = cmd.split(' ')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is more concise, nit: cmd_list = cmd if isinstance(cmd, list) else cmd.split(' ')

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to make it more concise.

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
Loading