[gnome-continuous-yocto/gnomeostree-3.28-rocko: 5331/8267] oeqa.utils.commands: limit runCmd exception output
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 5331/8267] oeqa.utils.commands: limit runCmd exception output
- Date: Sun, 17 Dec 2017 03:17:24 +0000 (UTC)
commit 68190b511531886f498a3cf57f9ad7fb126d5fcb
Author: Markus Lehtonen <markus lehtonen linux intel com>
Date: Fri Mar 24 16:43:24 2017 +0200
oeqa.utils.commands: limit runCmd exception output
Make it possible to limit the length of output lines shown in runCmd
exceptions. E.g when running bitbake we easily get thousands of lines of
log output, where only the last few (tens) are interesting or relevant
when an error occurs.
(From OE-Core rev: 403dd205828002d6ef4e8b474aedb6082289e22f)
Signed-off-by: Markus Lehtonen <markus lehtonen linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
meta/lib/oeqa/utils/commands.py | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 6528a98..cd7a5e3 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -97,7 +97,8 @@ class Result(object):
pass
-def runCmd(command, ignore_status=False, timeout=None, assert_error=True, native_sysroot=None, **options):
+def runCmd(command, ignore_status=False, timeout=None, assert_error=True,
+ native_sysroot=None, limit_exc_output=0, **options):
result = Result()
if native_sysroot:
@@ -117,10 +118,16 @@ def runCmd(command, ignore_status=False, timeout=None, assert_error=True, native
result.pid = cmd.process.pid
if result.status and not ignore_status:
+ exc_output = result.output
+ if limit_exc_output > 0:
+ split = result.output.splitlines()
+ if len(split) > limit_exc_output:
+ exc_output = "\n... (last %d lines of output)\n" % limit_exc_output + \
+ '\n'.join(split[-limit_exc_output:])
if assert_error:
- raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command,
result.status, result.output))
+ raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command,
result.status, exc_output))
else:
- raise CommandError(result.status, command, result.output)
+ raise CommandError(result.status, command, exc_output)
return result
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]