<commit_before>from django.core.management.base import BaseCommand
from django.conf import settings

from cyder.cydns.cybind.builder import DNSBuilder, BuildError

import subprocess
import dns_migrate
#import dhcp_migrate
from lib.diffdns import diff_zones
from lib.checkexcept import checkexcept


def build_dns():
    args = {'FIRST_RUN': False,
            'PRESERVE_STAGE': False,
            'PUSH_TO_PROD': False,
            'BUILD_ZONES': True,
            'LOG_SYSLOG': True,
            'CLOBBER_STAGE': True,
            'STAGE_ONLY': False,
            'DEBUG': False
            }
    b = DNSBuilder(**args)

    try:
        b
    except BuildError as why:
        b.log('LOG_ERR', why)
    except Exception as err:
        b.log('LOG_CRIT', err)
        raise


class Command(BaseCommand):

    def handle(self, **options):
        print "Migrating DNS objects."
        dns_migrate.do_everything(skip_edu=True)

        print "Building zone files."
        build_dns()
        p = subprocess.Popen(["rndc", "reload"], stdout=subprocess.PIPE)
        if "successful" in p.stdout.read():
            print "rndc reloaded successfully"
        else:
            print "Failed to reload rndc. Do you have permission?"
            exit(1)
        p.stdout.close()

        print "Comparing localhost to %s." % settings.VERIFICATION_SERVER
        diffs = diff_zones("localhost", settings.VERIFICATION_SERVER,
                           settings.ZONES_FILE, skip_edu=True)

        print "Removing excusable differences."
        checked, unexcused = checkexcept(diffs)

        print "%s differences. %s not excused." % (checked, len(unexcused))
        print
        for rdtype, name, A, B in unexcused:
            print rdtype, name
            print "localhost", A
            print settings.VERIFICATION_SERVER, B
            print

        #dhcp_migrate.migrate_all()<commit_msg>oops, forgot to build zone files<commit_after>from django.core.management.base import BaseCommand
from django.conf import settings

from cyder.cydns.cybind.builder import DNSBuilder, BuildError

import subprocess
import dns_migrate
#import dhcp_migrate
from lib.diffdns import diff_zones
from lib.checkexcept import checkexcept


def build_dns():
    args = {'FIRST_RUN': False,
            'PRESERVE_STAGE': False,
            'PUSH_TO_PROD': False,
            'BUILD_ZONES': True,
            'LOG_SYSLOG': True,
            'CLOBBER_STAGE': True,
            'STAGE_ONLY': False,
            'DEBUG': False
            }
    b = DNSBuilder(**args)

    try:
        b.build_dns()
    except BuildError as why:
        b.log('LOG_ERR', why)
    except Exception as err:
        b.log('LOG_CRIT', err)
        raise


class Command(BaseCommand):

    def handle(self, **options):
        '''
        print "Migrating DNS objects."
        dns_migrate.do_everything(skip_edu=False)
        '''

        print "Building zone files."
        build_dns()

        '''
        p = subprocess.Popen(["rndc", "reload"], stdout=subprocess.PIPE)
        if "successful" in p.stdout.read():
            print "rndc reloaded successfully"
        else:
            print "Failed to reload rndc. Do you have permission?"
            exit(1)
        p.stdout.close()

        print "Comparing localhost to %s." % settings.VERIFICATION_SERVER
        diffs = diff_zones("localhost", settings.VERIFICATION_SERVER,
                           settings.ZONES_FILE, skip_edu=False)

        print "Removing excusable differences."
        checked, unexcused = checkexcept(diffs)

        print "%s differences. %s not excused." % (checked, len(unexcused))
        print
        for rdtype, name, A, B in unexcused:
            print rdtype, name
            print "localhost", A
            print settings.VERIFICATION_SERVER, B
            print
        '''

        #dhcp_migrate.migrate_all()
{'fraction_non_alphanumeric': 0.09499225606608157, 'fraction_numerical': 0.0005162622612287042, 'mean_word_length': 2.1762295081967213, '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': '5901073', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1153, 'n_words': 298}