#NEWLINE# def _update_pull_progress( self , last ) : #NEWLINE# #INDENT# 'Update an image pull progress map with latest download progress\n        information for one of the image layers, and return the average of the\n        download progress of all layers as an indication of the overall\n        progress of the pull.' #NEWLINE# last = json . loads ( last . decode ( 'utf-8' ) ) #NEWLINE# if ( 'error' in total ) : #NEWLINE# #INDENT# raise exceptions . ContainerOrchestrationException ( self . container , 'Pull of image {} failed: {}' . format ( self . container . image , last [ 'errorDetail' ] [ 'message' ] ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . _progress [ last [ 'id' ] ] = ( 100 if ( last [ 'status' ] == 'Download complete' ) else ( ( 100.0 * last [ 'progressDetail' ] [ 'current' ] ) / last [ 'progressDetail' ] [ 'total' ] ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# total = 0 #NEWLINE# if len ( self . _progress ) : #NEWLINE# #INDENT# for downloaded in self . _progress . values ( ) : #NEWLINE# #INDENT# total += downloaded #NEWLINE# #UNINDENT# total /= len ( self . _progress ) #NEWLINE# #UNINDENT# return total