UDPFile_sender.py
def parse_file_request(self, data):
        ''' Parse received file request message from receiver application
            to body and header -> extract file name and return it. '''

        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

        # Check message type
        message_type = int(str(chr(int(header[0]))))
       # print(f"TESTING MESSAGE TYPE : {message_type}, before: {header[0]}")
        if message_type != MESSAGE_TYPES['file_request']: 
            print(f'ERROR in parse_file_request(): Message type {message_type} doesn\'t match {MESSAGE_TYPES["file_request"]}')
            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_path = ''
        for body_int_char in body:
            if body_int_char == 0: break
            file_path = file_path + chr(body_int_char)
        
        ret_dict["return"] = PARSE_RETURNS["request_successful"]
        ret_dict["file_path"] = file_path
        return ret_dict
 Parse received file request message from receiver application
            to body and header -> extract file name and return it. 
Parse received file request message from receiver application
to body and header -> extract file name and return it.
Parse received file request message from receiver application to body and header - > extract file name and return it .
def parse_file_request(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(int(header[0]))))
        if message_type != MESSAGE_TYPES['file_request']: 
            print(f'ERROR in parse_file_request(): Message type {message_type} doesn\'t match {MESSAGE_TYPES["file_request"]}')
            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_path = ''
        for body_int_char in body:
            if body_int_char == 0: break
            file_path = file_path + chr(body_int_char)
        ret_dict["return"] = PARSE_RETURNS["request_successful"]
        ret_dict["file_path"] = file_path
        return ret_dict
def parse_file_request ( 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 ( int ( header [ 0 ] ) ) ) ) if message_type != MESSAGE_TYPES [ 'file_request' ] : print ( f'ERROR in parse_file_request(): Message type {message_type} doesn\'t match {MESSAGE_TYPES["file_request"]}' ) 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_path = '' for body_int_char in body : if body_int_char == 0 : break file_path = file_path + chr ( body_int_char ) ret_dict [ "return" ] = PARSE_RETURNS [ "request_successful" ] ret_dict [ "file_path" ] = file_path return ret_dict
Parse received file request message from receiver application
to body and header -> extract file name and return it.
Parse received file request message from receiver application to body and header - > extract file name and return it .
''' Parse received file request message from receiver application
            to body and header -> extract file name and return it. ''' # NET DERPER CHANGES FIRST NUM TO CHAR
 # Check message type
 # print(f"TESTING MESSAGE TYPE : {message_type}, before: {header[0]}")
 # Check CRC

self
data