<commit_before>from django.core.management.base import BaseCommand, CommandError
from crons.models import Entry, Cronjob
from time import sleep

def ping(entry):
    pass

class Command(BaseCommand):
    help = 'Run the worker that performs the pings to Travis'

    def handle(self, *args, **options):
        self.stdout.write('[*] Starting...\n')
        while True:
            jobs = Cronjob.objects.all()
            for job in jobs:
                if not job.need_run(): continue
                self.stdout.write('[+] Running ' + job.description + '...\n')
                for entry in job.entry_set.filter(approved=True).exclude(travis_token=''):
                    self.stdout.write('[+] Ping ' + entry.gh_project + '\n')
                    ping(entry)
                job.run_now()
                job.save()
            before_next = min(map(lambda job: job.before_next_run(), jobs))
            before_next = 0 if before_next < 0 else int(before_next + 1)
            self.stdout.write('[-] Sleeping ' + str(before_next) + ' seconds...\n')
            self.stdout.flush()
            sleep(before_next)<commit_msg>bridged the worker and travis_ping<commit_after>from django.core.management.base import BaseCommand, CommandError
from crons.models import Entry, Cronjob
from time import sleep
from travis_ping import travis_ping

def ping(entry):
    travis_token = entry.travis_token
    repository = entry.gh_project
    return travis_ping(travis_token, repository)

class Command(BaseCommand):
    help = 'Run the worker that performs the pings to Travis'

    def handle(self, *args, **options):
        self.stdout.write('[*] Starting...\n')
        while True:
            jobs = Cronjob.objects.all()
            for job in jobs:
                if not job.need_run(): continue
                self.stdout.write('[+] Running ' + job.description + '...\n')
                for entry in job.entry_set.filter(approved=True).exclude(travis_token=''):
                    self.stdout.write('[+] Ping ' + entry.gh_project + '\n')
                    ping(entry)
                job.run_now()
                job.save()
            before_next = min(map(lambda job: job.before_next_run(), jobs))
            before_next = 0 if before_next < 0 else int(before_next + 1)
            self.stdout.write('[-] Sleeping ' + str(before_next) + ' seconds...\n')
            self.stdout.flush()
            sleep(before_next)
{'fraction_non_alphanumeric': 0.12062577192260189, 'fraction_numerical': 0.002470152326060107, 'mean_word_length': 2.168187744458931, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1882807', 'n_tokens_mistral': 720, 'n_tokens_neox': 679, 'n_words': 175}