This commit is contained in:
LDAP/paul_yang 2014-12-02 02:58:26 +00:00
Родитель df8b4b0629
Коммит 46f927faab
1 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -1,5 +1,5 @@
import logging
from subprocess import Popen, PIPE
from subprocess import Popen, STDOUT, PIPE
from airflow.models import BaseOperator
from airflow.utils import apply_defaults
@ -25,12 +25,13 @@ class BashOperator(BaseOperator):
logging.info("Runnning command: " + bash_command)
sp = Popen(
bash_command, shell=True, stdout=PIPE, stderr=PIPE)
out, err = sp.communicate()
sp.wait()
bash_command, shell=True, stdout=PIPE, stderr=STDOUT)
logging.info("Output:")
for line in iter(sp.stdout.readline, ''):
logging.info(line.strip())
sp.wait()
logging.info("Command exited with return code %d", sp.returncode)
logging.info("Command STDOUT:\n" + out)
if err:
logging.error(err)
if sp.returncode:
raise Exception("Bash command failed")