From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CA5ED158094 for ; Sat, 9 Jul 2022 21:46:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 115F6E0BB8; Sat, 9 Jul 2022 21:46:22 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D7594E0BB8 for ; Sat, 9 Jul 2022 21:46:21 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D7AD0340817 for ; Sat, 9 Jul 2022 21:46:20 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1869D3C7 for ; Sat, 9 Jul 2022 21:46:19 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1657403104.680dd160e1e5a41f008bd1a47afa2da2eb25714f.dolsen@gentoo> Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/eclean/clean.py pym/gentoolkit/eclean/cli.py pym/gentoolkit/eclean/pkgindex.py X-VCS-Directories: pym/gentoolkit/eclean/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 680dd160e1e5a41f008bd1a47afa2da2eb25714f X-VCS-Branch: master Date: Sat, 9 Jul 2022 21:46:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6b1630b8-4b28-4658-891b-adc10270aced X-Archives-Hash: ad56f4792d5829079df2d44b26011d3d commit: 680dd160e1e5a41f008bd1a47afa2da2eb25714f Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 9 21:41:39 2022 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 9 21:45:04 2022 +0000 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=680dd160 eclean: Complete migration to imported emaint code eclean-pkg now uses imported emaint binhost code to run, Properly handle --quiet option for progressbar suppression from emaint. Keeps the standalone emaint binhost subprocess call as backup. Closes: https://bugs.gentoo.org/688550 Signed-off-by: Brian Dolbec gentoo.org> pym/gentoolkit/eclean/clean.py | 5 ++-- pym/gentoolkit/eclean/cli.py | 2 +- pym/gentoolkit/eclean/pkgindex.py | 56 ++++++++++++++++++--------------------- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py index a6358a4..37a042a 100644 --- a/pym/gentoolkit/eclean/clean.py +++ b/pym/gentoolkit/eclean/clean.py @@ -19,8 +19,9 @@ class CleanUp: or bypassing/ignoring """ - def __init__(self, controller): + def __init__(self, controller, quiet): self.controller = controller + self.quiet = quiet def clean_dist(self, clean_dict): """Calculate size of each entry for display, prompt user if needed, @@ -64,7 +65,7 @@ class CleanUp: # emaint is not yet importable so call it # print a blank line here for separation print() - clean_size += index_control.call_emaint() + clean_size += index_control.clean_pkgs_index(self.quiet) # return total size of deleted or to delete files return clean_size diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py index e3bc21a..23c7f3b 100644 --- a/pym/gentoolkit/eclean/cli.py +++ b/pym/gentoolkit/eclean/cli.py @@ -555,7 +555,7 @@ def doAction(action, options, exclude={}, output=None): ) # initialize our cleaner - cleaner = CleanUp(output.progress_controller) + cleaner = CleanUp(output.progress_controller, options["quiet"]) # actually clean files if something was found if clean_me: diff --git a/pym/gentoolkit/eclean/pkgindex.py b/pym/gentoolkit/eclean/pkgindex.py index 617b437..d0878a1 100644 --- a/pym/gentoolkit/eclean/pkgindex.py +++ b/pym/gentoolkit/eclean/pkgindex.py @@ -11,6 +11,11 @@ import gentoolkit.pprinter as pp from gentoolkit.eprefix import EPREFIX import portage +from portage.module import ( + InvalidModuleName, + Modules, +) +from portage.emaint.main import TaskHandler class PkgIndex: @@ -32,37 +37,36 @@ class PkgIndex: @sets: self.binhost to BinhostHandler class @rtype: boolean """ - # About noqa below: I don't understand how this code can run at all. - # TODO: verify soundness try: - self.emaint_control = Modules() # noqa + self.emaint_control = Modules() self.binhost = self.emaint_control._get_class("binhost") - except InvalidModuleName as er: # noqa + 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 - def _load_modules(self): - """Import the emaint modules and report the success/fail of them""" - try: - from emaint.module import Modules # noqa - from emaint.main import TaskHandler # noqa - except ImportError: - return False - return True + def clean_pkgs_index(self, quiet): + """This will clean the binpkgs packages index file - def clean_pkgs_index( - self, - ): - """This will clean the binpkgs packages index file""" - go = self._load_modules() - if go: - if self.get_emaint_binhost(): - self.taskmaster = TaskHandler(show_progress_bar=True) # noqa - tasks = [self.binhost] - self.taskmaster.run_tasks(tasks) + @param quiet: boolean + @return: the difference in file size + """ + 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) + tasks = [self.binhost] + self.taskmaster.run_tasks(tasks) + else: + self.call_emaint() + statinfo = os.stat(file_) + clean_size = size1 - statinfo.st_size + self.controller("\n", clean_size, "Packages Index", file_, "Index") + return clean_size def call_emaint(self): """Run the stand alone emaint script from @@ -71,9 +75,6 @@ class PkgIndex: @rtype: integer @return: the difference in file size """ - file_ = os.path.join(portage.settings["PKGDIR"], "Packages") - statinfo = os.stat(file_) - size1 = statinfo.st_size try: retcode = subprocess.call(self.emaint_cmd, shell=True) if retcode < 0: @@ -83,8 +84,3 @@ class PkgIndex: ) except OSError as e: print(pp.error("Execution failed:" + e), file=sys.stderr) - print() - statinfo = os.stat(file_) - clean_size = size1 - statinfo.st_size - self.controller(clean_size, "Packages Index", file_, "Index") - return clean_size