From: Michael Tremer Date: Sat, 5 Jun 2021 13:35:31 +0000 (+0000) Subject: cli: Drop using Python's UI module X-Git-Tag: 0.9.28~1285^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b64412fe8bfdf4113cb6c364777bfd38bb11b1c;p=pakfire.git cli: Drop using Python's UI module Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index 5c7ee405e..eb8cfb3be 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -34,7 +34,6 @@ from . import builder from . import client from . import config from . import daemon -from . import ui from . import util from .system import system @@ -44,9 +43,6 @@ from .i18n import _ class Cli(object): default_path = "/" - def __init__(self): - self.ui = ui.cli.CliUI() - def parse_cli(self): parser = argparse.ArgumentParser( description = _("Pakfire command line interface"), @@ -243,49 +239,35 @@ class Cli(object): return args.func(args) except KeyboardInterrupt: - self.ui.message(_("Received keyboard interupt (Ctrl-C). Exiting."), - level=logging.CRITICAL) - return 128 + signal.SIGINT except DependencyError as e: - self.ui.message(_("One or more dependencies could not been resolved")) - self.ui.message("") # empty line + print(_("One or more dependencies could not been resolved")) + print("") # empty line # This exception provides a list of all problems problems, = e.args # List all problems for problem in problems: - self.ui.message(" * %s" % problem) + print(" * %s" % problem) - self.ui.message(" %s" % _("Possible solutions are:")) + print(" %s" % _("Possible solutions are:")) for solution in problem.solutions: - self.ui.message(" * %s" % solution) + print(" * %s" % solution) # Add another empty line - self.ui.message("") + print("") return 4 # Catch all errors and show a user-friendly error message. except Error as e: - self.ui.message(_("An error has occured when running Pakfire"), level=logging.CRITICAL) - - self.ui.message(_("%s: %s") % (e.__class__.__name__, e.message), - level=logging.ERROR) + print(_("An error has occured when running Pakfire")) + print(_("%s: %s") % (e.__class__.__name__, e.message)) return e.exit_code - def _dump_transaction(self, transaction): - """ - Dumps the transaction - """ - t = transaction.dump() - - for line in t.splitlines(): - self.ui.message(line) - def _execute_transaction(self, transaction): transaction.run() @@ -293,7 +275,7 @@ class Cli(object): with self.pakfire(ns) as p: for pkg in p.info(ns.package): s = pkg.dump(long=ns.long) - self.ui.message(s) + print(s) def handle_search(self, ns): with self.pakfire(ns) as p: @@ -302,7 +284,7 @@ class Cli(object): if pkg.name.endswith("-debuginfo"): continue - self.ui.message("%-24s: %s" % (pkg.name, pkg.summary)) + print("%-24s: %s" % (pkg.name, pkg.summary)) def handle_update(self, ns, check=False): with self.pakfire(ns) as p: @@ -379,7 +361,7 @@ class Cli(object): print(FORMAT % (repo.name, repo.enabled, repo.priority, len(repo))) def handle_clean(self, ns): - self.ui.message(_("Cleaning up everything...")) + print(_("Cleaning up everything...")) p = self.pakfire(ns) p.clean() @@ -389,7 +371,7 @@ class Cli(object): # This will throw an exception when there are errors transaction = p.check() - self.ui.message(_("Everything okay")) + print(_("Everything okay")) def handle_extract(self, ns): with self.pakfire(ns) as p: @@ -519,7 +501,7 @@ class CliBuilder(Cli): with b.pakfire as p: for pkg in p.info(ns.package): s = pkg.dump(long=True, filelist=ns.filelist) - self.ui.message(s) + print(s) def handle_repolist(self, ns): with self.builder(ns) as b: