From 38491959103d0eb21c2576bec80c26061a27d8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Wed, 5 Oct 2005 00:31:21 +0000 Subject: [PATCH] * more small fixes --- pisi-cli | 4 +--- pisi/api.py | 8 +++++--- pisi/cli/__init__.py | 21 ++++++++------------- pisi/cli/pisicli.py | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/pisi-cli b/pisi-cli index 8b044408..d2b089ec 100755 --- a/pisi-cli +++ b/pisi-cli @@ -59,9 +59,7 @@ Please file a bug report! (http://bugs.uludag.org.tr) sys.exit(1) if __name__ == "__main__": - - locale.setlocale(locale.LC_ALL, '') - + sys.excepthook = handle_exception cli = PisiCLI() diff --git a/pisi/api.py b/pisi/api.py index 27ea2777..8491496e 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -92,11 +92,13 @@ def install(packages): #FIXME: As Gurer warns, something's fishy with this exception proc. except InstallError, e: - ctx.ui.error("InstallError:%s" % e) + print type(e) + ctx.ui.error(str(e)) + ctx.ui.error("InstallError:") #%s" % str(e)) except packagedb.Error, e: - ctx.ui.error("PackageDBError: (%s)" % e) - ctx.ui.error("Package is not installable.") + ctx.ui.error("PackageDBError: (%s)" % str(e)) + ctx.ui.error(_("Package is not installable.")) #except Exception, e: # print e diff --git a/pisi/cli/__init__.py b/pisi/cli/__init__.py index 838feba2..1c95bf97 100644 --- a/pisi/cli/__init__.py +++ b/pisi/cli/__init__.py @@ -40,21 +40,15 @@ class CLI(UI): def __init__(self, show_debug = False, show_verbose = False): super(CLI, self).__init__(show_debug, show_verbose) locale.setlocale(locale.LC_ALL, '') - #print locale.getlocale() - self.encoding = locale.getpreferredencoding() - locale.setlocale(locale.LC_ALL, 'C') - # workaround a silly python bug! - self.encoding = self.encoding.lower() - locale.setlocale(locale.LC_ALL, '') - if show_debug: - print 'output encoding: ', self.encoding - def output(self, str, err = False): + def output(self, msg, err = False): + if type(msg)==type(unicode()): + msg = msg.encode('utf-8') if err: out = sys.stdout else: out = sys.stderr - out.write(str.encode(self.encoding)) + out.write(msg) out.flush() def info(self, msg, verbose = False, noln = False): @@ -96,10 +90,11 @@ class CLI(UI): if ctx.config.options and ctx.config.options.yes_all: return True while True: - s = raw_input(msg + colorize(_('(yes/no)'), 'red')) - if s.startswith(_('y')) or s.startswith(_('Y')): + prompt = msg + colorize(_('(yes/no)'), 'red') + s = raw_input(prompt.encode('utf-8')) + if s.startswith(_('y').encode('utf-8')) or s.startswith(_('Y').encode('utf-8')): return True - if s.startswith(_('n')) or s.startswith(_('N')): + if s.startswith(_('n').encode('utf-8')) or s.startswith(_('N').encode('utf-8')): return False def display_progress(self, pd): diff --git a/pisi/cli/pisicli.py b/pisi/cli/pisicli.py index 2f5e70c3..f3a5cb54 100644 --- a/pisi/cli/pisicli.py +++ b/pisi/cli/pisicli.py @@ -89,7 +89,7 @@ class PisiCLI(object): self.command = Command.get_command(cmd_name) if not self.command: - print _("Unrecognized command: "), cmd + ctx.ui.error(_("Unrecognized command: %s") % cmd_name) self.die() def die(self):