Kaydet (Commit) b979d52d authored tarafından Eray Özkural's avatar Eray Özkural

* pisicli: we have a uniform exception naming (only name change there)

* improve pisish a little
üst 8b1518e7
......@@ -19,7 +19,7 @@ import bsddb3.db as db
import pisi.ui
import pisi.context as ctx
from pisi.cli.pisicli import PisiCLI, CLIError
import pisi.cli.pisicli as pisicli
import gettext
__trans = gettext.translation('pisi', fallback=True)
......@@ -64,7 +64,7 @@ Please file a bug report. (http://bugs.uludag.org.tr)"""))
ui.info(_("Traceback:"))
traceback.print_tb(tb)
else:
if not exception is CLIError:
if not exception is pisicli.Error:
ui.info(_("Use --debug to see a traceback."))
exit()
......@@ -74,7 +74,7 @@ if __name__ == "__main__":
sys.excepthook = handle_exception
locale.setlocale(locale.LC_ALL, '')
cli = PisiCLI()
cli = pisicli.PisiCLI()
try:
cli.run_command()
except pisi.operations.PisiUpgradeException, e:
......
......@@ -29,10 +29,6 @@ class ParserError(pisi.Exception):
class Error(pisi.Error):
pass
class CLIError(Error):
pass
class PreParser(OptionParser):
"""consumes any options, and finds arguments from command line"""
......@@ -98,14 +94,14 @@ class PisiCLI(object):
sys.exit(0)
elif 'help' in opts or 'h' in opts:
self.die()
raise CLIError(_('No command given'))
raise Error(_('No command given'))
cmd_name = args[0]
except ParserError:
raise CLIError(_('Command line parsing error'))
raise Error(_('Command line parsing error'))
self.command = Command.get_command(cmd_name, args=orig_args)
if not self.command:
raise CLIError(_("Unrecognized command: %s") % cmd_name)
raise Error(_("Unrecognized command: %s") % cmd_name)
def die(self):
printu('\n' + self.parser.format_help())
......
......@@ -31,14 +31,14 @@ def exit(retval = 0):
pisi.api.finalize()
sys.exit(retval)
if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '')
print """Welcome to the interactive PISI shell.
Type "help" to see a list of commands.
To end the session, type "exit".
Copyright 2006 (c) Pardus
You can run system commands by prefixing with '!' as in '!ls'.
Copyright 2006 (c) Pardus.
"""
while 1:
cmd = raw_input('pisi> ')
......@@ -58,21 +58,19 @@ Copyright 2006 (c) Pardus
signal.signal(signal.SIGINT, signal.SIG_IGN) # disable further interrupts
ui = pisi.cli.CLI() # make a temporary UI
show_traceback = False
pisi.api.finalize()
if isinstance(value, exceptions.KeyboardInterrupt):
ui.error(_("Keyboard Interrupt: Exiting..."))
sys.exit(1)
elif isinstance(value, pisi.Error):
ui.error(_("Program Terminated."))
show_traceback = ctx.get_option('debug')
elif isinstance(value, db.DBRunRecoveryError):
ui.error(_("""A database operation has been aborted. You should run pisi
again for normal DB recovery procedure. Make sure you have free disk space.
You have to run rebuild-db only when there is file corruption and database upgrades."""))
again for normal DB recovery procedure. Make sure you have free disk space.
You have to run rebuild-db only when there is file corruption and database upgrades."""))
elif isinstance(value, pisi.Exception):
show_traceback = True
ui.error(_("""Unhandled internal exception.
Please file a bug report. (http://bugs.uludag.org.tr)"""))
Please file a bug report. (http://bugs.uludag.org.tr)"""))
else:
# For any other exception (possibly Python exceptions) show
# the traceback!
......@@ -84,10 +82,11 @@ Copyright 2006 (c) Pardus
else:
ui.error(unicode(value))
ui.info(_("Please use 'pisi help' for general help."))
ui.info(_("Please type 'help' for general help."))
if show_traceback:
ui.info(_("Traceback:"))
traceback.print_tb(tb)
#traceback.print_exc(file=sys.stdout)
traceback.print_tb(sys.exc_traceback)
else:
ui.info(_("Use --debug to see a traceback."))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment