Example #1
0
def makeHeaderTxt():
    screen_cols = monitor_func.get_screen_cols()

    txtTitle = "Chat lines"
    fillerLen = screen_cols - len(txtTitle) - 10
    txtFiller = " ".ljust(fillerLen)[:fillerLen]
    header_text = [
        ('title', txtTitle),
        txtFiller,
        ('key', "Q"),
        " exits",
    ]

    return header_text
Example #2
0
def calculateColumnWidth(columnWidth):
    screen_cols     = monitor_func.get_screen_cols()
    sumColumnWidth  = sum(columnWidth)
    listOf0         = [s for s in columnWidth if s==0]
    columns2Calc    = len(listOf0)

    if(columns2Calc):
        remainColumnWidth   = (screen_cols - sumColumnWidth) / columns2Calc
        idx = 0
        while idx < len(columnWidth):
            if(columnWidth[idx] == 0):
                columnWidth[idx] = remainColumnWidth
            idx += 1
    
    return columnWidth
Example #3
0
def makeHeaderTxt():
    screen_cols = monitor_func.get_screen_cols()

    txtTitle = "Computer Status"
    fillerLen = screen_cols - len(txtTitle) - 10
    txtFiller = " ".ljust(fillerLen)[:fillerLen]
    header_text = [
        ('title', txtTitle),
        txtFiller,
        ('key', "Q"),
        " exits",
    ]

    #logging.debug(header_text)
    return header_text
Example #4
0
def printCompStats(computer_list):
    red_bg = urwid.AttrSpec('default', 'dark red')
    green_bg = urwid.AttrSpec('default', 'dark green')
    yellow_bg = urwid.AttrSpec('black', 'yellow')

    screen_cols = monitor_func.get_screen_cols()
    colLenFactor = screen_cols / 10
    colLen_ComputerName = colLenFactor * 3  #15
    colLen_LastOnlineDateTime = colLenFactor * 4  #20
    colLen_CPUUtilization = colLenFactor * 1  #5
    colLen_DiskUtilization = colLenFactor * 2  #5

    dateTimeNow = datetime.now()
    col1Str = 'Computer name'.ljust(colLen_ComputerName)[:colLen_ComputerName]
    col2Str = 'Last online'.ljust(
        colLen_LastOnlineDateTime)[:colLen_LastOnlineDateTime]
    col3Str = 'CPU'.ljust(colLen_CPUUtilization)[:colLen_CPUUtilization]
    col4Str = 'Disk'.ljust(colLen_DiskUtilization)[:colLen_DiskUtilization]
    outList = [col1Str, col2Str, col3Str, col4Str + '\n']

    for computer in computer_list:
        lastOnlineDateTime = computer.LastOnlineDateTime + timedelta(
            seconds=computer.UpdateIntervalSec)
        lastOnlineDateTimeLong = computer.LastOnlineDateTime + timedelta(
            seconds=computer.UpdateIntervalSec * 2)

        col1Str = computer.ComputerName.ljust(
            colLen_ComputerName)[:colLen_ComputerName]
        col2Str = str(computer.LastOnlineDateTime).ljust(
            colLen_LastOnlineDateTime)[:colLen_LastOnlineDateTime]
        col3Str = str(computer.CPUUtilization).ljust(
            colLen_CPUUtilization)[:colLen_CPUUtilization]
        col4Str = str(computer.DiskUtilization).ljust(
            colLen_DiskUtilization)[:colLen_DiskUtilization] + '\n'

        # Set Colors on ComputerName && LastOnlineDateTime
        if (dateTimeNow > lastOnlineDateTimeLong):
            col1 = (red_bg, col1Str)
            col2 = (red_bg, col2Str)
        elif (dateTimeNow > lastOnlineDateTime):
            col1 = (yellow_bg, col1Str)
            col2 = (yellow_bg, col2Str)
        else:
            col1 = (green_bg, col1Str)
            col2 = (green_bg, col2Str)

        # Set Colors on CPUUtilization
        if (computer.CPUUtilization >= 90):
            col3 = (red_bg, col3Str)
        elif (computer.CPUUtilization >= 80):
            col3 = (yellow_bg, col3Str)
        else:
            col3 = (green_bg, col3Str)

        # Set Colors on DiskUtilization
        if (computer.DiskUtilization >= 90):
            col4 = (red_bg, col4Str)
        elif (computer.DiskUtilization >= 80):
            col4 = (yellow_bg, col4Str)
        else:
            col4 = (green_bg, col4Str)

        outList.append(col1)
        outList.append(col2)
        outList.append(col3)
        outList.append(col4)

    return outList