#NEWLINE# def main( self , request_id , path_to_file ) : #NEWLINE# #INDENT# ( self . repository_info , self . tool ) = self . initialize_scm_tool ( client_name = self . options . repository_type ) #NEWLINE# server_url = self . get_server_url ( self . repository_info , self . tool ) #NEWLINE# ( api_client , api_root ) = self . get_api ( server_url ) #NEWLINE# request = get_review_request ( request_id , api_root ) #NEWLINE# try : #NEWLINE# #INDENT# with open ( path_to_file , 'rb' ) as f : #NEWLINE# #INDENT# content = f . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# except IOError : #NEWLINE# #INDENT# raise CommandError ( ( '%s is not a valid file.' % request_id ) ) #NEWLINE# #UNINDENT# filename = ( self . options . filename or os . path . basename ( path_to_file ) ) #NEWLINE# try : #NEWLINE# #INDENT# request . get_file_attachments ( ) . upload_attachment ( filename , content , self . options . caption ) #NEWLINE# #UNINDENT# except APIError as e : #NEWLINE# #INDENT# raise CommandError ( ( 'Error uploading file: %s' % e ) ) #NEWLINE# #UNINDENT# print ( ( 'Uploaded %s to review request %s.' % ( path_to_file , request_id ) ) )