コード例 #1
0
    def _process_schedulers(self):
        self.stdout.write(log_prefix() + 'Starting scheduler process')

        today = date.today()

        self.stdout.write(
            'Using date {} as reference to get schedulers'.format(today))

        items = Scheduler.objects.pending(today)

        count = len(items)

        self.stdout.write(log_prefix() +
                          'Found {} schedulers to process'.format(count))

        for i, scheduler in enumerate(items, start=1):
            self.stdout.write('Processing scheduler #{} - {} of {}'.format(
                scheduler.id, i, count))

            try:
                scheduler.process(reference_date=today)
                self.stdout.write(
                    log_prefix() +
                    'Scheduler #{} processed'.format(scheduler.id))
            except Exception as e:
                self.stderr.write(log_prefix() +
                                  'Error processing scheduler #{}: {}'.format(
                                      scheduler.id, str(e)))
コード例 #2
0
    def _process_reports(self, ids):
        items = Report.objects.filter(status=Report.STATUS_PENDING)

        if ids:
            items = items.filter(id__in=ids)
        else:
            items = items[:10]

        count = len(items)

        self.stdout.write(log_prefix() +
                          'Found {} reports to process'.format(count))
        for i, report in enumerate(items, start=1):
            self.stdout.write(
                log_prefix() +
                'Processing report #{} - {} of {}'.format(report.id, i, count))

            try:
                report.process()
                report.save()
                self.stdout.write(log_prefix() +
                                  'Report #{} processed'.format(report.id))
            except Exception as e:
                traceback.print_exc()
                self.stderr.write(log_prefix() +
                                  'Error processing report #{}: {}'.format(
                                      report.id, str(e)))
コード例 #3
0
    def _process_schedulers(self):
        self.stdout.write(log_prefix() + 'Starting scheduler process')

        today = date.today()

        self.stdout.write('Using date {} as reference to get schedulers'.format(today))

        items = Scheduler.objects.pending(today)

        count = len(items)

        self.stdout.write(log_prefix() + 'Found {} schedulers to process'.format(count))

        for i, scheduler in enumerate(items, start=1):
            self.stdout.write('Processing scheduler #{} - {} of {}'.format(
                scheduler.id, i, count))

            try:
                scheduler.process(reference_date=today)
                self.stdout.write(log_prefix() + 'Scheduler #{} processed'.format(scheduler.id))
            except Exception as e:
                self.stderr.write(log_prefix() + 'Error processing scheduler #{}: {}'.format(
                    scheduler.id, str(e)))
コード例 #4
0
    def _process_reports(self, ids):
        items = Report.objects.filter(status=Report.STATUS_PENDING)

        if ids:
            items = items.filter(id__in=ids)
        else:
            items = items[:10]

        count = len(items)

        self.stdout.write(log_prefix() + 'Found {} reports to process'.format(count))
        for i, report in enumerate(items, start=1):
            self.stdout.write(log_prefix() + 'Processing report #{} - {} of {}'.format(
                report.id, i, count))

            try:
                report.process()
                report.save()
                self.stdout.write(log_prefix() + 'Report #{} processed'.format(report.id))
            except Exception as e:
                traceback.print_exc()
                self.stderr.write(log_prefix() + 'Error processing report #{}: {}'.format(
                    report.id, str(e)))