Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tracer loading to always define the same method #150

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions src/katello/tracer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,35 @@
import imp

def collect_apps():
raise NotImplementedError("This is not the method you want to use. Normally, this method should be provided by tracer.deb or tracer.zypper")
raise NotImplementedError("Couldn't detect package manager. Failed to query affected apps!")

try:
imp.find_module('apt')
from katello.tracer.deb import collect_apps
apt = True
except ImportError as e:
apt = False

try:
imp.find_module('dnf')
dnf = True
except ImportError:
dnf = False
pass

try:
imp.find_module('yum')
yum = True
imp.find_module('dnf')
tracer = True
except ImportError:
yum = False
try:
imp.find_module('yum')
tracer = True
except ImportError:
tracer = False

if yum or dnf:
if tracer:
from tracer.query import Query
def collect_apps():
query = Query()
return query.affected_applications().get()

try:
imp.find_module('zypp_plugin')
from katello.tracer.zypper import collect_apps
zypp = True
except ImportError:
zypp = False
pass


def upload_tracer_profile(queryfunc, plugin=None):
Expand All @@ -48,13 +47,7 @@ def upload_tracer_profile(queryfunc, plugin=None):


def query_affected_apps(plugin=None):
if yum or dnf:
query = Query()
return query.affected_applications().get()
elif zypp or apt:
return collect_apps()
else:
raise Exception("Couldn't detect package manager. Failed to query affected apps!")
return collect_apps()


def get_apps(queryfunc, plugin=None):
Expand Down
Loading