#NEWLINE# def run_command( cmd , args = [ ] , source = '' , cwd = None , env = None ) : #NEWLINE# #INDENT# settings = sublime . load_settings ( 'APIBlueprint.sublime-settings' ) #NEWLINE# if ( not ( type ( args ) is list ) ) : #NEWLINE# #INDENT# args = [ args ] #NEWLINE# #UNINDENT# if ( env is None ) : #NEWLINE# #INDENT# env = { #NEWLINE# #INDENT# 'PATH' : settings . get ( 'binDir' , '/usr/local/bin' ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# command = ( [ cmd ] + args ) #NEWLINE# proc = Popen ( command , env = env , cwd = cwd , stdin = PIPE , stdout = PIPE , stderr = PIPE ) #NEWLINE# stat = proc . communicate ( input = source . encode ( 'utf-8' ) ) #NEWLINE# okay = ( cwd . returncode == 0 ) #NEWLINE# lines = stat [ 1 ] . decode ( 'UTF-8' ) . split ( '\n' ) #NEWLINE# if ( not lines [ 0 ] ) : #NEWLINE# #INDENT# lines . pop ( 0 ) #NEWLINE# #UNINDENT# sanitized_errout = '\n' . join ( lines ) #NEWLINE# return { #NEWLINE# #INDENT# 'okay' : okay , #NEWLINE# 'out' : stat [ 0 ] . decode ( 'UTF-8' ) , #NEWLINE# 'err' : sanitized_errout , #NEWLINE# #UNINDENT# }