def handle(self, *args, **options): """ Main command handler. """ if options['job_list']: # print out the id's instead of processing anything columns = ['ID', 'Table', 'Created', 'Touched', 'Sts', 'Refs', 'Progress', 'Data file'] data = [] for j in Job.objects.all(): datafile = j.datafile() if not os.path.exists(datafile): datafile += " (missing)" data.append([j.id, j.table.name, j.created, j.touched, j.status, j.refcount, j.progress, datafile]) Formatter.print_table(data, columns) elif options['job_data']: job = Job.objects.get(id=options['job_data']) columns = [c.name for c in job.table.get_columns()] if job.status == job.COMPLETE: Formatter.print_table(job.values(), columns) elif options['job_age']: Job.age_jobs(force=True) elif options['job_flush']: Job.objects.all().delete()
def handle(self, *args, **options): """ Main command handler. """ if options['job_list']: # print out the id's instead of processing anything columns = ['ID', 'PID', 'Table', 'Created', 'Touched', 'Sts', 'Refs', 'Progress', 'Data file'] data = [] for j in Job.objects.all().order_by('id'): datafile = j.datafile() if not os.path.exists(datafile): datafile += " (missing)" parent_id = j.parent.id if j.parent else '--' data.append([j.id, parent_id, j.table.name, j.created, j.touched, j.status, j.refcount, j.progress, datafile]) Formatter.print_table(data, columns) elif options['job_data']: job = Job.objects.get(id=options['job_data']) columns = [c.name for c in job.table.get_columns()] if job.status == job.COMPLETE: Formatter.print_table(job.values(), columns) elif options['job_age']: logger.debug('Aging all jobs.') Job.age_jobs(force=True) elif options['job_flush']: logger.debug('Flushing all jobs.') while Job.objects.count(): ids = Job.objects.values_list('pk', flat=True)[:100] Job.objects.filter(pk__in=ids).delete()