Skip to content

Commit

Permalink
Analyzer: Only import sssd.source_* when needed
Browse files Browse the repository at this point in the history
This allows sss_analyze to run without python-systemd when using the
Files backend.
  • Loading branch information
jetomit committed May 27, 2022
1 parent e797447 commit 3062323
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tools/analyzer/modules/request.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import re
import logging

from sssd.source_files import Files
from sssd.source_journald import Journald
from sssd.parser import SubparsersAction
from sssd.parser import Option

Expand Down Expand Up @@ -77,8 +75,10 @@ def load(self, args):
Instantiated source object
"""
if args.source == "journald":
from sssd.source_journald import Journald
source = Journald()
else:
from sssd.source_files import Files
source = Files(args.logdir)
return source

Expand Down Expand Up @@ -143,7 +143,7 @@ def consume_line(self, line, source, consume):
self.consumed_logs.append(line.rstrip(line[-1]))
else:
# files source includes newline
if isinstance(source, Files):
if type(source).__name__ == 'Files':
print(line, end='')
else:
print(line)
Expand Down Expand Up @@ -225,7 +225,7 @@ def list_requests(self, args):
source.set_component(component, False)
self.done = ""
for line in self.matched_line(source, patterns):
if isinstance(source, Journald):
if type(source).__name__ == 'Journald':
print(line)
else:
self.print_formatted(line, args.verbose)
Expand Down

0 comments on commit 3062323

Please sign in to comment.