<commit_before>import datetime
import logging

from django.core.management.base import BaseCommand

from corehq.apps.hqcase.bulk import SystemFormMeta, update_cases
from corehq.apps.linked_domain.dbaccessors import get_linked_domains
from corehq.apps.users.util import SYSTEM_USER_ID, username_to_user_id, user_id_to_username
from corehq.form_processor.models import CommCareCase
from corehq.util.log import with_progress_bar


class CaseUpdateCommand(BaseCommand):
    """
        Base class for updating cases of a specific case_type.
        Override all methods that raise NotImplementedError.
    """

    def __init__(self):
        self.extra_options = {}

    def logger_name(self):
        """
        Typically __name__
        """
        raise NotImplementedError()

    def case_blocks(self, case):
        """
        Return a list of CaseBlock updates, or None if no updates are needed.
        """
        raise NotImplementedError()

    def find_case_ids(self, domain):
        return CommCareCase.objects.get_case_ids_in_domain(domain, self.case_type)

    def add_arguments(self, parser):
        parser.add_argument('domain')
        parser.add_argument('case_type')
        parser.add_argument('--username', type=str, default=None)
        parser.add_argument('--and-linked', action='store_true', default=False)
        parser.add_argument('--throttle-secs', type=float, default=0)

    def handle(self, domain, case_type, **options):
        # logger.debug will record something to a file but not print it
        self.logger = logging.getLogger(self.logger_name())
        self.logger.addHandler(logging.FileHandler(self.logger_name().split(".")[-1] + ".txt"))
        self.logger.setLevel(logging.DEBUG)
<commit_msg>Turned off logging in tests<commit_after>import datetime
import logging

from django.conf import settings
from django.core.management.base import BaseCommand

from corehq.apps.hqcase.bulk import SystemFormMeta, update_cases
from corehq.apps.linked_domain.dbaccessors import get_linked_domains
from corehq.apps.users.util import SYSTEM_USER_ID, username_to_user_id, user_id_to_username
from corehq.form_processor.models import CommCareCase
from corehq.util.log import with_progress_bar


class CaseUpdateCommand(BaseCommand):
    """
        Base class for updating cases of a specific case_type.
        Override all methods that raise NotImplementedError.
    """

    def __init__(self):
        self.extra_options = {}

    def logger_name(self):
        """
        Typically __name__
        """
        raise NotImplementedError()

    def case_blocks(self, case):
        """
        Return a list of CaseBlock updates, or None if no updates are needed.
        """
        raise NotImplementedError()

    def find_case_ids(self, domain):
        return CommCareCase.objects.get_case_ids_in_domain(domain, self.case_type)

    def add_arguments(self, parser):
        parser.add_argument('domain')
        parser.add_argument('case_type')
        parser.add_argument('--username', type=str, default=None)
        parser.add_argument('--and-linked', action='store_true', default=False)
        parser.add_argument('--throttle-secs', type=float, default=0)

    def handle(self, domain, case_type, **options):
        # logger.debug will record something to a file but not print it
        self.logger = logging.getLogger(self.logger_name())
        if not settings.UNIT_TESTING:
            self.logger.addHandler(logging.FileHandler(self.logger_name().split(".")[-1] + ".txt"))
        self.logger.setLevel(logging.DEBUG)

{'fraction_non_alphanumeric': 0.09717166059927192, 'fraction_numerical': 0.0011201344161299357, 'mean_word_length': 3.453865336658354, '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': '4256783', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1019, 'n_words': 243}