when I execute a command (while true; do date; sleep 1; done) over a Python-Skript nothing is displyed and no logging.
import logging
import sys
import subprocess as SP
logger = logging.getLogger('logging')
logger.setLevel(logging.INFO)
if not logger.handlers:
log_handler = logging.FileHandler('test_logging.log')
formatter = logging.Formatter('%(asctime)s %(message)s')
log_handler.setFormatter(formatter)
logger.addHandler(log_handler)
log_handler.setLevel(logging.INFO)
command = 'while true; do date; sleep 1; done'
p = SP.Popen(command, shell=True, stdout=SP.PIPE, stderr=SP.PIPE)
print p.stdout.readlines()
for line in p.stdout.readlines():
logger.info(line)
print line