#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def _upload( self , f , d , s ) : #NEWLINE# #INDENT# size = d [ 'archive' ] . meta . size #NEWLINE# acmd = self . registry . cmd . archive #NEWLINE# with s : #NEWLINE# #INDENT# with ServerProgressHandler ( maxval = size , state = s ) as progq : #NEWLINE# #INDENT# with self . cache . _archive_open ( f , 'w' ) as _archive : #NEWLINE# #INDENT# make_adf ( list ( d . itervalues ( ) ) , out = _archive ) #NEWLINE# #UNINDENT# saved = ( yield acmd . upload_async ( _archive , f , progq , s ) ) #NEWLINE# #UNINDENT# status = ( yield acmd . _poll_status_async ( saved [ 'link' ] ) ) #NEWLINE# while ( status is None ) : #NEWLINE# #INDENT# getLogger ( ) . debug ( "couldn't get status, retrying.." ) #NEWLINE# status = ( yield acmd . _poll_status_async ( saved [ 'link' ] ) ) #NEWLINE# #UNINDENT# getLogger ( ) . debug ( 'API returned status: {}' . format ( status ) ) #NEWLINE# if ( status [ 'status' ] == 'error' ) : #NEWLINE# #INDENT# raise UploadError ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( status [ 'status' ] == 'completed' ) : #NEWLINE# #INDENT# fname = saved [ 'fname' ] #NEWLINE# getLogger ( ) . debug ( 'upload completed' ) #NEWLINE# self . cache . save_cert ( self . cache . upload_complete ( fname , status ) ) #NEWLINE# self . reset_upload ( f )