* fix: only caught Exception indicates internal error
caught Error indicates fatal error * show traceback only when there is an internal error or when debug option is set (global!) * fix: we have --ignore-comar option. so raise exceptions when we get comar errors.
This commit is contained in:
@@ -23,27 +23,34 @@ def handle_exception(exception, value, tb):
|
|||||||
import exceptions
|
import exceptions
|
||||||
|
|
||||||
import pisi.ui
|
import pisi.ui
|
||||||
|
import pisi.context as ctx
|
||||||
from pisi.xmlext import XmlError
|
from pisi.xmlext import XmlError
|
||||||
|
|
||||||
ui = pisi.cli.CLI()
|
ui = pisi.cli.CLI()
|
||||||
|
traceback = False
|
||||||
if exception == exceptions.KeyboardInterrupt:
|
if exception == exceptions.KeyboardInterrupt:
|
||||||
ui.error(_("\nKeyboardInterrupt: Exiting...\n"))
|
ui.error(_("\nKeyboardInterrupt: Exiting...\n"))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif exception == XmlError:
|
elif exception == XmlError:
|
||||||
ui.error(str(value))
|
ui.error(str(value))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
elif exception == pisi.Exception:
|
||||||
ui.error(_("""
|
ui.error(_("""
|
||||||
Internal PISI Error:
|
Internal PISI Error:
|
||||||
Please file a bug report! (http://bugs.uludag.org.tr)
|
Please file a bug report! (http://bugs.uludag.org.tr)
|
||||||
|
|
||||||
"""))
|
"""))
|
||||||
|
traceback = True
|
||||||
|
elif exception == pisi.Error:
|
||||||
|
ui.error(_("Fatal Error:"))
|
||||||
|
traceback = ctx.options and ctx.options.debug
|
||||||
|
|
||||||
ui.error("%s" %exception)
|
ui.error("%s" %exception)
|
||||||
ui.error("%s\n" %value)
|
ui.error("%s\n" %value)
|
||||||
|
|
||||||
|
if traceback:
|
||||||
ui.info(_("Traceback:"))
|
ui.info(_("Traceback:"))
|
||||||
traceback.print_tb(tb)
|
traceback.print_tb(tb)
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
+5
-3
@@ -17,6 +17,9 @@ import sys
|
|||||||
ver = sys.version_info
|
ver = sys.version_info
|
||||||
if ver[0] <= 2 and ver[1] < 4:
|
if ver[0] <= 2 and ver[1] < 4:
|
||||||
from sets import Set as set
|
from sets import Set as set
|
||||||
|
import gettext
|
||||||
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
|
_ = __trans.ugettext
|
||||||
|
|
||||||
import pisi
|
import pisi
|
||||||
|
|
||||||
@@ -49,11 +52,10 @@ def init(database = True, options = None, ui = None ):
|
|||||||
import comar
|
import comar
|
||||||
ctx.comard = comar.Link()
|
ctx.comard = comar.Link()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print "INSTALL COMARD!"
|
raise Error(_("COMAR: comard not fully installed"))
|
||||||
print "skipping COMAR connection for now..."
|
print "skipping COMAR connection for now..."
|
||||||
except comar.Error:
|
except comar.Error:
|
||||||
print "NEXT TIME RUN COMARD FIRST!"
|
raise Error(_("COMAR: comard not running or defunct"))
|
||||||
print "skipping COMAR connection for now..."
|
|
||||||
|
|
||||||
if ui is None:
|
if ui is None:
|
||||||
if options:
|
if options:
|
||||||
|
|||||||
Reference in New Issue
Block a user