示例#1
0
def desktop_profiles():
    open_, close = get_open_close(date.today())
    now = datetime.today()

    # If the lab has opened, but hasn't closed yet, only count
    # statistics until the current time. If the lab isn't open
    # yet, then don't count anything, and if it is closed, show
    # statistics from when it was open during the day.
    if now > open_ and now < close:
        end = now
    elif now <= open_:
        end = open_
    else:
        end = close

    return sorted(
        UtilizationProfile.from_hostnames(list_desktops(), open_, end).values(),
        key=attrgetter('hostname'),
    )
示例#2
0
def desktop_profiles() -> List[Any]:
    open_, close = get_open_close(date.today())
    now = datetime.today()

    # If the lab has opened, but hasn't closed yet, only count
    # statistics until the current time. If the lab isn't open
    # yet, then don't count anything, and if it is closed, show
    # statistics from when it was open during the day.
    if now > open_ and now < close:
        end = now
    elif now <= open_:
        end = open_
    else:
        end = close

    return sorted(
        UtilizationProfile.from_hostnames(list_desktops(), open_, end).values(),
        key=attrgetter('hostname'),
    )