* fix: replace sys.exit's with raise's
* fix a related comment
This commit is contained in:
+1
-5
@@ -584,11 +584,7 @@ def prepare_for_build(pspecfile, authInfo=None):
|
|||||||
ctx.ui.error(_("Unsatisfied Build Dependencies:"))
|
ctx.ui.error(_("Unsatisfied Build Dependencies:"))
|
||||||
for dep in dep_unsatis:
|
for dep in dep_unsatis:
|
||||||
ctx.ui.warning(dep.package)
|
ctx.ui.warning(dep.package)
|
||||||
|
# FIXME: raise an exception if ignore-depends not given
|
||||||
# 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)
|
|
||||||
|
|
||||||
return pb
|
return pb
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -220,11 +220,9 @@ class PisiBuild:
|
|||||||
buf = open(scriptfile).read()
|
buf = open(scriptfile).read()
|
||||||
exec compile(buf, "error", "exec") in localSymbols, globalSymbols
|
exec compile(buf, "error", "exec") in localSymbols, globalSymbols
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
ctx.ui.error(_("Unable to read Action Script (%s): %s") %(scriptfile,e))
|
raise Error(_("Unable to read Action Script (%s): %s") %(scriptfile,e))
|
||||||
sys.exit(1)
|
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
ctx.ui.error (_("SyntaxError in Action Script (%s): %s") %(scriptfile,e))
|
raise Error(_("SyntaxError in Action Script (%s): %s") %(scriptfile,e))
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
self.actionLocals = localSymbols
|
self.actionLocals = localSymbols
|
||||||
self.actionGlobals = globalSymbols
|
self.actionGlobals = globalSymbols
|
||||||
|
|||||||
+11
-6
@@ -22,6 +22,11 @@ import pisi.cli
|
|||||||
import pisi.context as ctx
|
import pisi.context as ctx
|
||||||
from pisi.uri import URI
|
from pisi.uri import URI
|
||||||
|
|
||||||
|
|
||||||
|
class Error(pisi.Error):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Command(object):
|
class Command(object):
|
||||||
"""generic help string for any command"""
|
"""generic help string for any command"""
|
||||||
|
|
||||||
@@ -45,8 +50,7 @@ class Command(object):
|
|||||||
return Command.cmd_dict[cmd]()
|
return Command.cmd_dict[cmd]()
|
||||||
|
|
||||||
if fail:
|
if fail:
|
||||||
ctx.ui.info(_("Unrecognized command: ") + cmd)
|
raise Error(_("Unrecognized command: ") + cmd)
|
||||||
sys.exit(1)
|
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
get_command = staticmethod(get_command)
|
get_command = staticmethod(get_command)
|
||||||
@@ -102,7 +106,7 @@ class Command(object):
|
|||||||
dir = str(self.options.destdir)
|
dir = str(self.options.destdir)
|
||||||
import os.path
|
import os.path
|
||||||
if not os.path.exists(dir):
|
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)
|
self.options.destdir = os.path.realpath(dir)
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +164,8 @@ class Command(object):
|
|||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
"""exit program"""
|
"""exit program"""
|
||||||
ctx.ui.error(_('Program terminated abnormally.'))
|
#FIXME: not called from anywhere?
|
||||||
|
ctx.ui.error(_('Command terminated abnormally.'))
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
||||||
@@ -170,11 +175,11 @@ class autocommand(type):
|
|||||||
Command.cmd.append(cls)
|
Command.cmd.append(cls)
|
||||||
name = getattr(cls, 'name', None)
|
name = getattr(cls, 'name', None)
|
||||||
if name is None:
|
if name is None:
|
||||||
raise pisi.cli.Error(_('command lacks name'))
|
raise pisi.cli.Error(_('Command lacks name'))
|
||||||
longname, shortname = name
|
longname, shortname = name
|
||||||
def add_cmd(cmd):
|
def add_cmd(cmd):
|
||||||
if Command.cmd_dict.has_key(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:
|
else:
|
||||||
Command.cmd_dict[cmd] = cls
|
Command.cmd_dict[cmd] = cls
|
||||||
add_cmd(longname)
|
add_cmd(longname)
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ class LockedDBShelf(shelve.DBShelf):
|
|||||||
try:
|
try:
|
||||||
fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
except IOError:
|
except IOError:
|
||||||
import sys
|
raise Error(_("Another instance of PISI is running. Try later!"))
|
||||||
pisi.context.ui.error(_("Another instance of PISI is running. Try later!"))
|
|
||||||
sys.exit(1)
|
|
||||||
return self.db.open(filename, dbname, filetype, flags, mode)
|
return self.db.open(filename, dbname, filetype, flags, mode)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
|||||||
+1
-3
@@ -45,9 +45,7 @@ class PackageDB(object):
|
|||||||
try:
|
try:
|
||||||
fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
fcntl.flock(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
import sys
|
raise Error(_("Cannot lock PackageDB: %s") % e)
|
||||||
ctx.ui.error("PackageDB: %s" % e)
|
|
||||||
sys.exit(1)
|
|
||||||
self.d = shelve.open(self.fname)
|
self.d = shelve.open(self.fname)
|
||||||
self.dr = shelve.open(self.fname2)
|
self.dr = shelve.open(self.fname2)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user