<commit_before>#!/usr/bin/env python

import logging
import os
import os.path
import time

import tornado.httpserver
import tornado.web
import tornado.template
import tornado.escape

execfile('libinjection_test.py')

class HookShotHandler(tornado.web.RequestHandler):
    """
    something to handle github hookshots
    right now I'm just hardwiring it
    """
    def get(self):
        DYNAMO.put('libinjection')
    def post(self):
        DYNAMO.put('libinjection')

class KickHandler(tornado.web.RequestHandler):
    """
    hack to do everything
    """
    def get(self):
        DYNAMO.put('libinjection')

class CicadaStatusHandler(tornado.web.RequestHandler):
    def get(self):
        projects = {}
        for rs in DYNAMO.projectjobs_list_all():
            try:
                projectname = str(rs['project'])
                jobname = str(rs['job'])
                artifacts = []
                publishers = PROJECTS[projectname][jobname].get('publish', [])
                for p in publishers:
                    href, text = p.link()
                    href = "artifacts/{0}/{1}/{2}/{3}".format(projectname, jobname, rs['started'], href)
                    artifacts.append( (href, text) )
                job = {
                    'project': projectname,
                    'job': jobname,
                    'start': int(rs['started']),
                    'duration': int(rs['updated'] - rs['started']),
                    'state': str(rs['state']),
                    'artifacts': artifacts
                }


                if rs['project'] in projects:
                    projects[rs['project']].append(job)
                else:
                    projects[rs['project']] = [ job ]
            except Exception, e:
                logging.error("Problem in rendering: {0} {1}".format(e, rs))


        self.render(
            'status.html',<commit_msg>human time<commit_after>#!/usr/bin/env python

import logging
import os
import os.path
import time

import tornado.httpserver
import tornado.web
import tornado.template
import tornado.escape

execfile('libinjection_test.py')

def epoch_to_ago(ago, now=0):
    if now == 0:
        now = int(time.time())
    diff = now-ago
    if (diff > 0):
        return "future"
    if (diff < 2):
        return "now"
    if (diff < 60):
        return "{1}sec".format(diff)
    if (diff < 60*60*3):
        return "{1}min".format(int(diff / 60.0))
    if (diff < 86400):
        return "{1}hr".format(int(diff / 3600.0))
    return "{1}day".format(int(diff / 86400.0))

class HookShotHandler(tornado.web.RequestHandler):
    """
    something to handle github hookshots
    right now I'm just hardwiring it
    """
    def get(self):
        DYNAMO.put('libinjection')
    def post(self):
        DYNAMO.put('libinjection')

class KickHandler(tornado.web.RequestHandler):
    """
    hack to do everything
    """
    def get(self):
        DYNAMO.put('libinjection')

class CicadaStatusHandler(tornado.web.RequestHandler):
    def get(self):
        projects = {}
        for rs in DYNAMO.projectjobs_list_all():
            try:
                projectname = str(rs['project'])
                jobname = str(rs['job'])
                artifacts = []
                publishers = PROJECTS[projectname][jobname].get('publish', [])
                for p in publishers:
                    href, text = p.link()
                    href = "artifacts/{0}/{1}/{2}/{3}".format(projectname, jobname, rs['started'], href)
                    artifacts.append( (href, text) )
                job = {
                    'project': projectname,
                    'job': jobname,
                    'start': int(rs['started']),
                    'ago': epoch_to_ago(int(rs['started'])),
                    'duration': int(rs['updated'] - rs['started']),
                    'state': str(rs['state']),
                    'artifacts': artifacts
                }


                if rs['project'] in projects:
                    projects[rs['project']].append(job)
                else:
                    projects[rs['project']] = [ job ]
            except Exception, e:
                logging.error("Problem in rendering: {0} {1}".format(e, rs))


        self.render(
            'status.html',
{'fraction_non_alphanumeric': 0.13548236393366037, 'fraction_numerical': 0.010745153001635132, 'mean_word_length': 1.7877604166666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '6091595', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1205, 'n_words': 266}