<commit_before><%!
    from datetime import datetime
    import os
    import re
    from shlex import split
    from subprocess import check_output, CalledProcessError, STDOUT

    os.environ["SGE_ROOT"] = "/sge62"

    def format_date(d):
        start = datetime.strptime(d, "%a %b %d %H:%M:%S %Y")
        since = start.strftime("%b %d, %Y at %H:%M:%S UTC")
        diff = (datetime.utcnow() - start)
        if diff.days:
            uptime = "{0} days".format(diff.days)
            if diff.seconds >= 3600:
                uptime += ", {0} hours".format(diff.seconds / 3600)
        else:
            if diff.seconds > 3600:
                uptime = "{0} hours".format(diff.seconds / 3600)
            elif diff.seconds > 60:
                uptime = "{0} minutes".format(diff.seconds / 60)
            else:
                uptime = "{0} seconds".format(diff.seconds)
        return (since, uptime)

    def collect_status_info():
        try:
            result = check_output(["qstat", "-j", "earwigbot"], stderr=STDOUT)
        except CalledProcessError as e:
            return ["offline"]

        if result.startswith("Following jobs do not exist:"):
            return ["offline"]

        lines = result.splitlines()[1:]
        re_key = "^(.*?):\s"
        re_val = ":\s*(.*?)$"
        data = dict((re.search(re_key, line).group(1), re.search(re_val, line).group(1)) for line in lines)
        since, uptime = format_date(data["submission_time"])
        host = data["sge_o_host"]
        return ["online", since, uptime, host]
%>\
<%def name="get_status()" filter="trim">
    <% status, since, uptime, host = collect_status_info() %>
    <span class="${status}">${status}</span>
    % if status == "online":
        since ${since} (${uptime} uptime) on <tt>${host}</tt>
    % endif
</%def>\
<%include file="/support/header.mako" args="environ=environ, title='EarwigBot Status'"/>
            <h1>EarwigBot Status</h1>
            <p>EarwigBot is ${get_status()}.</p>
            <p>Additional information: <a href="http://status.toolserver.org/">status.toolserver.org</a></p>
<%include file="/support/footer.mako" args="environ=environ"/><commit_msg>Grammar<commit_after><%!
    from datetime import datetime
    import os
    import re
    from shlex import split
    from subprocess import check_output, CalledProcessError, STDOUT

    os.environ["SGE_ROOT"] = "/sge62"

    def format_date(d):
        start = datetime.strptime(d, "%a %b %d %H:%M:%S %Y")
        since = start.strftime("%b %d, %Y at %H:%M:%S UTC")
        diff = (datetime.utcnow() - start)
        if diff.days:
            uptime = "{0} days".format(diff.days)
            if diff.seconds >= 3600:
                uptime += ", {0} hours".format(diff.seconds / 3600)
        else:
            if diff.seconds > 3600:
                uptime = "{0} hours".format(diff.seconds / 3600)
            elif diff.seconds > 60:
                uptime = "{0} minutes".format(diff.seconds / 60)
            else:
                uptime = "{0} seconds".format(diff.seconds)
        return (since, uptime)

    def collect_status_info():
        try:
            result = check_output(["qstat", "-j", "earwigbot"], stderr=STDOUT)
        except CalledProcessError as e:
            return ["offline"]

        if result.startswith("Following jobs do not exist:"):
            return ["offline"]

        lines = result.splitlines()[1:]
        re_key = "^(.*?):\s"
        re_val = ":\s*(.*?)$"
        data = dict((re.search(re_key, line).group(1), re.search(re_val, line).group(1)) for line in lines)
        since, uptime = format_date(data["submission_time"])
        host = data["sge_o_host"]
        return ["online", since, uptime, host]
%>\
<%def name="get_status()" filter="trim">
    <% status, since, uptime, host = collect_status_info() %>
    ${"has been" if status == "online" else "is"} <span class="${status}">${status}</span>
    % if status == "online":
        since ${since} (${uptime} uptime) on <tt>${host}</tt>
    % endif
</%def>\
<%include file="/support/header.mako" args="environ=environ, title='EarwigBot Status'"/>
            <h1>EarwigBot Status</h1>
            <p>EarwigBot ${get_status()}.</p>
            <p>Additional information: <a href="http://status.toolserver.org/">status.toolserver.org</a></p>
<%include file="/support/footer.mako" args="environ=environ"/>
{'fraction_non_alphanumeric': 0.1702857142857143, 'fraction_numerical': 0.014628571428571428, 'mean_word_length': 2.434850863422292, 'pattern_counts': {'":': 4, '<': 39, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7279537', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1390, 'n_words': 323}