diff options
| author | Natan Yellin <aantn@users.noreply.github.com> | 2024-03-21 11:54:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 12:54:53 +0200 |
| commit | 699802a26484a2bc303a6e95dbf61844d642f644 (patch) | |
| tree | 204d16df0e596893d77e1aebeac2d4510ddfdf0b /robusta_krr | |
| parent | 4da1933b66178f0b7c5faec69e00b383ed1c3142 (diff) | |
Fix fileoutput (#231)
* Fix --fileoutput
* Remove dead code
---------
Co-authored-by: Pavel Zhukov <33721692+LeaveMyYard@users.noreply.github.com>
Diffstat (limited to 'robusta_krr')
| -rw-r--r-- | robusta_krr/core/models/config.py | 7 | ||||
| -rw-r--r-- | robusta_krr/core/runner.py | 6 |
2 files changed, 3 insertions, 10 deletions
diff --git a/robusta_krr/core/models/config.py b/robusta_krr/core/models/config.py index 1d4e6a5..dd84423 100644 --- a/robusta_krr/core/models/config.py +++ b/robusta_krr/core/models/config.py @@ -65,7 +65,6 @@ class Config(pd.BaseSettings): # Internal inside_cluster: bool = False _logging_console: Optional[Console] = pd.PrivateAttr(None) - _result_console: Optional[Console] = pd.PrivateAttr(None) def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) @@ -132,12 +131,6 @@ class Config(pd.BaseSettings): self._logging_console = Console(file=sys.stderr if self.log_to_stderr else sys.stdout, width=self.width) return self._logging_console - @property - def result_console(self) -> Console: - if getattr(self, "_result_console") is None: - self._result_console = Console(file=sys.stdout, width=self.width) - return self._result_console - def load_kubeconfig(self) -> None: try: config.load_incluster_config() diff --git a/robusta_krr/core/runner.py b/robusta_krr/core/runner.py index 4aacfb5..f651aa8 100644 --- a/robusta_krr/core/runner.py +++ b/robusta_krr/core/runner.py @@ -8,6 +8,7 @@ from concurrent.futures import ThreadPoolExecutor from typing import Optional, Union from datetime import timedelta from prometrix import PrometheusNotFound +from rich.console import Console from slack_sdk import WebClient from robusta_krr.core.abstract.strategies import ResourceRecommendation, RunResult @@ -89,9 +90,8 @@ class Runner: elif settings.slack_output: file_name = settings.slack_output with open(file_name, "w") as target_file: - sys.stdout = target_file - custom_print(formatted, rich=rich, force=True) - sys.stdout = sys.stdout + console = Console(file=target_file, width=settings.width) + console.print(formatted) if settings.slack_output: client = WebClient(os.environ["SLACK_BOT_TOKEN"]) warnings.filterwarnings("ignore", category=UserWarning) |
