Skip to content

Commit

Permalink
Fix: Eclean pkgindex
Browse files Browse the repository at this point in the history
Last implemention was importing binhost module incorectly.

Signed-off-by: Siddhanth Rathod <[email protected]>
  • Loading branch information
hyprsyd committed Oct 5, 2023
1 parent e49cc34 commit 8f2f871
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions pym/gentoolkit/eclean/pkgindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import portage
from portage.module import (
InvalidModuleName,
Modules,
)
from portage.emaint.main import TaskHandler
from portage.emaint.modules.binhost import binhost


class PkgIndex:
Expand All @@ -30,22 +30,7 @@ def __init__(self, controller=None):
self.controller = controller
# backup command line call
self.emaint_cmd = "%s/usr/sbin/emaint --fix binhost" % EPREFIX

def _get_emaint_binhost(self):
"""Obtain a reference to the binhost module class
@sets: self.binhost to BinhostHandler class
@rtype: boolean
"""
try:
self.emaint_control = Modules()
self.binhost = self.emaint_control._get_class("binhost")
except InvalidModuleName as er:
print(pp.error("Error importing emaint binhost module"), file=sys.stderr)
print(pp.error("Original error: " + er), file=sys.stderr)
except:
return False
return True
self.binhost = binhost.BinhostHandler

def clean_pkgs_index(self, quiet):
"""This will clean the binpkgs packages index file
Expand All @@ -56,12 +41,11 @@ def clean_pkgs_index(self, quiet):
file_ = os.path.join(portage.settings["PKGDIR"], "Packages")
statinfo = os.stat(file_)
size1 = statinfo.st_size
show_progress = not quiet
if self._get_emaint_binhost():
self.taskmaster = TaskHandler(show_progress_bar=show_progress)
try:
self.taskmaster = TaskHandler(show_progress_bar=quiet)
tasks = [self.binhost]
self.taskmaster.run_tasks(tasks)
else:
self.taskmaster.run_tasks(tasks, "fix")
except InvalidModuleName:
self.call_emaint()
statinfo = os.stat(file_)
clean_size = size1 - statinfo.st_size
Expand Down

0 comments on commit 8f2f871

Please sign in to comment.