#NEWLINE# def _read_screenshot( self , queue ) : #NEWLINE# #INDENT# data = queue . get ( ) . data #NEWLINE# header = ScreenshotHeader . parse ( data ) [ 0 ] #NEWLINE# if ( header . response_code != ScreenshotHeader . ResponseCode . OK ) : #NEWLINE# #INDENT# queue . close ( ) #NEWLINE# raise ScreenshotError ( 'Screenshot failed: {!s}' . format ( header . response_code ) ) #NEWLINE# #UNINDENT# data = header . data #NEWLINE# expected_size = self . _get_expected_bytes ( header ) #NEWLINE# while ( len ( data ) < expected_size ) : #NEWLINE# #INDENT# data += queue . get ( ) . data #NEWLINE# self . _broadcast_event ( 'progress' , len ( data ) , expected_size ) #NEWLINE# #UNINDENT# queue . close ( ) #NEWLINE# return self . _decode_image ( header , data )