<s> """<STR_LIT>""" <EOL> import subprocess <EOL> import sys <EOL> import threading <EOL> from . import exceptions <EOL> from . import logger as flo_logger <EOL> def log_output ( stream , block_size = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> logger = flo_logger . get ( ) <EOL> while True : <EOL> data = stream . read ( block_size ) <EOL> if not data : <EOL> break <EOL> logger . write ( data ) <EOL> stream . close ( ) <EOL> def run ( directory , command ) : <EOL> """<STR_LIT>""" <EOL> wrapped_command = "<STR_LIT>" % ( directory , command ) <EOL> pipe = subprocess . Popen ( <EOL> wrapped_command , shell = True , <EOL> stdout = subprocess . PIPE , stderr = subprocess . STDOUT , <EOL> ) <EOL> thread = threading . Thread ( target = log_output , args = ( pipe . stdout , ) ) <EOL> thread . daemon = True <EOL> thread . start ( ) <EOL> thread . join ( ) <EOL> pipe . wait ( ) <EOL> if pipe . returncode != <NUM_LIT:0> : <EOL> raise exceptions . ShellError ( pipe . returncode ) </s>
