#NEWLINE# def which( bin_name , additional_dirs = None , ensure_executable = True ) : #NEWLINE# #INDENT# def check_it( path ) : #NEWLINE# #INDENT# if ( not path ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( not isfile ( path ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( ensure_executable and ( not os . access ( path , os . X_OK ) ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# full_name = distutils . spawn . find_executable ( bin_name ) #NEWLINE# if check_it ( full_name ) : #NEWLINE# #INDENT# return full_name #NEWLINE# #UNINDENT# if ( not additional_dirs ) : #NEWLINE# #INDENT# additional_dirs = [ ] #NEWLINE# #UNINDENT# for dir_name in additional_dirs : #NEWLINE# #INDENT# full_name = joinpths ( dirname ( dirname ( abspth ( anvil . __file__ ) ) ) , dir_name , bin_name ) #NEWLINE# if check_it ( full_name ) : #NEWLINE# #INDENT# return full_name #NEWLINE# #UNINDENT# #UNINDENT# raise excp . FileException ( ( "Can't find %s" % bin_name ) )