Skip to content

Commit

Permalink
[component] Move _fmt_msg() from collector,cleaner, upload to SosComp…
Browse files Browse the repository at this point in the history
…onent

The function _fmt_msg() was in three different subsystems. This
commit removes the code from collector, cleaner, and upload
into SosComponent.

Signed-off-by: Jose Castillo <[email protected]>
  • Loading branch information
jcastill committed Aug 13, 2024
1 parent 9859412 commit 72dd27c
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 @@ -177,13 +176,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 @@ -712,13 +711,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 @@ -458,6 +459,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 @@ -10,7 +10,6 @@

import os
import sys
from textwrap import fill
from sos.component import SoSComponent
from sos import _sos as _
from sos import __version__
Expand Down Expand Up @@ -89,13 +88,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 72dd27c

Please sign in to comment.