<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def install_host(trg_queue, *hosts, **kwargs):
    ''' Atomically install host queues '''
    user = kwargs.pop('user', None)
    group = kwargs.pop('group', None)
    mode = kwargs.pop('mode', None)
    item_user = kwargs.pop('item_user', None)
    item_group = kwargs.pop('item_group', None)
    item_mode = kwargs.pop('item_mode', None)
    is_down = kwargs.pop('is_down', False)

    #set modes
    mode, user, group, item_user, item_group, item_mode =\
        _def_mode(mode, user, group, item_user, item_group, item_mode)
    uid, gid = uid_gid(user, group)
    host_path = fsq_path.hosts(trg_queue)
    try:
        _instdir(host_path, mode, uid, gid)
    except (OSError, IOError, ), e:
        if e.errno not in ( errno.EEXIST, errno.ENOTEMPTY, ):
            raise FSQInstallError(e.errno, wrap_io_os_err(e))
    if hosts:
        for host in hosts:
            host = fsq_path.valid_name(host)
            # uid_gid makes calls to the pw db and|or gr db, in addition to
            # potentially stat'ing, as such, we want to avoid calling it
            # unless we absoultely have to
            uid, gid = uid_gid(user, group)
            tmp_full, tmp_queue = _tmp_trg(host, host_path)
            try:
                # open once to cut down on stat/open for chown/chmod combo
                fd = os.open(tmp_full, os.O_RDONLY)
                try:
                    # always fchmod here as mkdtemp is different than normal
                    # mkdir
                    os.fchmod(fd, mode)
                    if -1 != uid or -1 != gid:
                        os.fchown(fd, uid, gid)
                finally:
                    os.close(fd)

                # bless our queue with its children
                _instdir(fsq_path.tmp(trg_queue, tmp_queue), mode, uid, gid)
                _instdir(fsq_path.queue(trg_queue, tmp_queue), mode, uid, gid)
                _instdir(fsq_path.done(trg_queue, tmp_queue), mode, uid, gid)
                _instdir(fsq_path.fail(trg_queue, tmp_queue), mode, uid, gid)

                # down via configure.down if necessary
                if is_down:
                    down_host(tmp_queue, host, user=item_user,
                              group=item_group, mode=item_mode)

                # atomic commit -- by rename
                os.rename(tmp_full, fsq_path.base(trg_queue, host))
            except (OSError, IOError, ), e:
                shutil.rmtree(tmp_full)
                if e.errno == errno.ENOTEMPTY:
                    raise FSQInstallError(e.errno, u'queue exists: {0}'.format(
                                          trg_queue))
                if isinstance(e, FSQError):
                    raise e