@@ -261,17 +261,19 @@ def __run_script(self, *, parallel: bool | None) -> Path | None:
261261
262262 return script
263263
264+ @staticmethod
265+ def __cmd_name (cmd : Sequence [str | os .PathLike [str ]] | str ) -> str :
266+ if isinstance (cmd , str ):
267+ cmd = shlex .split (cmd )
268+
269+ return Path (cmd [0 ]).name
270+
264271 @contextmanager
265272 def __output (
266273 self , cmd : Sequence [str | os .PathLike [str ]] | str , * , log : bool
267274 ) -> Generator [tuple [int | IO [str ], int | IO [str ]], None , None ]:
268275 if log :
269- if isinstance (cmd , str ):
270- name = shlex .split (cmd )[0 ]
271- else :
272- name = Path (cmd [0 ]).name if isinstance (cmd [0 ], os .PathLike ) else cmd [0 ]
273-
274- with (self .path / f"log.{ name } " ).open ("a" ) as stdout :
276+ with (self .path / f"log.{ self .__cmd_name (cmd )} " ).open ("a" ) as stdout :
275277 yield stdout , STDOUT
276278 else :
277279 yield DEVNULL , DEVNULL
@@ -280,11 +282,6 @@ def __output(
280282 def __process_stdout (
281283 self , cmd : Sequence [str | os .PathLike [str ]] | str
282284 ) -> Generator [Callable [[str ], None ], None , None ]:
283- if isinstance (cmd , str ):
284- name = shlex .split (cmd )[0 ]
285- else :
286- name = Path (cmd [0 ]).name if isinstance (cmd [0 ], os .PathLike ) else cmd [0 ]
287-
288285 try :
289286 with self .control_dict as control_dict :
290287 if control_dict ["stopAt" ] == "endTime" :
@@ -299,7 +296,9 @@ def __process_stdout(
299296 end_time = None
300297
301298 with self .__progress as progress :
302- task = progress .add_task (f"({ self .name } ) Running { name } ..." , total = None )
299+ task = progress .add_task (
300+ f"({ self .name } ) Running { self .__cmd_name (cmd )} ..." , total = None
301+ )
303302
304303 def process_stdout (line : str ) -> None :
305304 if line .startswith ("Time = " ):
0 commit comments