@@ -112,7 +112,7 @@ def check_command(command: str, *, hint: str):
112112 f"Check { hint } is installed and available." )
113113
114114
115- def run_command (command : str , * , err_msg : str = '' , env : dict = None ) -> list [str ]:
115+ def run_command (command : str , * , err_msg : str = '' , env : dict | None = None ) -> list [str ]:
116116 """Runs a command in a shell process.
117117
118118 Returns a list of strings gathered from a command.
@@ -127,15 +127,17 @@ def run_command(command: str, *, err_msg: str = '', env: dict = None) -> list[st
127127
128128 """
129129 if env :
130- env = dict (os .environ , ** env )
131-
132- prc = Popen (command , stdout = PIPE , stderr = STDOUT , shell = True , universal_newlines = True , env = env )
130+ env = {** os .environ , ** env }
133131
134132 LOG .debug (f'Run command: `{ command } ` ...' )
135133
134+ prc = Popen (command , stdout = PIPE , stderr = STDOUT , shell = True , universal_newlines = True , env = env )
135+
136136 data = []
137137 out , _ = prc .communicate ()
138138
139+ LOG .debug (f'Command output:\n `{ out } `' )
140+
139141 for item in out .splitlines ():
140142 item = item .strip ()
141143
@@ -145,6 +147,6 @@ def run_command(command: str, *, err_msg: str = '', env: dict = None) -> list[st
145147 data .append (item )
146148
147149 if prc .returncode :
148- raise CommandError (err_msg or f"Command ` { command } ` failed: %s" % '\n ' .join (data ))
150+ raise CommandError (err_msg or f"Command ' { command } ' failed: { '\n ' .join (data )} " )
149151
150152 return data
0 commit comments