|
|
922fe2 |
From aa724a639a641943ecf39038fd694abc2037e66d Mon Sep 17 00:00:00 2001
|
|
|
922fe2 |
From: Jan Kolarik <jkolarik@redhat.com>
|
|
|
922fe2 |
Date: Mon, 22 Aug 2022 10:38:30 +0200
|
|
|
922fe2 |
Subject: [PATCH] Expose plugin unload method to API (RhBug:2047251)
|
|
|
922fe2 |
|
|
|
922fe2 |
= changelog =
|
|
|
922fe2 |
type: bugfix
|
|
|
922fe2 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2047251
|
|
|
922fe2 |
---
|
|
|
922fe2 |
dnf/base.py | 5 +++++
|
|
|
922fe2 |
dnf/plugin.py | 1 +
|
|
|
922fe2 |
doc/api_base.rst | 4 ++++
|
|
|
922fe2 |
tests/api/test_dnf_base.py | 7 +++++++
|
|
|
922fe2 |
4 files changed, 17 insertions(+)
|
|
|
922fe2 |
|
|
|
922fe2 |
diff --git a/dnf/base.py b/dnf/base.py
|
|
|
922fe2 |
index e623d98e..4ddfae15 100644
|
|
|
922fe2 |
--- a/dnf/base.py
|
|
|
922fe2 |
+++ b/dnf/base.py
|
|
|
922fe2 |
@@ -316,6 +316,11 @@ class Base(object):
|
|
|
922fe2 |
"""Run plugins configure() method."""
|
|
|
922fe2 |
self._plugins._run_config()
|
|
|
922fe2 |
|
|
|
922fe2 |
+ def unload_plugins(self):
|
|
|
922fe2 |
+ # :api
|
|
|
922fe2 |
+ """Run plugins unload() method."""
|
|
|
922fe2 |
+ self._plugins._unload()
|
|
|
922fe2 |
+
|
|
|
922fe2 |
def update_cache(self, timer=False):
|
|
|
922fe2 |
# :api
|
|
|
922fe2 |
|
|
|
922fe2 |
diff --git a/dnf/plugin.py b/dnf/plugin.py
|
|
|
922fe2 |
index 06066e79..87c1f08f 100644
|
|
|
922fe2 |
--- a/dnf/plugin.py
|
|
|
922fe2 |
+++ b/dnf/plugin.py
|
|
|
922fe2 |
@@ -164,6 +164,7 @@ class Plugins(object):
|
|
|
922fe2 |
self._caller('transaction')
|
|
|
922fe2 |
|
|
|
922fe2 |
def _unload(self):
|
|
|
922fe2 |
+ logger.debug(_('Plugins were unloaded'))
|
|
|
922fe2 |
del sys.modules[DYNAMIC_PACKAGE]
|
|
|
922fe2 |
|
|
|
922fe2 |
def unload_removed_plugins(self, transaction):
|
|
|
922fe2 |
diff --git a/doc/api_base.rst b/doc/api_base.rst
|
|
|
922fe2 |
index 03396b69..35cbeef5 100644
|
|
|
922fe2 |
--- a/doc/api_base.rst
|
|
|
922fe2 |
+++ b/doc/api_base.rst
|
|
|
922fe2 |
@@ -97,6 +97,10 @@
|
|
|
922fe2 |
|
|
|
922fe2 |
Configure plugins by running their configure() method.
|
|
|
922fe2 |
|
|
|
922fe2 |
+ .. method:: unload_plugins()
|
|
|
922fe2 |
+
|
|
|
922fe2 |
+ Unload all plugins.
|
|
|
922fe2 |
+
|
|
|
922fe2 |
.. method:: fill_sack([load_system_repo=True, load_available_repos=True])
|
|
|
922fe2 |
|
|
|
922fe2 |
Setup the package sack. If `load_system_repo` is ``True``, load information about packages in the local RPMDB into the sack. Else no package is considered installed during dependency solving. If `load_available_repos` is ``True``, load information about packages from the available repositories into the sack.
|
|
|
922fe2 |
diff --git a/tests/api/test_dnf_base.py b/tests/api/test_dnf_base.py
|
|
|
922fe2 |
index 33598189..e84e272b 100644
|
|
|
922fe2 |
--- a/tests/api/test_dnf_base.py
|
|
|
922fe2 |
+++ b/tests/api/test_dnf_base.py
|
|
|
922fe2 |
@@ -95,6 +95,13 @@ class DnfBaseApiTest(TestCase):
|
|
|
922fe2 |
|
|
|
922fe2 |
self.base.configure_plugins()
|
|
|
922fe2 |
|
|
|
922fe2 |
+ def test_unload_plugins(self):
|
|
|
922fe2 |
+ # Base.unload_plugins()
|
|
|
922fe2 |
+ self.assertHasAttr(self.base, "unload_plugins")
|
|
|
922fe2 |
+
|
|
|
922fe2 |
+ self.base.init_plugins()
|
|
|
922fe2 |
+ self.base.unload_plugins()
|
|
|
922fe2 |
+
|
|
|
922fe2 |
def test_update_cache(self):
|
|
|
922fe2 |
# Base.update_cache(self, timer=False)
|
|
|
922fe2 |
self.assertHasAttr(self.base, "update_cache")
|
|
|
922fe2 |
--
|
|
|
922fe2 |
2.37.1
|
|
|
922fe2 |
|