<s> """<STR_LIT>""" <EOL> __docformat__ = '<STR_LIT>' <EOL> import os <EOL> import signal <EOL> import time <EOL> from subprocess import Popen , STDOUT <EOL> def get_yolk_dir ( ) : <EOL> """<STR_LIT>""" <EOL> return os . path . abspath ( "<STR_LIT>" % os . path . expanduser ( "<STR_LIT>" ) ) <EOL> def run_command ( cmd , env = None , max_timeout = None ) : <EOL> """<STR_LIT>""" <EOL> arglist = cmd . split ( ) <EOL> output = os . tmpfile ( ) <EOL> try : <EOL> pipe = Popen ( arglist , stdout = output , stderr = STDOUT , env = env ) <EOL> except Exception as errmsg : <EOL> return <NUM_LIT:1> , errmsg <EOL> if max_timeout : <EOL> start = time . time ( ) <EOL> while pipe . poll ( ) is None : <EOL> time . sleep ( <NUM_LIT:0.1> ) <EOL> if time . time ( ) - start > max_timeout : <EOL> os . kill ( pipe . pid , signal . SIGINT ) <EOL> pipe . wait ( ) <EOL> return <NUM_LIT:1> , "<STR_LIT>" <EOL> pipe . wait ( ) <EOL> output . seek ( <NUM_LIT:0> ) <EOL> return pipe . returncode , output . read ( ) <EOL> def command_successful ( cmd ) : <EOL> """<STR_LIT>""" <EOL> return_code , _output = run_command ( cmd ) <EOL> return return_code == <NUM_LIT:0> </s>
