From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/
Date: Sun, 8 Oct 2023 03:28:40 +0000 (UTC) [thread overview]
Message-ID: <1696735655.c846c08c046588a98f2b40a45ac74b84cda21a89.sam@gentoo> (raw)
commit: c846c08c046588a98f2b40a45ac74b84cda21a89
Author: Siddhanth Rathod <xsiddhanthrathod <AT> gmail <DOT> com>
AuthorDate: Thu Oct 5 13:29:32 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 8 03:27:35 2023 +0000
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=c846c08c
eclean: pkg: fix pkgindex handling
Last implemention was importing binhost module incorrectly:
calling Modules() from portage.module which sets binhost var to the BinhostHandler class
which would always fail as it needs name and namepath, leading to always call emaint
via a subprocess call.
Signed-off-by: Siddhanth Rathod <xsiddhanthrathod <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>
pym/gentoolkit/eclean/clean.py | 17 +++++---
pym/gentoolkit/eclean/pkgindex.py | 86 ---------------------------------------
2 files changed, 11 insertions(+), 92 deletions(-)
diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py
index 87d7aac..92449b4 100644
--- a/pym/gentoolkit/eclean/clean.py
+++ b/pym/gentoolkit/eclean/clean.py
@@ -8,7 +8,9 @@ import os
import sys
import gentoolkit.pprinter as pp
-from gentoolkit.eclean.pkgindex import PkgIndex
+import portage
+from portage.emaint.main import TaskHandler
+from portage.emaint.modules.binhost import binhost
class CleanUp:
@@ -61,11 +63,14 @@ class CleanUp:
# run 'emaint --fix' here
if clean_size:
- index_control = PkgIndex(self.controller)
- # emaint is not yet importable so call it
- # print a blank line here for separation
- print()
- clean_size += index_control.clean_pkgs_index(self.quiet)
+ file = os.path.join(portage.settings["PKGDIR"], "Packages")
+ size1 = os.stat(file).st_size
+ TaskHandler(show_progress_bar=self.quiet).run_tasks(
+ [binhost.BinhostHandler], "fix"
+ )
+ size = size1 - os.stat(file).st_size
+ self.controller(size, "Packages Index", file, "Index")
+ clean_size += size
# return total size of deleted or to delete files
return clean_size
diff --git a/pym/gentoolkit/eclean/pkgindex.py b/pym/gentoolkit/eclean/pkgindex.py
deleted file mode 100644
index 7d6fade..0000000
--- a/pym/gentoolkit/eclean/pkgindex.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/python
-
-# Copyright 2003-2010 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-import subprocess
-import os
-import sys
-
-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:
- """Handle the cleaning of the binpkg Package
- Index file
-
- @type output: class
- @param output: optional output class for printing
- """
-
- 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
-
- def clean_pkgs_index(self, quiet):
- """This will clean the binpkgs packages index file
-
- @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(clean_size, "Packages Index", file_, "Index")
- return clean_size
-
- def call_emaint(self):
- """Run the stand alone emaint script from
- a subprocess call.
-
- @rtype: integer
- @return: the difference in file size
- """
- try:
- retcode = subprocess.call(self.emaint_cmd, shell=True)
- if retcode < 0:
- print(
- pp.error("Child was terminated by signal" + str(-retcode)),
- file=sys.stderr,
- )
- except OSError as e:
- print(pp.error("Execution failed:" + e), file=sys.stderr)
next reply other threads:[~2023-10-08 3:28 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-08 3:28 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-05-03 5:42 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/ Sam James
2024-05-03 5:40 Sam James
2024-05-03 5:40 Sam James
2024-05-03 5:40 Sam James
2024-05-03 5:11 Sam James
2024-02-18 2:19 Brian Dolbec
2024-02-18 2:19 Brian Dolbec
2024-01-19 7:03 Sam James
2024-01-19 6:15 Sam James
2024-01-12 19:16 Matt Turner
2023-12-03 7:51 Sam James
2023-10-08 3:28 Sam James
2023-09-29 7:20 Sam James
2023-08-24 19:52 Sam James
2023-08-22 20:54 Sam James
2023-08-22 20:52 Sam James
2023-08-22 20:50 Sam James
2023-08-22 20:50 Sam James
2023-08-22 20:35 Sam James
2023-08-21 5:16 Sam James
2023-08-21 5:16 Sam James
2022-07-11 7:17 Brian Dolbec
2022-07-09 22:45 Brian Dolbec
2022-07-09 21:46 Brian Dolbec
2022-06-01 10:25 Yixun Lan
2022-05-28 15:28 Yixun Lan
2022-02-09 10:48 Sam James
2020-06-09 17:29 Zac Medico
2020-03-12 16:51 Matt Turner
2020-03-12 16:51 Matt Turner
2020-01-03 4:31 Matt Turner
2019-12-05 16:51 Matt Turner
2019-12-05 16:51 Matt Turner
2019-09-13 23:34 Zac Medico
2017-12-12 5:51 Zac Medico
2016-07-03 6:29 Zac Medico
2016-07-01 6:19 Zac Medico
2016-06-24 21:40 Zac Medico
2016-06-24 21:36 Zac Medico
2016-06-23 20:01 Paul Varner
2015-10-19 21:33 Paul Varner
2015-10-15 21:39 Paul Varner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1696735655.c846c08c046588a98f2b40a45ac74b84cda21a89.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox