<commit_before># -*- coding: utf-8 -*-
import sys
import logging

from website.app import setup_django
setup_django()
from website import mails
from osf.models import OSFUser
from addons.mendeley.models import UserSettings
import progressbar

from scripts import utils as script_utils

logger = logging.getLogger(__name__)


def main(dry=True):
    user = OSFUser.load('qrgl2')
    qs = UserSettings.objects.filter(owner__is_active=True).select_related('owner')
    pbar = progressbar.ProgressBar(maxval=qs.count()).start()
    for i, each in enumerate(qs):
        user = each.owner
        logger.info('Sending email to OSFUser {}'.format(user._id))
        if not dry:
            mails.send_mail(
                mail=mails.MENDELEY_REAUTH,
                to_addr=user.username,
                can_change_preferences=False,
                user=user
            )
        pbar.update(i + 1)

if __name__ == '__main__':
    dry = '--dry' in sys.argv
    if not dry:
        script_utils.add_file_logger(logger, __file__)
    main(dry=dry)<commit_msg>Remove junk and add more logging<commit_after># -*- coding: utf-8 -*-
import sys
import logging

from website.app import setup_django
setup_django()
from website import mails
from osf.models import OSFUser
from addons.mendeley.models import UserSettings
import progressbar

from scripts import utils as script_utils

logger = logging.getLogger(__name__)


def main(dry=True):
    qs = UserSettings.objects.filter(owner__is_active=True).select_related('owner').order_by('pk')
    count = qs.count()
    pbar = progressbar.ProgressBar(maxval=count).start()
    logger.info('Sending email to {} users'.format(count))
    for i, each in enumerate(qs):
        user = each.owner
        logger.info('Sending email to OSFUser {}'.format(user._id))
        if not dry:
            mails.send_mail(
                mail=mails.MENDELEY_REAUTH,
                to_addr=user.username,
                can_change_preferences=False,
                user=user
            )
        pbar.update(i + 1)
    logger.info('Sent email to {} users'.format(count))

if __name__ == '__main__':
    dry = '--dry' in sys.argv
    if not dry:
        script_utils.add_file_logger(logger, __file__)
    main(dry=dry)
{'fraction_non_alphanumeric': 0.10427807486631016, 'fraction_numerical': 0.0022281639928698753, 'mean_word_length': 2.844178082191781, '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': '5146576', 'n_tokens_mistral': 713, 'n_tokens_neox': 678, 'n_words': 166}