<s> import subprocess <EOL> import re <EOL> import _thread <EOL> import os <EOL> def strip_margin ( text ) : <EOL> """<STR_LIT>""" <EOL> return re . sub ( '<STR_LIT>' , '<STR_LIT:\n>' , text ) <EOL> def write_classpath_sbt_script ( build_file , scala_version , ensime_version , classpath_file ) : <EOL> with open ( build_file , "<STR_LIT:w>" ) as f : <EOL> if os . name == "<STR_LIT>" : <EOL> classpath_file = classpath_file . replace ( "<STR_LIT:\\>" , "<STR_LIT>" ) <EOL> f . write ( strip_margin ( """<STR_LIT>""" + '<STR_LIT:">' + scala_version + '<STR_LIT:">' + """<STR_LIT>""" + '<STR_LIT:">' + ensime_version + '<STR_LIT:">' + """<STR_LIT>""" + '<STR_LIT:">' + classpath_file + '<STR_LIT:">' + """<STR_LIT>""" ) ) <EOL> def write_build_props_file ( build_props_file ) : <EOL> with open ( build_props_file , "<STR_LIT:w>" ) as f : <EOL> f . write ( """<STR_LIT>""" ) <EOL> def exec_save_classpath ( logger , sbt_cmd , working_dir , classpath_file , classpath_log , callback_fn ) : <EOL> """<STR_LIT>""" <EOL> def worker ( ) : <EOL> logger . info ( "<STR_LIT>" ) <EOL> cmd = sbt_cmd + [ "<STR_LIT>" ] <EOL> with open ( classpath_log , "<STR_LIT:w>" ) as output_file : <EOL> res = subprocess . call ( cmd , cwd = working_dir , stdout = output_file , stderr = subprocess . STDOUT ) <EOL> if res == <NUM_LIT:0> : <EOL> with open ( classpath_file , "<STR_LIT:r>" ) as f : <EOL> read_classpath = f . read ( ) . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> logger . info ( "<STR_LIT>" ) <EOL> callback_fn ( read_classpath ) <EOL> else : <EOL> logger . info ( "<STR_LIT>" + str ( res ) + "<STR_LIT>" + str ( classpath_log ) ) <EOL> callback_fn ( None ) <EOL> _thread . start_new_thread ( worker , ( ) ) </s>
