<commit_before># python -m smtpd -n -c DebuggingServer localhost:1025

from sys import stdout
from socket import error as socket_error
from time import sleep, gmtime, strftime
from xml.parsers.expat import ExpatError
from xmlrpclib import ProtocolError

from django.conf import settings
from django.core.management.base import NoArgsCommand
from django.core.mail import send_mail

from package.models import Package

DEBUG = True


class Command(NoArgsCommand):

    help = "Updates all the packages in the system. Commands belongs to django-packages.package"

    def handle(self, *args, **options):

        text = "Commencing package updating now at %s " % strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())

        for index, package in enumerate(Package.objects.all()):
            try:
                try:
                    package.fetch_metadata()
                    package.fetch_commits()
                except socket_error, e:
                    text += "\nFor '%s', threw a socket_error: %s" % (package.title, e)
                    continue
                except ValueError, e:
                    text += "\nFor '%s', threw a ValueError: %s" % (package.title, e)
                    continue
                
            except RuntimeError, e:
                text += "\nFor '%s', too many requests issued to repo threw a RuntimeError: %s" % (package.title, e)
                continue
            except UnicodeDecodeError, e:
                text += "\nFor '%s', UnicodeDecodeError: %s" % (package.title, e)
                continue
            except ProtocolError, e:
                text += "\nFor '%s', xmlrpc.ProtocolError: %s" % (package.title, e)
                continue
            except ExpatError, e:
                text += "\nFor '%s', ExpatError: %s" % (package.title, e)
                continue
            except Exception, e:
                text += "\nFor '%s', General Exception: %s" % (package.title, e)
                continue

            if not hasattr(settings, "GITHUB_API_SECRET"):
                sleep(5)
            text += "\n%s. Successfully updated package '%s'" % (index + 1, package.title)
            
            if DEBUG:
                print(text.splitlines()[index])

        #print >> stdout, "-" * 40
        text += "\n"
        text += "-" * 40
        #print >> stdout, "Finished at %s" % strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
        text += "\nFinished at %s" % strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())

        send_mail(
            subject="Package Updating complete",
            message=text,
            from_email=settings.DEFAULT_FROM_EMAIL,
            recipient_list=["<EMAIL>", "<EMAIL>", ],
        )<commit_msg>Test fix<commit_after># python -m smtpd -n -c DebuggingServer localhost:1025

from sys import stdout
from socket import error as socket_error
from time import sleep, gmtime, strftime
from xml.parsers.expat import ExpatError
from xmlrpclib import ProtocolError

from django.conf import settings
from django.core.management.base import NoArgsCommand
from django.core.mail import send_mail

from package.models import Package

DEBUG = True


class Command(NoArgsCommand):

    help = "Updates all the packages in the system. Commands belongs to django-packages.package"

    def handle(self, *args, **options):

        text = "Commencing package updating now at %s " % strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
        
        for index, package in enumerate(Package.objects.all()):
            if index < 1154:
                continue
            
            try:
                try:
                    package.fetch_metadata()
                    package.fetch_commits()
                except socket_error, e:
                    text += "\nFor '%s', threw a socket_error: %s" % (package.title, e)
                    continue
                except ValueError, e:
                    text += "\nFor '%s', threw a ValueError: %s" % (package.title, e)
                    continue
                
            except RuntimeError, e:
                text += "\nFor '%s', too many requests issued to repo threw a RuntimeError: %s" % (package.title, e)
                continue
            except UnicodeDecodeError, e:
                text += "\nFor '%s', UnicodeDecodeError: %s" % (package.title, e)
                continue
            except ProtocolError, e:
                text += "\nFor '%s', xmlrpc.ProtocolError: %s" % (package.title, e)
                continue
            except ExpatError, e:
                text += "\nFor '%s', ExpatError: %s" % (package.title, e)
                continue
            except Exception, e:
                text += "\nFor '%s', General Exception: %s" % (package.title, e)
                continue

            if not hasattr(settings, "GITHUB_API_SECRET"):
                sleep(5)
            text += "\n%s. Successfully updated package '%s'" % (index + 1, package.title)
            
            if DEBUG:
                try:
                    print(text.splitlines()[index])
                except UnicodeDecodeError, e:
                    print('Stupid unicode error on {0}'.format(index))

        #print >> stdout, "-" * 40
        text += "\n"
        text += "-" * 40
        #print >> stdout, "Finished at %s" % strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
        text += "\nFinished at %s" % strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())

        send_mail(
            subject="Package Updating complete",
            message=text,
            from_email=settings.DEFAULT_FROM_EMAIL,
            recipient_list=["<EMAIL>", "<EMAIL>", ],
        )
{'fraction_non_alphanumeric': 0.1193342776203966, 'fraction_numerical': 0.008675637393767706, 'mean_word_length': 1.7882527147087859, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '666720', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1535, 'n_words': 486}