'Write to the named pipe handle or the file handle.
This function will wait until the write operation has completed.
:param buf: string representing the buffer which will be written
:param to_namedpipe: boolean representing where to write the buffer
True = the buffer \'buf\' will be written to the named pipe handle
False = the buffer \'buf\' will be written to the file handle'

def blocking_write(self, buf, to_namedpipe=True):

    if ((not to_namedpipe) and (self._npipe_file is None)):
        raise NamedPipeException('create_file    must    be    called    first.')
    handle_to_write = (self.namedpipe if to_namedpipe else self._npipe_file)
    encoded_buf = ovs_winutils.get_encoded_buffer(buf)
    (errCode, _nBytesWritten) = avoid_blocking_call(ovs_winutils.write_file, handle_to_write, encoded_buf, None)
    if errCode:
        raise NamedPipeException('Could    not    write    to    named    pipe.', errCode)
