#NEWLINE# def upload_distribution( self , upload_file ) : #NEWLINE# #INDENT# '\n        Upload distribution file and update redis data.\n        ' #NEWLINE# filename = secure_filename ( upload_file . filename ) #NEWLINE# self . logger . info ( 'Uploading distribution: {}' . format ( filename ) ) #NEWLINE# if self . storage . exists ( filename ) : #NEWLINE# #INDENT# self . logger . warn ( 'Aborting upload of: {}; already exists' . format ( filename ) ) #NEWLINE# raise ConflictError ( ) #NEWLINE# #UNINDENT# path = self . storage . write ( filename , upload_file . read ( ) ) #NEWLINE# try : #NEWLINE# #INDENT# self . logger . debug ( 'Parsing source distribution for metadata' ) #NEWLINE# metadata = self . _get_metadata ( path , filename ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# self . logger . debug ( 'Removing uploaded file: {} on error' . format ( filename ) ) #NEWLINE# self . storage . remove ( filename ) #NEWLINE# raise #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . history . add ( metadata [ 'name' ] , metadata [ 'version' ] ) #NEWLINE# self . projects . add_metadata ( metadata )