#NEWLINE# def _fetch_binary( self , name , binary_path ) : #NEWLINE# #INDENT# bootstrap_dir = os . path . realpath ( os . path . expanduser ( self . _pants_bootstrapdir ) ) #NEWLINE# bootstrapped_binary_path = os . path . join ( bootstrap_dir , binary_path ) #NEWLINE# if ( not os . path . exists ( bootstrapped_binary_path ) ) : #NEWLINE# #INDENT# downloadpath = ( bootstrapped_binary_path + '~' ) #NEWLINE# try : #NEWLINE# #INDENT# with self . _select_binary_stream ( name , binary_path ) as stream : #NEWLINE# #INDENT# with safe_open ( downloadpath , 'wb' ) as bootstrapped_binary : #NEWLINE# #INDENT# bootstrapped_binary . write ( stream ( ) ) #NEWLINE# #UNINDENT# os . rename ( downloadpath , bootstrapped_binary_path ) #NEWLINE# chmod_plus_x ( bootstrapped_binary_path ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# safe_delete ( downloadpath ) #NEWLINE# #UNINDENT# #UNINDENT# logger . debug ( 'Selected {binary} binary bootstrapped to: {path}' . format ( binary = name , path = bootstrapped_binary_path ) ) #NEWLINE# return bootstrapped_binary_path