UDPFile_receiver.py
def parse_file_request_response(self, data):
        ''' Parse received file request response message from receiver application
            to body and header -> extract file size and return True if
            file was found else return False '''

        header, body = self.parse_data(data)
        ret_dict = {}

        # NET DERPER CHANGES FIRST NUM TO CHAR
        if not str(chr(header[0])).isnumeric():
            ret_dict["return"] = PARSE_RETURNS["wrong_message_type"]
            return ret_dict

        message_type = int(str(chr(header[0])))
        if ord(chr(message_type)) != MESSAGE_TYPES['file_request_successful'] and ord(chr(message_type )) != MESSAGE_TYPES['file_request_unsuccessful'] : 
            print(f'ERROR in parse_file_request_response(): Message type {ord(chr(message_type))} doesn\'t match {MESSAGE_TYPES["file_request_successful"]} or  {MESSAGE_TYPES["file_request_unsuccessful"]}')
            ret_dict["return"] = PARSE_RETURNS["wrong_message_type"]
            return ret_dict

        # Check CRC
        if not check_crc_received_message(data):
            ret_dict["return"] = PARSE_RETURNS["wrong_crc"]
            return ret_dict

        file_size = '0'
        print(f"body: {body}")
        # pop_zeros(body)
        for body_int_char in body:
            if body_int_char == 0: break
            print(f"body_int_char: {body_int_char}")
            file_size = file_size + str(chr(body_int_char))
        print(f"file_size: {file_size}")
        self.file_byte_size = int(file_size)

        if ord(chr(message_type )) == MESSAGE_TYPES['file_request_successful']:
            ret_dict["return"] = PARSE_RETURNS["request_successful"]
            return ret_dict
        else:
            ret_dict["return"] =PARSE_RETURNS["request_unsuccessful"]
            return ret_dict
 Parse received file request response message from receiver application
            to body and header -> extract file size and return True if
            file was found else return False 
Parse received file request response message from receiver application
to body and header -> extract file size and return True if
file was found else return False
Parse received file request response message from receiver application to body and header - > extract file size and return True if file was found else return False
def parse_file_request_response(self, data):
        header, body = self.parse_data(data)
        ret_dict = {}
        if not str(chr(header[0])).isnumeric():
            ret_dict["return"] = PARSE_RETURNS["wrong_message_type"]
            return ret_dict
        message_type = int(str(chr(header[0])))
        if ord(chr(message_type)) != MESSAGE_TYPES['file_request_successful'] and ord(chr(message_type )) != MESSAGE_TYPES['file_request_unsuccessful'] : 
            print(f'ERROR in parse_file_request_response(): Message type {ord(chr(message_type))} doesn\'t match {MESSAGE_TYPES["file_request_successful"]} or  {MESSAGE_TYPES["file_request_unsuccessful"]}')
            ret_dict["return"] = PARSE_RETURNS["wrong_message_type"]
            return ret_dict
        if not check_crc_received_message(data):
            ret_dict["return"] = PARSE_RETURNS["wrong_crc"]
            return ret_dict
        file_size = '0'
        print(f"body: {body}")
        for body_int_char in body:
            if body_int_char == 0: break
            print(f"body_int_char: {body_int_char}")
            file_size = file_size + str(chr(body_int_char))
        print(f"file_size: {file_size}")
        self.file_byte_size = int(file_size)
        if ord(chr(message_type )) == MESSAGE_TYPES['file_request_successful']:
            ret_dict["return"] = PARSE_RETURNS["request_successful"]
            return ret_dict
        else:
            ret_dict["return"] =PARSE_RETURNS["request_unsuccessful"]
            return ret_dict
def parse_file_request_response ( self , data ) : header , body = self . parse_data ( data ) ret_dict = { } if not str ( chr ( header [ 0 ] ) ) . isnumeric ( ) : ret_dict [ "return" ] = PARSE_RETURNS [ "wrong_message_type" ] return ret_dict message_type = int ( str ( chr ( header [ 0 ] ) ) ) if ord ( chr ( message_type ) ) != MESSAGE_TYPES [ 'file_request_successful' ] and ord ( chr ( message_type ) ) != MESSAGE_TYPES [ 'file_request_unsuccessful' ] : print ( f'ERROR in parse_file_request_response(): Message type {ord(chr(message_type))} doesn\'t match {MESSAGE_TYPES["file_request_successful"]} or  {MESSAGE_TYPES["file_request_unsuccessful"]}' ) ret_dict [ "return" ] = PARSE_RETURNS [ "wrong_message_type" ] return ret_dict if not check_crc_received_message ( data ) : ret_dict [ "return" ] = PARSE_RETURNS [ "wrong_crc" ] return ret_dict file_size = '0' print ( f"body: {body}" ) for body_int_char in body : if body_int_char == 0 : break print ( f"body_int_char: {body_int_char}" ) file_size = file_size + str ( chr ( body_int_char ) ) print ( f"file_size: {file_size}" ) self . file_byte_size = int ( file_size ) if ord ( chr ( message_type ) ) == MESSAGE_TYPES [ 'file_request_successful' ] : ret_dict [ "return" ] = PARSE_RETURNS [ "request_successful" ] return ret_dict else : ret_dict [ "return" ] = PARSE_RETURNS [ "request_unsuccessful" ] return ret_dict
Parse received file request response message from receiver application
to body and header -> extract file size and return True if
file was found else return False
Parse received file request response message from receiver application to body and header - > extract file size and return True if file was found else return False
''' Parse received file request response message from receiver application
            to body and header -> extract file size and return True if
            file was found else return False ''' # NET DERPER CHANGES FIRST NUM TO CHAR
 # Check CRC
 # pop_zeros(body)

self
data