Add error and warning reports at the end of builds
This commit is contained in:
@@ -46,6 +46,8 @@ class CLI(pisi.ui.UI):
|
|||||||
|
|
||||||
def __init__(self, show_debug = False, show_verbose = False):
|
def __init__(self, show_debug = False, show_verbose = False):
|
||||||
super(CLI, self).__init__(show_debug, show_verbose)
|
super(CLI, self).__init__(show_debug, show_verbose)
|
||||||
|
self.warnings = 0
|
||||||
|
self.errors = 0
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
pisi.util.xterm_title_reset()
|
pisi.util.xterm_title_reset()
|
||||||
@@ -70,6 +72,7 @@ class CLI(pisi.ui.UI):
|
|||||||
|
|
||||||
def warning(self, msg, verbose = False):
|
def warning(self, msg, verbose = False):
|
||||||
msg = unicode(msg)
|
msg = unicode(msg)
|
||||||
|
self.warnings += 1
|
||||||
if ctx.log:
|
if ctx.log:
|
||||||
ctx.log.warning(msg)
|
ctx.log.warning(msg)
|
||||||
if ctx.get_option('no_color'):
|
if ctx.get_option('no_color'):
|
||||||
@@ -79,6 +82,7 @@ class CLI(pisi.ui.UI):
|
|||||||
|
|
||||||
def error(self, msg):
|
def error(self, msg):
|
||||||
msg = unicode(msg)
|
msg = unicode(msg)
|
||||||
|
self.errors += 1
|
||||||
if ctx.log:
|
if ctx.log:
|
||||||
ctx.log.error(msg)
|
ctx.log.error(msg)
|
||||||
if ctx.get_option('no_color'):
|
if ctx.get_option('no_color'):
|
||||||
|
|||||||
+21
-13
@@ -45,6 +45,9 @@ import pisi.db
|
|||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ActionScriptException(Error):
|
||||||
|
pass
|
||||||
|
|
||||||
# Helper Functions
|
# Helper Functions
|
||||||
def get_file_type(path, pinfo_list, install_dir):
|
def get_file_type(path, pinfo_list, install_dir):
|
||||||
"""Return the file type of a path according to the given PathInfo
|
"""Return the file type of a path according to the given PathInfo
|
||||||
@@ -304,7 +307,7 @@ class Builder:
|
|||||||
|
|
||||||
def fetch_component(self):
|
def fetch_component(self):
|
||||||
if not self.spec.source.partOf:
|
if not self.spec.source.partOf:
|
||||||
ctx.ui.warning(_('PartOf tag not defined, looking for component'))
|
ctx.ui.info(_('PartOf tag not defined, looking for component'))
|
||||||
diruri = pisi.util.parenturi(self.specuri.get_uri())
|
diruri = pisi.util.parenturi(self.specuri.get_uri())
|
||||||
parentdir = pisi.util.parenturi(diruri)
|
parentdir = pisi.util.parenturi(diruri)
|
||||||
url = pisi.util.join_path(parentdir, 'component.xml')
|
url = pisi.util.join_path(parentdir, 'component.xml')
|
||||||
@@ -456,11 +459,11 @@ class Builder:
|
|||||||
if line.startswith("~"):
|
if line.startswith("~"):
|
||||||
line = os.environ["HOME"] + line[1:]
|
line = os.environ["HOME"] + line[1:]
|
||||||
valid_paths.append(line)
|
valid_paths.append(line)
|
||||||
|
|
||||||
# Extra path for ccache when needed
|
# Extra path for ccache when needed
|
||||||
if ctx.config.values.build.buildhelper == "ccache":
|
if ctx.config.values.build.buildhelper == "ccache":
|
||||||
valid_paths.append("%s/.ccache" % os.environ["HOME"])
|
valid_paths.append("%s/.ccache" % os.environ["HOME"])
|
||||||
|
|
||||||
ret = catbox.run(self.actionLocals[func], valid_paths, logger=self.log_sandbox_violation)
|
ret = catbox.run(self.actionLocals[func], valid_paths, logger=self.log_sandbox_violation)
|
||||||
# Retcode can be 0 while there is a sanbox violation, so only look for violations to correctly handle it
|
# Retcode can be 0 while there is a sanbox violation, so only look for violations to correctly handle it
|
||||||
if ret.violations != []:
|
if ret.violations != []:
|
||||||
@@ -468,15 +471,13 @@ class Builder:
|
|||||||
for result in ret.violations:
|
for result in ret.violations:
|
||||||
ctx.ui.error("* %s (%s -> %s)" % (result[0], result[1], result[2]))
|
ctx.ui.error("* %s (%s -> %s)" % (result[0], result[1], result[2]))
|
||||||
raise Error(_("Sandbox violations!"))
|
raise Error(_("Sandbox violations!"))
|
||||||
else:
|
|
||||||
# Retcode is 1 when there is a python exception.
|
if ret.code == 1:
|
||||||
# This is for actionsapi's exceptions. Without this, when exception is raised, build process continues.
|
raise ActionScriptException
|
||||||
if ret.code == 1:
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
else:
|
||||||
if mandatory:
|
if mandatory:
|
||||||
raise Error(_("unable to call function from actions: %s") % func)
|
raise Error(_("unable to call function from actions: %s") % func)
|
||||||
|
|
||||||
os.chdir(curDir)
|
os.chdir(curDir)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -501,7 +502,7 @@ class Builder:
|
|||||||
extra_deps = [dependency.Dependency(package = x) for x in extra_names]
|
extra_deps = [dependency.Dependency(package = x) for x in extra_names]
|
||||||
build_deps.extend(extra_deps)
|
build_deps.extend(extra_deps)
|
||||||
else:
|
else:
|
||||||
ctx.ui.warning(_('Safety switch: system.devel is already installed'))
|
ctx.ui.info(_('Safety switch: system.devel is already installed'))
|
||||||
else:
|
else:
|
||||||
ctx.ui.warning(_('Safety switch: the component system.devel cannot be found'))
|
ctx.ui.warning(_('Safety switch: the component system.devel cannot be found'))
|
||||||
|
|
||||||
@@ -947,11 +948,11 @@ class Builder:
|
|||||||
if ctx.get_option('debug'):
|
if ctx.get_option('debug'):
|
||||||
abandoned_files = self.get_abandoned_files()
|
abandoned_files = self.get_abandoned_files()
|
||||||
if abandoned_files:
|
if abandoned_files:
|
||||||
ctx.ui.warning(_('Abandoned files under the install dir (%s):') % (install_dir))
|
ctx.ui.warning(_('There are abandoned files under the install dir (%s):') % (install_dir))
|
||||||
for f in abandoned_files:
|
for f in abandoned_files:
|
||||||
ctx.ui.info(' - %s' % (f))
|
ctx.ui.info(' - %s' % (f))
|
||||||
else:
|
else:
|
||||||
ctx.ui.warning(_('All of the files under the install dir (%s) has been collected by package(s)')
|
ctx.ui.info(_('All of the files under the install dir (%s) has been collected by package(s)')
|
||||||
% (install_dir))
|
% (install_dir))
|
||||||
|
|
||||||
if ctx.config.values.general.autoclean is True:
|
if ctx.config.values.general.autoclean is True:
|
||||||
@@ -978,7 +979,14 @@ def build(pspec):
|
|||||||
pb = Builder(pspec)
|
pb = Builder(pspec)
|
||||||
else:
|
else:
|
||||||
pb = Builder.from_name(pspec)
|
pb = Builder.from_name(pspec)
|
||||||
return pb.build()
|
try:
|
||||||
|
result = pb.build()
|
||||||
|
except ActionScriptException:
|
||||||
|
ctx.ui.error("Action script error caught.")
|
||||||
|
sys.exit(1)
|
||||||
|
finally:
|
||||||
|
ctx.ui.warning("*** %d error(s), %d warning(s)" % (ctx.ui.errors, ctx.ui.warnings))
|
||||||
|
return result
|
||||||
|
|
||||||
order = {"none": 0,
|
order = {"none": 0,
|
||||||
"fetch": 1,
|
"fetch": 1,
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class UI(object):
|
|||||||
def __init__(self, debuggy = False, verbose = False):
|
def __init__(self, debuggy = False, verbose = False):
|
||||||
self.show_debug = debuggy
|
self.show_debug = debuggy
|
||||||
self.show_verbose = verbose
|
self.show_verbose = verbose
|
||||||
|
self.errors = 0
|
||||||
|
self.warnings = 0
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"cleanup stuff here"
|
"cleanup stuff here"
|
||||||
|
|||||||
Reference in New Issue
Block a user