Skip to content

Commit

Permalink
Expose plugin unload method to API (RhBug:2047251)
Browse files Browse the repository at this point in the history
= changelog =
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2047251
  • Loading branch information
jan-kolarik authored and kontura committed Aug 22, 2022
1 parent 1770a64 commit 7ef317d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ def configure_plugins(self):
"""Run plugins configure() method."""
self._plugins._run_config()

def unload_plugins(self):
# :api
"""Run plugins unload() method."""
self._plugins._unload()

def update_cache(self, timer=False):
# :api

Expand Down
1 change: 1 addition & 0 deletions dnf/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def run_transaction(self):
self._caller('transaction')

def _unload(self):
logger.debug(_('Plugins were unloaded'))
del sys.modules[DYNAMIC_PACKAGE]

def unload_removed_plugins(self, transaction):
Expand Down
4 changes: 4 additions & 0 deletions doc/api_base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@

Configure plugins by running their configure() method.

.. method:: unload_plugins()

Unload all plugins.

.. method:: fill_sack([load_system_repo=True, load_available_repos=True])

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.
Expand Down
7 changes: 7 additions & 0 deletions tests/api/test_dnf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def test_configure_plugins(self):

self.base.configure_plugins()

def test_unload_plugins(self):
# Base.unload_plugins()
self.assertHasAttr(self.base, "unload_plugins")

self.base.init_plugins()
self.base.unload_plugins()

def test_update_cache(self):
# Base.update_cache(self, timer=False)
self.assertHasAttr(self.base, "update_cache")
Expand Down

0 comments on commit 7ef317d

Please sign in to comment.