Пример #1
0
def load_page(form):
    logging_settings = load_configuration('logging_client')

    log = logging_settings['logging']

    # correcting time for configured offset.
    time_offset = logging_settings['time_offset']
    system_time = System.format_date_time(fast_time())
    local_time = System.calculate_time_offset(fast_time())
    local_time = System.format_date_time(local_time)

    logging_settings = {
        'system': system_time,
        'local': local_time,
        'offset': {
            'direction': time_offset['direction'],
            'amount': time_offset['amount']
        },
        'logging': {
            'log_levels': [level.title() for level in LOG_LEVELS],
            'level': log['level'],
            'length': log['length']
        }
    }

    return logging_settings
Пример #2
0
def load_page(form):
    backups_info, current_backups = {}, System.backups()

    for backup, c_time in current_backups.items():
        c_time = System.calculate_time_offset(c_time)
        c_time = System.format_date_time(c_time).split(maxsplit=1)

        backups_info[backup] = (c_time[0], c_time[1])

    return backups_info
Пример #3
0
def format_row(row, users):
    '''formats database data to be better displayed and managed by front end. will replace
    all '_' with ' '. If user is passed in, it will be appended before last_seen.'''
    Sys = System()

    *entries, last_seen = row

    ls_offset = Sys.calculate_time_offset(last_seen)
    last_seen = Sys.format_date_time(ls_offset)
    if (users is not None):
        entries.append(users.get(entries[0], {}).get('name', 'n/a'))

    entries.append(last_seen)
    return [str(x).lower().replace('_', ' ') for x in entries]
Пример #4
0
def load_page(form):
    whitelist = load_configuration('whitelist')

    for info in whitelist['time_based'].values():
        st_offset = System.calculate_time_offset(info['time'])

        info['time'] = System.format_date_time(st_offset)

    whitelist_settings = {
        'time_based': whitelist['time_based'],
        'pre_proxy': whitelist['pre_proxy'],
        'ip_bypass': whitelist['ip_bypass']
    }

    return whitelist_settings
Пример #5
0
def load_page(form):
    dhcp_server = load_configuration('dhcp_server')

    dhcp_settings = dhcp_server['interfaces']

    leases = []
    for ip, (status, handout_time, mac, hostname) in dhcp_server['leases'].items():
        # ensuring only leased status entries get included
        if (status != -4): continue

        offset_time = System.calculate_time_offset(handout_time)
        handout_time = System.format_date_time(offset_time)

        leases.append((ip, handout_time, mac_str(mac), hostname))

    leases.sort()

    dhcp_settings.update({
        'reservations': [(mac_str(mac), info) for mac, info in dhcp_server['reservations'].items()],
        'leases': leases
    })

    return dhcp_settings