'write something into treedir/hostname'

def write_tree_file(self, hostname, buf):

    buf = to_bytes(buf)
    try:
        makedirs_safe(self.tree)
        path = os.path.join(self.tree, hostname)
        with open(path, 'wb+') as fd:
            fd.write(buf)
    except (OSError, IOError) as e:
        self._display.warning(("Unable    to    write    to    %s's    file:    %s" % (hostname, str(e))))
