Skip to content

Commit

Permalink
[component] Move _fmt_msg() to SoSComponent
Browse files Browse the repository at this point in the history
The function _fmt_msg() was in three different subsystems. This
commit removes the code from collector, cleaner, and upload
into SosComponent.

Related: #3746

Signed-off-by: Jose Castillo <[email protected]>
  • Loading branch information
jcastill committed Feb 19, 2025
1 parent 142ddb4 commit 05d12e9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
8 changes: 0 additions & 8 deletions sos/cleaner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from pwd import getpwuid
from textwrap import fill

import sos.cleaner.preppers

Expand Down Expand Up @@ -178,13 +177,6 @@ def log_info(self, msg, caller=None):
def log_error(self, msg, caller=None):
self.soslog.error(self._fmt_log_msg(msg, caller))

def _fmt_msg(self, msg):
width = 80
_fmt = ''
for line in msg.splitlines():
_fmt = _fmt + fill(line, width, replace_whitespace=False) + '\n'
return _fmt

@classmethod
def display_help(cls, section):
section.set_title("SoS Cleaner Detailed Help")
Expand Down
8 changes: 0 additions & 8 deletions sos/collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from getpass import getpass
from pathlib import Path
from shlex import quote
from textwrap import fill
from sos.cleaner import SoSCleaner
from sos.collector.sosnode import SosNode
from sos.options import ClusterOption, str_to_bool
Expand Down Expand Up @@ -724,13 +723,6 @@ def _get_archive_path(self):
compr = 'gz'
return self.tmpdir + '/' + self.arc_name + '.tar.' + compr

def _fmt_msg(self, msg):
width = 80
_fmt = ''
for line in msg.splitlines():
_fmt = _fmt + fill(line, width, replace_whitespace=False) + '\n'
return _fmt

def _load_group_config(self):
"""
Attempts to load the host group specified on the command line.
Expand Down
8 changes: 8 additions & 0 deletions sos/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys
import time

from textwrap import fill
from argparse import SUPPRESS
from datetime import datetime
from getpass import getpass
Expand Down Expand Up @@ -471,6 +472,13 @@ def _setup_logging(self):
def get_temp_file(self):
return self.tempfile_util.new()

def _fmt_msg(self, msg):
width = 80
_fmt = ''
for line in msg.splitlines():
_fmt = _fmt + fill(line, width, replace_whitespace=False) + '\n'
return _fmt


class SoSMetadata():
"""This class is used to record metadata from a sos execution that will
Expand Down
8 changes: 0 additions & 8 deletions sos/upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import logging
import inspect

from textwrap import fill
from sos.component import SoSComponent
from sos import _sos as _
from sos import __version__
Expand Down Expand Up @@ -137,13 +136,6 @@ def display_help(cls, section):
'to a distribution specific location.'
)

def _fmt_msg(self, msg):
width = 80
_fmt = ''
for line in msg.splitlines():
_fmt = _fmt + fill(line, width, replace_whitespace=False) + '\n'
return _fmt

def intro(self):
"""Print the intro message and prompts for a case ID if one is not
provided on the command line
Expand Down

0 comments on commit 05d12e9

Please sign in to comment.