diff --git a/pisi/api.py b/pisi/api.py index 30ac32f7..39be35b6 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -584,11 +584,7 @@ def prepare_for_build(pspecfile, authInfo=None): ctx.ui.error(_("Unsatisfied Build Dependencies:")) for dep in dep_unsatis: ctx.ui.warning(dep.package) - - # FIXME: Don't exit for now! It's annoying to test on a system that - # doesn't has all packages made with pisi. - # Will be enabled on the full-pisi system. - # sys.exit(1) + # FIXME: raise an exception if ignore-depends not given return pb diff --git a/pisi/build.py b/pisi/build.py index d2fa59c9..f26dc50a 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -220,11 +220,9 @@ class PisiBuild: buf = open(scriptfile).read() exec compile(buf, "error", "exec") in localSymbols, globalSymbols except IOError, e: - ctx.ui.error(_("Unable to read Action Script (%s): %s") %(scriptfile,e)) - sys.exit(1) + raise Error(_("Unable to read Action Script (%s): %s") %(scriptfile,e)) except SyntaxError, e: - ctx.ui.error (_("SyntaxError in Action Script (%s): %s") %(scriptfile,e)) - sys.exit(1) + raise Error(_("SyntaxError in Action Script (%s): %s") %(scriptfile,e)) self.actionLocals = localSymbols self.actionGlobals = globalSymbols diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 46db7c79..71748eea 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -22,6 +22,11 @@ import pisi.cli import pisi.context as ctx from pisi.uri import URI + +class Error(pisi.Error): + pass + + class Command(object): """generic help string for any command""" @@ -45,8 +50,7 @@ class Command(object): return Command.cmd_dict[cmd]() if fail: - ctx.ui.info(_("Unrecognized command: ") + cmd) - sys.exit(1) + raise Error(_("Unrecognized command: ") + cmd) else: return None get_command = staticmethod(get_command) @@ -102,7 +106,7 @@ class Command(object): dir = str(self.options.destdir) import os.path if not os.path.exists(dir): - raise Exception, _('Destination directory %s does not exist') % dir + raise Error, _('Destination directory %s does not exist') % dir self.options.destdir = os.path.realpath(dir) @@ -160,7 +164,8 @@ class Command(object): def die(self): """exit program""" - ctx.ui.error(_('Program terminated abnormally.')) + #FIXME: not called from anywhere? + ctx.ui.error(_('Command terminated abnormally.')) sys.exit(-1) @@ -170,11 +175,11 @@ class autocommand(type): Command.cmd.append(cls) name = getattr(cls, 'name', None) if name is None: - raise pisi.cli.Error(_('command lacks name')) + raise pisi.cli.Error(_('Command lacks name')) longname, shortname = name def add_cmd(cmd): if Command.cmd_dict.has_key(cmd): - raise pisi.cli.Error(_('duplicate command %s') % cmd) + raise pisi.cli.Error(_('Duplicate command %s') % cmd) else: Command.cmd_dict[cmd] = cls add_cmd(longname) diff --git a/pisi/lockeddbshelve.py b/pisi/lockeddbshelve.py index 8d8bd306..2c82c632 100644 --- a/pisi/lockeddbshelve.py +++ b/pisi/lockeddbshelve.py @@ -57,9 +57,7 @@ class LockedDBShelf(shelve.DBShelf): try: fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: - import sys - pisi.context.ui.error(_("Another instance of PISI is running. Try later!")) - sys.exit(1) + raise Error(_("Another instance of PISI is running. Try later!")) return self.db.open(filename, dbname, filetype, flags, mode) def close(self): diff --git a/pisi/packagedb.py b/pisi/packagedb.py index d43097f5..6d2e28e3 100644 --- a/pisi/packagedb.py +++ b/pisi/packagedb.py @@ -45,9 +45,7 @@ class PackageDB(object): try: fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: - import sys - ctx.ui.error("PackageDB: %s" % e) - sys.exit(1) + raise Error(_("Cannot lock PackageDB: %s") % e) self.d = shelve.open(self.fname) self.dr = shelve.open(self.fname2)