This function, sometimes doesn't return the error info, for example on "fatal" results.
|
def _exec_cmd(cmd, stdin=None, stdout=PIPE, stderr=STDOUT, env:dict=None): |
|
lines = [] |
|
|
|
env = env or {} |
|
for k,v in os.environ.items(): |
|
env[k] = env.get(k, v) |
|
|
|
env['SLING_PACKAGE'] = 'python' |
|
for pkg in ['dagster', 'airflow', 'temporal', 'orkes']: |
|
if is_package(pkg): |
|
env['SLING_PACKAGE'] = pkg |
|
|
|
with Popen(cmd, shell=True, env=env, stdin=stdin, stdout=stdout, stderr=stderr) as proc: |
|
if stdout and stdout != STDOUT and proc.stdout: |
|
for line in proc.stdout: |
|
line = str(line.strip(), 'utf-8', errors='replace') |
|
yield line |
|
|
|
proc.wait() |
|
|
|
if stderr and stderr != STDOUT and proc.stderr: |
|
lines = '\n'.join(list(proc.stderr)) |
|
|
|
if proc.returncode != 0: |
|
if len(lines) > 0: |
|
raise Exception(f'Sling command failed:\n{lines}') |
|
raise Exception(f'Sling command failed') |
|
|
To reproduce use an invalid stream, it will just said Sling command failed, this is probably because the error is on STDOUT instead and lines aren't being added.
This function, sometimes doesn't return the error info, for example on "fatal" results.
sling-python/sling/sling/__init__.py
Lines 495 to 522 in 27d541e
To reproduce use an invalid stream, it will just said Sling command failed, this is probably because the error is on STDOUT instead and lines aren't being added.