MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / yum_clean

Function yum_clean

bleachbit/Unix.py:664–680  ·  view source on GitHub ↗

Run 'yum clean all' and return size in bytes recovered

()

Source from the content-addressed store, hash-verified

662
663
664def yum_clean():
665 """Run 'yum clean all' and return size in bytes recovered"""
666 if os.path.exists('/var/run/yum.pid'):
667 msg = _(
668 "%s cannot be cleaned because it is currently running. Close it, and try again.") % "Yum"
669 raise RuntimeError(msg)
670
671 old_size = FileUtilities.getsizedir('/var/cache/yum')
672 args = ['--enablerepo=*', 'clean', 'all']
673 invalid = ['You need to be root', 'Cannot remove rpmdb file']
674 try:
675 run_cleaner_cmd('yum', args, '^unused regex$', invalid)
676 except subprocess.CalledProcessError as e:
677 raise RuntimeError(
678 f"Error calling '{' '.join(str(part) for part in e.cmd)}':\n{e.output}") from e
679 new_size = FileUtilities.getsizedir('/var/cache/yum')
680 return old_size - new_size
681
682
683def dnf_clean():

Callers 1

test_yum_cleanMethod · 0.90

Calls 2

run_cleaner_cmdFunction · 0.85
joinMethod · 0.80

Tested by 1

test_yum_cleanMethod · 0.72