<commit_before>#!/usr/bin/python

"""A script to get information from MrTijn's new server so I (MrMadsenMalmo) can display it
on a website
"""

__author__ = "MrMadsenMalmo - <NAME> & Tijndagamer"

import os
import time
import re
import datetime

def main():
    dataList = []

    dataList.append(os.popen("uptime").read() + "\n")
    dataList.append(os.popen("cpuload").read())
    dataList.append("CPU temp: \n" + os.popen("getcputemp").read())
    dataList.append("Network stats:\n" + os.popen("getdown").read())
    dataList.append(os.popen("getup").read() + "\n")
    dataList.append("Memory stats:\n" + os.popen("free -h").read() + "\n")
    dataList.append("Drive stats:  TOTAL | USED | FREE\n" + os.popen("df -h | grep '/dev/' && df -h --total | grep 'total'").read())

    data = str(dataList)
    data = data.replace('[', '')
    data = data.replace(']', '')
    data = data.replace(',', '')

    # os.popen("echo " + data + " > /var/www/html/status")
    # for data in dataList:
    #     print data
    
    with open("/var/www/html/status.txt", "w") as file:
        for data in dataList:
            file.write(data)
            
    write()


def get_time():
    return re.search("\d\d\:\d\d\:\d\d", os.popen("uptime").read()) + "\n"

def get_load():
    return re.search("CPU\sload\:\s([\d\.]+\%)", os.popen("cpuload").read(), re.VERBOSE).group(1) + "\n"

def get_temp():
    return re.search("[\w]+\:\s([\d\.]+)", os.popen("getcputemp").read(), re.VERBOSE).group(1) + "C\n"
    
def write(time=""):
    for type in [["temp", get_temp], ["load", get_load]]:
        with open(type[0] + time + ".txt") as file:
            file.write(get_time + type[1]())

prev_time = get_time()
prev_day = datetime.datetime.today().day

while True:
    # minute change
    if get_time[3:5] != prev_time[3:5]:
        write("min")

    # hour change
	if get_time[0:2] != prev_time[0:2]:
	    write("hr")

    # day change
    if datetime.datetime.today().day != prev_day:
        write("day")

    main()

    prev_time = get_time()
    prev_day = datetime.datetime.today().day

    time.sleep(5)
<commit_msg>add group to re for time<commit_after>#!/usr/bin/python

"""A script to get information from MrTijn's new server so I (MrMadsenMalmo) can display it
on a website
"""

__author__ = "MrMadsenMalmo - <NAME> & Tijndagamer"

import os
import time
import re
import datetime

def main():
    dataList = []

    dataList.append(os.popen("uptime").read() + "\n")
    dataList.append(os.popen("cpuload").read())
    dataList.append("CPU temp: \n" + os.popen("getcputemp").read())
    dataList.append("Network stats:\n" + os.popen("getdown").read())
    dataList.append(os.popen("getup").read() + "\n")
    dataList.append("Memory stats:\n" + os.popen("free -h").read() + "\n")
    dataList.append("Drive stats:  TOTAL | USED | FREE\n" + os.popen("df -h | grep '/dev/' && df -h --total | grep 'total'").read())

    data = str(dataList)
    data = data.replace('[', '')
    data = data.replace(']', '')
    data = data.replace(',', '')

    # os.popen("echo " + data + " > /var/www/html/status")
    # for data in dataList:
    #     print data
    
    with open("/var/www/html/status.txt", "w") as file:
        for data in dataList:
            file.write(data)
            
    write()


def get_time():
    return re.search("\d\d\:\d\d\:\d\d", os.popen("uptime").read(), re.VERBOSE).group(0) + "\n"

def get_load():
    return re.search("CPU\sload\:\s([\d\.]+\%)", os.popen("cpuload").read(), re.VERBOSE).group(1) + "\n"

def get_temp():
    return re.search("[\w]+\:\s([\d\.]+)", os.popen("getcputemp").read(), re.VERBOSE).group(1) + "C\n"
    
def write(time=""):
    for type in [["temp", get_temp], ["load", get_load]]:
        with open(type[0] + time + ".txt") as file:
            file.write(get_time + type[1]())

prev_time = get_time()
prev_day = datetime.datetime.today().day

while True:
    # minute change
    if get_time[3:5] != prev_time[3:5]:
        write("min")

    # hour change
	if get_time[0:2] != prev_time[0:2]:
	    write("hr")

    # day change
    if datetime.datetime.today().day != prev_day:
        write("day")

    main()

    prev_time = get_time()
    prev_day = datetime.datetime.today().day

    time.sleep(5)

{'fraction_non_alphanumeric': 0.208804143126177, 'fraction_numerical': 0.006355932203389831, 'mean_word_length': 2.908923643054278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5131918', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1563, 'n_words': 326}