@@ -20,22 +20,37 @@ def __init__(self, logger):
2020 self .logger = logger
2121 self .hostRpmIsNotUsable = - 1
2222
23- def run (self , cmd , update_env = False ):
24- self .logger .debug (cmd )
25- use_shell = not isinstance (cmd , list )
26- process = subprocess .Popen (cmd , shell = use_shell , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
27- out ,err = process .communicate ()
28- retval = process .returncode
29- if out != b'' :
30- self .logger .info (out .decode ())
31- if update_env :
32- os .environ .clear ()
33- os .environ .update (dict (line .partition ('=' )[::2 ] for line in out .decode ('utf8' ).split ('\0 ' ) if line ))
34- if retval != 0 :
35- self .logger .info ("Command failed: {}" .format (cmd ))
36- self .logger .info ("Error code: {}" .format (retval ))
37- self .logger .error (err .decode ())
38- return retval
23+ def run (self , cmd , update_env = False ):
24+ """if FileNotFoundError raised by subprocess,
25+ error code 127 report up on the stack"""
26+ retval = 127
27+ try :
28+ use_shell = not isinstance (cmd , list )
29+ process = subprocess .Popen (
30+ cmd , shell = use_shell ,
31+ stdout = subprocess .PIPE ,
32+ stderr = subprocess .PIPE
33+ )
34+ out , err = process .communicate ()
35+ retval = process .returncode
36+ if out != b'' :
37+ self .logger .info (out .decode ())
38+ if update_env :
39+ os .environ .clear ()
40+ os .environ .update (
41+ dict (line .partition ('=' )[::2 ]
42+ for line in out .decode ('utf8' ).split ('\0 ' )
43+ if line )
44+ )
45+ if retval != 0 :
46+ self .logger .info ("Command failed: {}" .format (cmd ))
47+ self .logger .info ("Error code: {}" .format (retval ))
48+ self .logger .error (err .decode ())
49+ except FileNotFoundError as _ :
50+ self .logger .info (f"Command { cmd } not found" )
51+
52+ finally :
53+ return retval
3954
4055 def run_in_chroot (self , chroot_path , cmd , update_env = False ):
4156 # Use short command here. Initial version was:
0 commit comments