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

from __future__ import print_function
import os
import signal
import sys
from main import app, queues, sched


def _teardown(signal, frame):
    sched.shutdown(wait=False)
    for queue in queues.values():
        queue.put(None)
    queues.clear()
    # Let the interrupt bubble up so that Flask/Werkzeug see it
    raise KeyboardInterrupt


def _run_job(name=None):
    import json
    import sys
    from flask import Flask
    from jobs import load_jobs
    from pprint import pprint

    app = Flask(__name__)
    app.config.from_envvar('JARVIS_SETTINGS')
    conf = app.config['JOBS']

    jobs = load_jobs()
    if name is None:
        names = ' '.join(jobs.keys())
        name = raw_input('Name of the job to run [%s]: ' % (names,)).lower()

    print_json = name.endswith('.json')
    if print_json:
        name = name.rstrip('.json')

    cls = jobs.get(name)
    if cls is None:
        print('No such job: %s' % (name,))
        sys.exit(1)<commit_msg>Fix extension stripping when running a job<commit_after>#!/usr/bin/env python

from __future__ import print_function

import os
import signal
import sys

from main import app, queues, sched


def _teardown(signal, frame):
    sched.shutdown(wait=False)
    for queue in queues.values():
        queue.put(None)
    queues.clear()
    # Let the interrupt bubble up so that Flask/Werkzeug see it
    raise KeyboardInterrupt


def _run_job(name=None):
    import json
    import sys
    from flask import Flask
    from jobs import load_jobs
    from pprint import pprint

    app = Flask(__name__)
    app.config.from_envvar('JARVIS_SETTINGS')
    conf = app.config['JOBS']

    jobs = load_jobs()
    if name is None:
        names = ' '.join(jobs.keys())
        name = raw_input('Name of the job to run [%s]: ' % (names,)).lower()

    print_json = name.endswith('.json')
    if print_json:
        name = name.rpartition('.json')[0]

    cls = jobs.get(name)
    if cls is None:
        print('No such job: %s' % (name,))
        sys.exit(1)
{'fraction_non_alphanumeric': 0.109375, 'fraction_numerical': 0.00146484375, 'mean_word_length': 2.829906542056075, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7262882', 'n_tokens_mistral': 687, 'n_tokens_neox': 664, 'n_words': 201}