From 51b1bb1579c7e2ab6aec878c851905b53bd6d7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 22 Nov 2005 12:52:39 +0000 Subject: [PATCH] * fetch component in build_packages (fixes #856) * CLI status() method sets xterm title * add a close method to ui interface, and call it in api.finalize() * build start message uses status() --- pisi/api.py | 1 + pisi/build.py | 6 +++--- pisi/cli/__init__.py | 5 +++++ pisi/ui.py | 4 ++++ pisi/util.py | 12 ++++++++---- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index dfe71f9e..a9548b77 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -93,6 +93,7 @@ def finalize(): packagedb.finalize_db() pisi.sourcedb.finalize() ctx.ui.debug('PISI API finalized') + ctx.ui.close() ctx.initialized = False def list_upgradable(): diff --git a/pisi/build.py b/pisi/build.py index ba006845..0e8a0214 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -165,8 +165,7 @@ class Builder: def build(self): """Build the package in one shot.""" - ctx.ui.info(_("Building PISI source package: %s") % self.spec.source.name) - util.xterm_title(_("Building PISI source package: %s\n") % self.spec.source.name) + ctx.ui.status(_("Building PISI source package: %s") % self.spec.source.name) self.compile_action_script() @@ -584,6 +583,8 @@ class Builder: from copy import deepcopy + self.fetch_component() # bug 856 + # Strip install directory before building .pisi packages. self.strip_install_dir() @@ -654,7 +655,6 @@ class Builder: pkg.close() os.chdir(c) self.set_state("buildpackages") - util.xterm_title_reset() ctx.ui.info(_("Done.")) if ctx.config.values.general.autoclean is True: diff --git a/pisi/cli/__init__.py b/pisi/cli/__init__.py index 1b8c9141..e7672b21 100644 --- a/pisi/cli/__init__.py +++ b/pisi/cli/__init__.py @@ -21,6 +21,7 @@ import pisi import pisi.context as ctx from pisi.ui import UI import pisi.ui as ui +import pisi.util as util from pisi.cli.colors import colorize @@ -48,6 +49,9 @@ class CLI(UI): def __init__(self, show_debug = False, show_verbose = False): super(CLI, self).__init__(show_debug, show_verbose) + def close(self): + util.xterm_title_reset() + def output(self, msg, err = False): if type(msg)==type(unicode()): msg = msg.encode('utf-8') @@ -123,6 +127,7 @@ class CLI(UI): def status(self, msg = None): if msg: self.output(colorize(msg + '\n', 'purple')) + util.xterm_title(msg) def notify(self, event, **keywords): if event == ui.installed: diff --git a/pisi/ui.py b/pisi/ui.py index 7767646e..643dc143 100644 --- a/pisi/ui.py +++ b/pisi/ui.py @@ -44,6 +44,10 @@ class UI(object): def __init__(self, debuggy = False, verbose = False): self.show_debug = debuggy self.show_verbose = verbose + + def close(self): + "cleanup stuff here" + pass def set_verbose(self, flag): self.show_verbose = flag diff --git a/pisi/util.py b/pisi/util.py index a0b72946..8617836b 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -137,11 +137,15 @@ def run_batch(cmd): ctx.ui.error(_('Failed command: %s') % cmd + strlist(lines)) return (successful,lines) +###################### +# Terminal functions # +###################### + +def has_xterm(): + return os.environ.has_key("TERM") and sys.stderr.isatty() + def xterm_title(message): """sets message as a console window's title""" - return - #TODO: the last thing needed in util probably - #this is going to be moved to pisi.cli later if os.environ.has_key("TERM") and sys.stderr.isatty(): terminalType = os.environ["TERM"] for term in ["xterm", "Eterm", "aterm", "rxvt", "screen", "kterm", "rxvt-unicode"]: @@ -152,11 +156,11 @@ def xterm_title(message): def xterm_title_reset(): """resets console window's title""" - #TODO: this, too. if os.environ.has_key("TERM"): terminalType = os.environ["TERM"] xterm_title(os.environ["TERM"]) + ############################# # Path Processing Functions # #############################