<commit_before>from django.core.management.base import BaseCommand, CommandError
from django.utils.timezone import utc
from sis_provisioner.models import Job
import datetime
import sys


class SISProvisionerCommand(BaseCommand):
    def __init__(self, *args, **kwargs):
        super(SISProvisionerCommand, self).__init__(*args, **kwargs)

        if not self.is_active_job(name=sys.argv[1]):
            sys.exit(0)

    def is_active_job(self, name):
        try:
            job = Job.objects.get(name=name)
        except Job.DoesNotExist:
            title = ' '.join(w.capitalize() for w in name.split('_'))
            job = Job(name=name, title=title, is_active=False)
            job.changed_date = datetime.datetime.utcnow().replace(tzinfo=utc)
            job.save()

        return True if job.is_active else False

    def update_job(self):
        job = Job.objects.get(name=sys.argv[1])
        job.last_run_date = datetime.datetime.utcnow().replace(tzinfo=utc)
        job.save()<commit_msg>adds args to job name<commit_after>from django.core.management.base import BaseCommand, CommandError
from django.utils.timezone import utc
from sis_provisioner.models import Job
import datetime
import sys


class SISProvisionerCommand(BaseCommand):
    def __init__(self, *args, **kwargs):
        super(SISProvisionerCommand, self).__init__(*args, **kwargs)

        if not self.is_active_job():
            sys.exit(0)

    def is_active_job(self):
        name = self.name_from_argv()
        try:
            job = Job.objects.get(name=name)
        except Job.DoesNotExist:
            job = Job(name=name,
                      title=self.title_from_name(name),
                      is_active=False)
            job.changed_date = datetime.datetime.utcnow().replace(tzinfo=utc)
            job.save()

        return True if job.is_active else False

    def update_job(self):
        job = Job.objects.get(name=sys.argv[1])
        job.last_run_date = datetime.datetime.utcnow().replace(tzinfo=utc)
        job.save()

    def name_from_argv(self):
        name = sys.argv[1]
        args = sys.argv[2:]
        if len(args):
            name += ':' + ':'.join(args).replace('--', '')
        return name

    def title_from_name(self, name):
        parts = name.split(':')
        title = ' '.join(w.capitalize() for w in parts[0].split('_'))
        args = parts[1:]
        if len(args):
            title += ' (' + ', '.join(args) + ')'
        return title
{'fraction_non_alphanumeric': 0.12394025030278563, 'fraction_numerical': 0.0036334275333064193, 'mean_word_length': 2.4901408450704223, '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': '6030624', 'n_tokens_mistral': 784, 'n_tokens_neox': 761, 'n_words': 157}