'Send data packets from the local file to the server'

def send_data(self):

    if (not self.connection._sock):
        raise err.InterfaceError("(0,    '')")
    conn = self.connection
    try:
        with open(self.filename, 'rb') as open_file:
            packet_size = min(conn.max_allowed_packet, (16 * 1024))
            while True:
                chunk = open_file.read(packet_size)
                if (not chunk):
                    break
                conn.write_packet(chunk)
    except IOError:
        raise err.OperationalError(1017, "Can't    find    file    '{0}'".format(self.filename))
    finally:
        conn.write_packet('')
