@@ -492,34 +492,40 @@ def cli(*args, return_output=False):
492492 return 0
493493
494494
495- def _exec_cmd (cmd , stdin = None , stdout = PIPE , stderr = STDOUT , env :dict = None ):
496- lines = []
497-
498- env = env or {}
499- for k ,v in os .environ .items ():
500- env [k ] = env .get (k , v )
501-
502- env ['SLING_PACKAGE' ] = 'python'
503- for pkg in ['dagster' , 'airflow' , 'temporal' , 'orkes' ]:
504- if is_package (pkg ):
505- env ['SLING_PACKAGE' ] = pkg
506-
507- with Popen (cmd , shell = True , env = env , stdin = stdin , stdout = stdout , stderr = stderr ) as proc :
508- if stdout and stdout != STDOUT and proc .stdout :
509- for line in proc .stdout :
510- line = str (line .strip (), 'utf-8' , errors = 'replace' )
511- yield line
495+ def _exec_cmd (
496+ cmd : str , stdin = None , stdout = PIPE , stderr = STDOUT , env : dict [str , str ] | None = None
497+ ):
498+ lines : list [str ] = []
512499
513- proc .wait ()
514-
515- if stderr and stderr != STDOUT and proc .stderr :
516- lines = '\n ' .join (list (proc .stderr ))
517-
518- if proc .returncode != 0 :
519- if len (lines ) > 0 :
520- raise Exception (f'Sling command failed:\n { lines } ' )
521- raise Exception (f'Sling command failed' )
500+ env = env or {}
501+ for k , v in os .environ .items ():
502+ env [k ] = env .get (k , v )
522503
504+ env ["SLING_PACKAGE" ] = "python"
505+ for pkg in ["dagster" , "airflow" , "temporal" , "orkes" ]:
506+ if is_package (pkg ):
507+ env ["SLING_PACKAGE" ] = pkg
508+
509+ with Popen (
510+ cmd , shell = True , env = env , stdin = stdin , stdout = stdout , stderr = stderr
511+ ) as proc :
512+ if stdout and stdout != STDOUT and proc .stdout :
513+ for line in proc .stdout :
514+ line = str (line .strip (), "utf-8" , errors = "replace" )
515+ lines .append (line )
516+ yield line
517+
518+ proc .wait ()
519+
520+ if stderr and stderr != STDOUT and proc .stderr :
521+ lines .extend (
522+ str (line .strip (), "utf-8" , errors = "replace" ) for line in proc .stderr
523+ )
524+
525+ if proc .returncode != 0 :
526+ if len (lines ) > 0 :
527+ raise Exception (f"Sling command failed:\n { '\n ' .join (lines )} " )
528+ raise Exception ("Sling command failed" )
523529
524530
525531class SlingError (Exception ):
0 commit comments