def handle(self, *args, **options):
        super(Command, self).handle(*args, **options)

        self.missing_raw_files = []
        self.empty_raw_files = []
        self.unknown_raw_files = []

        try:
            last_complete_download = self.command_logs.filter(
                command='downloadcalaccessrawdata',
                finish_datetime__isnull=False
            ).order_by('-finish_datetime')[0]
        except __HOLE__:
            self.failure("No complete downloads yet.")
            self.log("Try: python manage.py updatecalaccessrawdata")
            return
        else:
            self.raw_data_files = self.raw_data_files.filter(
                version=last_complete_download.version
            )

            downloaded_release_datetime = last_complete_download.version.release_datetime
            current_release_datetime = self.get_download_metadata()['last-modified']

            if current_release_datetime != downloaded_release_datetime:
                since_new_release = naturaltime(current_release_datetime)
                self.failure("A new version of CAL-ACCESS was "
                             "released {}.".format(since_new_release))
                self.log("Try: python manage.py updatecalaccessrawdata")

        self.log("Analyzing loaded models")

        if self.verbosity == 1:
            model_list = progress.bar(get_model_list())
        else:
            model_list = get_model_list()

        for model in model_list:

            call_command(
                'verifycalaccessrawfile',
                model.__name__,
                verbosity=self.verbosity
            )

        self.num_download_files = self.raw_data_files.count()

        self.num_clean_files = self.raw_data_files.filter(
            clean_records_count__gt=0
        ).count()

        self.num_loaded_files = self.raw_data_files.filter(
            load_records_count__gt=0
        ).count()

        total_raw_records = self.sum_count_column('download_records_count')

        total_clean_records = self.sum_count_column('clean_records_count')

        total_loaded_records = self.sum_count_column('load_records_count')

        self.log(
            '{0:.4%} of records cleaned'.format(
                calc_percent(total_clean_records, total_raw_records)
            )
        )

        self.log(
            '{0:.4%} of records loaded'.format(
                calc_percent(total_loaded_records, total_raw_records)
            )
        )

        self.write_csv_results()

        self.duration()
dataset/ETHPy150Open california-civic-data-coalition/django-calaccess-raw-data/calaccess_raw/management/commands/reportcalaccessrawdata.py/Command.handle