[elbe-devel] [PATCH 3/8] shellhelper: make CommandError log the command and returncode properly

Torben Hohn torben.hohn at linutronix.de
Wed Mar 4 13:08:06 CET 2020


CommandError exceptions produce this log, because CommandError.__str__()
returns an empty string.

----------------------------------------------------------------------------------------------------------------
[ERROR] Build failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/elbepack/asyncworker.py", line 186, in execute
    skip_pbuild=self.skip_pbuilder)
  File "/usr/lib/python2.7/dist-packages/elbepack/elbeproject.py", line 551, in build
    self.get_rpcaptcache())
  File "/usr/lib/python2.7/dist-packages/elbepack/efilesystem.py", line 83, in extract_target
    copy_filelist(src, file_list, dst)
  File "/usr/lib/python2.7/dist-packages/elbepack/efilesystem.py", line 40, in copy_filelist
    dst.fname(f)))
  File "/usr/lib/python2.7/dist-packages/elbepack/shellhelper.py", line 41, in system
    raise CommandError(cmd, ret)
CommandError
----------------------------------------------------------------------------------------------------------------

Don't init the Exceptionbase with no parameters and change __repr__ to __str__

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/shellhelper.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/elbepack/shellhelper.py b/elbepack/shellhelper.py
index c73642c78..203b5f4ca 100644
--- a/elbepack/shellhelper.py
+++ b/elbepack/shellhelper.py
@@ -20,15 +20,13 @@ soap = logging.getLogger("soap")
 
 class CommandError(Exception):
     def __init__(self, cmd, returncode):
-        Exception.__init__(self)
         self.returncode = returncode
         self.cmd = cmd
 
-    def __repr__(self):
+    def __str__(self):
         return "Error: %d returned from Command %s" % (
             self.returncode, self.cmd)
 
-
 def system(cmd, allow_fail=False, env_add=None):
     new_env = os.environ.copy()
     if env_add:
-- 
2.20.1




More information about the elbe-devel mailing list