#NEWLINE# @ tthrow #NEWLINE# @ login_async #NEWLINE# @ defer . inlineCallbacks #NEWLINE# def UploadToCapsule( self , archive , capsule , title , description , sandbox ) : #NEWLINE# #INDENT# '\n          void UploadToCapsule(1: string ArchiveLocalID, 2: string CapsuleID,\n            3: string title, 4: string description, 5: bool sandbox)\n        ' #NEWLINE# docs = self . cache . get_adf ( archive ) #NEWLINE# docs [ 'archive' ] . title = title #NEWLINE# docs [ 'archive' ] . description = description #NEWLINE# status = self . cache . archive_status ( archive , capsule ) #NEWLINE# if ( status != ttypes . ArchiveStatus . Local ) : #NEWLINE# #INDENT# raise ValueError ( 'Archive state invalid' ) #NEWLINE# #UNINDENT# size = docs [ 'archive' ] . meta . size #NEWLINE# cs = ( yield self . session . async_capsules ( ) ) #NEWLINE# for c in cs : #NEWLINE# #INDENT# if ( c [ 'id' ] == int ( capsule ) ) : #NEWLINE# #INDENT# if ( c . get ( 'remaining' , 0 ) >= docs [ 'archive' ] . meta . size ) : #NEWLINE# #INDENT# capsule = c #NEWLINE# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Capsule is not big enough' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Capsule not found' ) #NEWLINE# #UNINDENT# state = UploadState . get ( archive , size , capsule , sandbox ) #NEWLINE# if ( state . exc is not None ) : #NEWLINE# #INDENT# raise ValueError ( 'Archive has error' ) #NEWLINE# #UNINDENT# self . _upload ( archive , docs , state )