* pisicli: we have a uniform exception naming (only name change there)
* improve pisish a little
This commit is contained in:
@@ -19,7 +19,7 @@ import bsddb3.db as db
|
|||||||
|
|
||||||
import pisi.ui
|
import pisi.ui
|
||||||
import pisi.context as ctx
|
import pisi.context as ctx
|
||||||
from pisi.cli.pisicli import PisiCLI, CLIError
|
import pisi.cli.pisicli as pisicli
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
@@ -64,7 +64,7 @@ Please file a bug report. (http://bugs.uludag.org.tr)"""))
|
|||||||
ui.info(_("Traceback:"))
|
ui.info(_("Traceback:"))
|
||||||
traceback.print_tb(tb)
|
traceback.print_tb(tb)
|
||||||
else:
|
else:
|
||||||
if not exception is CLIError:
|
if not exception is pisicli.Error:
|
||||||
ui.info(_("Use --debug to see a traceback."))
|
ui.info(_("Use --debug to see a traceback."))
|
||||||
|
|
||||||
exit()
|
exit()
|
||||||
@@ -74,7 +74,7 @@ if __name__ == "__main__":
|
|||||||
sys.excepthook = handle_exception
|
sys.excepthook = handle_exception
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
cli = PisiCLI()
|
cli = pisicli.PisiCLI()
|
||||||
try:
|
try:
|
||||||
cli.run_command()
|
cli.run_command()
|
||||||
except pisi.operations.PisiUpgradeException, e:
|
except pisi.operations.PisiUpgradeException, e:
|
||||||
|
|||||||
+3
-7
@@ -29,10 +29,6 @@ class ParserError(pisi.Exception):
|
|||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class CLIError(Error):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class PreParser(OptionParser):
|
class PreParser(OptionParser):
|
||||||
"""consumes any options, and finds arguments from command line"""
|
"""consumes any options, and finds arguments from command line"""
|
||||||
|
|
||||||
@@ -98,14 +94,14 @@ class PisiCLI(object):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif 'help' in opts or 'h' in opts:
|
elif 'help' in opts or 'h' in opts:
|
||||||
self.die()
|
self.die()
|
||||||
raise CLIError(_('No command given'))
|
raise Error(_('No command given'))
|
||||||
cmd_name = args[0]
|
cmd_name = args[0]
|
||||||
except ParserError:
|
except ParserError:
|
||||||
raise CLIError(_('Command line parsing error'))
|
raise Error(_('Command line parsing error'))
|
||||||
|
|
||||||
self.command = Command.get_command(cmd_name, args=orig_args)
|
self.command = Command.get_command(cmd_name, args=orig_args)
|
||||||
if not self.command:
|
if not self.command:
|
||||||
raise CLIError(_("Unrecognized command: %s") % cmd_name)
|
raise Error(_("Unrecognized command: %s") % cmd_name)
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
printu('\n' + self.parser.format_help())
|
printu('\n' + self.parser.format_help())
|
||||||
|
|||||||
+8
-9
@@ -31,14 +31,14 @@ def exit(retval = 0):
|
|||||||
pisi.api.finalize()
|
pisi.api.finalize()
|
||||||
sys.exit(retval)
|
sys.exit(retval)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
print """Welcome to the interactive PISI shell.
|
print """Welcome to the interactive PISI shell.
|
||||||
Type "help" to see a list of commands.
|
Type "help" to see a list of commands.
|
||||||
To end the session, type "exit".
|
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:
|
while 1:
|
||||||
cmd = raw_input('pisi> ')
|
cmd = raw_input('pisi> ')
|
||||||
@@ -58,21 +58,19 @@ Copyright 2006 (c) Pardus
|
|||||||
signal.signal(signal.SIGINT, signal.SIG_IGN) # disable further interrupts
|
signal.signal(signal.SIGINT, signal.SIG_IGN) # disable further interrupts
|
||||||
ui = pisi.cli.CLI() # make a temporary UI
|
ui = pisi.cli.CLI() # make a temporary UI
|
||||||
show_traceback = False
|
show_traceback = False
|
||||||
pisi.api.finalize()
|
|
||||||
if isinstance(value, exceptions.KeyboardInterrupt):
|
if isinstance(value, exceptions.KeyboardInterrupt):
|
||||||
ui.error(_("Keyboard Interrupt: Exiting..."))
|
ui.error(_("Keyboard Interrupt: Exiting..."))
|
||||||
sys.exit(1)
|
|
||||||
elif isinstance(value, pisi.Error):
|
elif isinstance(value, pisi.Error):
|
||||||
ui.error(_("Program Terminated."))
|
ui.error(_("Program Terminated."))
|
||||||
show_traceback = ctx.get_option('debug')
|
show_traceback = ctx.get_option('debug')
|
||||||
elif isinstance(value, db.DBRunRecoveryError):
|
elif isinstance(value, db.DBRunRecoveryError):
|
||||||
ui.error(_("""A database operation has been aborted. You should run pisi
|
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.
|
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."""))
|
You have to run rebuild-db only when there is file corruption and database upgrades."""))
|
||||||
elif isinstance(value, pisi.Exception):
|
elif isinstance(value, pisi.Exception):
|
||||||
show_traceback = True
|
show_traceback = True
|
||||||
ui.error(_("""Unhandled internal exception.
|
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:
|
else:
|
||||||
# For any other exception (possibly Python exceptions) show
|
# For any other exception (possibly Python exceptions) show
|
||||||
# the traceback!
|
# the traceback!
|
||||||
@@ -84,10 +82,11 @@ Copyright 2006 (c) Pardus
|
|||||||
else:
|
else:
|
||||||
ui.error(unicode(value))
|
ui.error(unicode(value))
|
||||||
|
|
||||||
ui.info(_("Please use 'pisi help' for general help."))
|
ui.info(_("Please type 'help' for general help."))
|
||||||
|
|
||||||
if show_traceback:
|
if show_traceback:
|
||||||
ui.info(_("Traceback:"))
|
ui.info(_("Traceback:"))
|
||||||
traceback.print_tb(tb)
|
#traceback.print_exc(file=sys.stdout)
|
||||||
|
traceback.print_tb(sys.exc_traceback)
|
||||||
else:
|
else:
|
||||||
ui.info(_("Use --debug to see a traceback."))
|
ui.info(_("Use --debug to see a traceback."))
|
||||||
|
|||||||
Reference in New Issue
Block a user