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 get_log_entries(log_files): combined_log = [] total_lines, line_limit = 0, 100 for file in log_files: if (file.endswith('temp')): continue log_entries = tail_file(file, line_count=100) for line in log_entries: total_lines += 1 if total_lines >= line_limit: break epoch, log_message = line.split('|') date_time = System.calculate_time_offset(int(epoch)) date_time = System.format_log_time(date_time) combined_log.append((date_time, log_message)) return combined_log
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
def get_log_entries(log_files): combined_log = [] total_lines, line_limit = 0, 100 for file in log_files: if (file.endswith('temp')): continue log_entries = tail_file(file, line_count=100) for line in log_entries: # skipping over empty lines. if not line.strip('\n'): continue total_lines += 1 if total_lines >= line_limit: break epoch, *log_entry = line.split('|', 3) date_time = System.calculate_time_offset(int(epoch)) date_time = System.format_log_time(date_time) combined_log.append((date_time, *log_entry)) return combined_log