* more small fixes

This commit is contained in:
Eray Özkural
2005-10-05 00:31:21 +00:00
parent 457316bc73
commit 3849195910
4 changed files with 15 additions and 20 deletions
+1 -3
View File
@@ -59,9 +59,7 @@ Please file a bug report! (http://bugs.uludag.org.tr)
sys.exit(1) sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '')
sys.excepthook = handle_exception sys.excepthook = handle_exception
cli = PisiCLI() cli = PisiCLI()
+5 -3
View File
@@ -92,11 +92,13 @@ def install(packages):
#FIXME: As Gurer warns, something's fishy with this exception proc. #FIXME: As Gurer warns, something's fishy with this exception proc.
except InstallError, e: 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: except packagedb.Error, e:
ctx.ui.error("PackageDBError: (%s)" % e) ctx.ui.error("PackageDBError: (%s)" % str(e))
ctx.ui.error("Package is not installable.") ctx.ui.error(_("Package is not installable."))
#except Exception, e: #except Exception, e:
# print e # print e
+8 -13
View File
@@ -40,21 +40,15 @@ class CLI(UI):
def __init__(self, show_debug = False, show_verbose = False): def __init__(self, show_debug = False, show_verbose = False):
super(CLI, self).__init__(show_debug, show_verbose) super(CLI, self).__init__(show_debug, show_verbose)
locale.setlocale(locale.LC_ALL, '') 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: if err:
out = sys.stdout out = sys.stdout
else: else:
out = sys.stderr out = sys.stderr
out.write(str.encode(self.encoding)) out.write(msg)
out.flush() out.flush()
def info(self, msg, verbose = False, noln = False): 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: if ctx.config.options and ctx.config.options.yes_all:
return True return True
while True: while True:
s = raw_input(msg + colorize(_('(yes/no)'), 'red')) prompt = msg + colorize(_('(yes/no)'), 'red')
if s.startswith(_('y')) or s.startswith(_('Y')): s = raw_input(prompt.encode('utf-8'))
if s.startswith(_('y').encode('utf-8')) or s.startswith(_('Y').encode('utf-8')):
return True 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 return False
def display_progress(self, pd): def display_progress(self, pd):
+1 -1
View File
@@ -89,7 +89,7 @@ class PisiCLI(object):
self.command = Command.get_command(cmd_name) self.command = Command.get_command(cmd_name)
if not self.command: if not self.command:
print _("Unrecognized command: "), cmd ctx.ui.error(_("Unrecognized command: %s") % cmd_name)
self.die() self.die()
def die(self): def die(self):