* fix: replace sys.exit's with raise's

* fix a related comment
This commit is contained in:
Eray Özkural
2005-10-11 22:25:26 +00:00
parent f9dceb042d
commit 5c9c72512b
5 changed files with 16 additions and 21 deletions
+1 -5
View File
@@ -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
+2 -4
View File
@@ -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
+11 -6
View File
@@ -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)
+1 -3
View File
@@ -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):
+1 -3
View File
@@ -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)