Skip to content

Commit

Permalink
encapsulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Miryam-Schwartz committed Dec 1, 2024
1 parent 3abbad1 commit caf3629
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,10 @@ def create_analyzer(
end = time.perf_counter()
log.LOGGER.debug(f"Took {end-start:.3f} to load the parsed data")

all_images_outputs_and_title, dataframes_for_pdf, lists_to_add = \
all_images_outputs_and_title, dataframes_for_pdf, lists_to_add = (
ufm_top_analyzer.full_analysis_all_analyzers()
)

png_images = []
images_and_title_to_present = []
for image_title in all_images_outputs_and_title:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,14 @@ def __init__(
def _remove_empty_lines_from_csv(input_file):
temp_file = input_file + ".temp"

with open(
input_file, "r", newline="", encoding=DataConstants.UTF8ENCODING
) as infile, open(
temp_file, "w", newline="", encoding=DataConstants.UTF8ENCODING
) as outfile:
with (
open(
input_file, "r", newline="", encoding=DataConstants.UTF8ENCODING
) as infile,
open(
temp_file, "w", newline="", encoding=DataConstants.UTF8ENCODING
) as outfile,
):
reader = csv.reader(infile)
writer = csv.writer(outfile)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ def _extract_ufm_version(logs_csvs):
temp_file = csv_file + ".temp"

# Open the input CSV file for reading
with open(
csv_file, mode="r", newline="", encoding=DataConstants.UTF8ENCODING
) as infile, open(
temp_file, mode="w", newline="", encoding=DataConstants.UTF8ENCODING
) as outfile:
with (
open(
csv_file, mode="r", newline="", encoding=DataConstants.UTF8ENCODING
) as infile,
open(
temp_file, mode="w", newline="", encoding=DataConstants.UTF8ENCODING
) as outfile,
):
reader = csv.DictReader(infile)
fieldnames = reader.fieldnames # Get the header from the CSV
writer = csv.DictWriter(outfile, fieldnames=fieldnames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ def full_analysis(self):
)

lists_to_add.append(
(
[self.get_number_of_core_dumps()],
f"{self.telemetry_type} "
"number of core dumps found in the logs",
["Amount"],
)
(
[self.get_number_of_core_dumps()],
f"{self.telemetry_type} "
"number of core dumps found in the logs",
["Amount"],
)
)
return images, dataframes_for_pdf, lists_to_add
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,10 @@ def plot_link_flapping_last_week(self):
def full_analysis(self):
link_flapping_last_week = self.get_link_flapping_last_week()
images, _, _ = super().full_analysis()
df = [("Link Flapping last week", link_flapping_last_week,)]
df = [
(
"Link Flapping last week",
link_flapping_last_week,
)
]
return images, df, []
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
# pylint: disable=missing-module-docstring


from plugins.ufm_log_analyzer_plugin.src.loganalyze.log_analyzers.ibdiagnet_log_analyzer\
import IBDIAGNETLogAnalyzer
from plugins.ufm_log_analyzer_plugin.src.loganalyze.log_analyzers.ibdiagnet_log_analyzer import (
IBDIAGNETLogAnalyzer,
)


class UFMTopAnalyzer:
Expand All @@ -37,8 +38,9 @@ def full_analysis_all_analyzers(self):
dataframes.extend(tmp_dataframes)
lists_to_add.extend(tmp_lists)

has_ibdiagnet_analyzer = any(isinstance(instance, IBDIAGNETLogAnalyzer) \
for instance in self._analyzers)
has_ibdiagnet_analyzer = any(
isinstance(instance, IBDIAGNETLogAnalyzer) for instance in self._analyzers
)
if not has_ibdiagnet_analyzer:
dataframes.append(("Fabric info", ("No Fabric Info found")))

Expand Down

0 comments on commit caf3629

Please sign in to comment.