def load_page(): logging_settings = load_configuration('logging_client')['logging'] logging = logging_settings['logging'] log_level = logging['level'] log_length = logging['length'] log_settings = {'level': log_level, 'length': log_length} time_offset = logging_settings['time_offset'] offset_values = { 'direction': time_offset['direction'], 'amount': time_offset['amount'] } 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, 'logging': log_settings, 'offset': offset_values } return logging_settings
def load_page(): logging_settings = load_configuration('logging_client')['logging'] 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
def load_page(): 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
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]
def load_page(): blacklist = load_configuration('blacklist')['blacklist'] exceptions = blacklist['exception'] domain_blacklist = blacklist['domain'] for domain, info in domain_blacklist.items(): st_offset = System.calculate_time_offset(info['time']) domain_blacklist[domain]['time'] = System.format_date_time(st_offset) blacklist_settings = { 'domain_blacklist': domain_blacklist, 'exceptions': exceptions } return blacklist_settings
def load_page(): whitelist = load_configuration('whitelist.json')['whitelist'] exceptions = whitelist['exception'] domain_whitelist = whitelist['domain'] ip_whitelist = whitelist['ip_whitelist'] for domain, info in domain_whitelist.items(): st_offset = System.calculate_time_offset(info['time']) domain_whitelist[domain]['time'] = System.format_date_time(st_offset) whitelist_settings = { 'domain_whitelist': domain_whitelist, 'exceptions': exceptions, 'ip_whitelist': ip_whitelist } return whitelist_settings