コード例 #1
0
    def handle(self, *args, **options):
        if options['date']:
            receipt_date = parse_date(options['date'])
            if not receipt_date:
                raise CommandError(
                    'Date %s cannot be parsed, use YYYY-MM-DD format' % date)
        else:
            workdays = WorkdayChecker()
            if not workdays.is_workday(date.today()):
                return
            receipt_date = workdays.get_previous_workday(date.today())

        api_session = api_client.get_authenticated_api_session(
            settings.BANK_ADMIN_USERNAME, settings.BANK_ADMIN_PASSWORD)
        self.__class__.function(api_session, receipt_date)
コード例 #2
0
    def handle(self, *args, **options):
        if settings.CLOUD_PLATFORM_MIGRATION_MODE:
            logger.warning(
                f'{self.__class__.__module__} management command will not run in migration mode'
            )
            return

        if options['date']:
            receipt_date = parse_date(options['date'])
            if not receipt_date:
                raise CommandError(
                    'Date %s cannot be parsed, use YYYY-MM-DD format' % date)
        else:
            workdays = WorkdayChecker()
            if not workdays.is_workday(date.today()):
                return
            receipt_date = workdays.get_previous_workday(date.today())

        api_session = api_client.get_authenticated_api_session(
            settings.BANK_ADMIN_USERNAME, settings.BANK_ADMIN_PASSWORD)
        self.__class__.function(api_session, receipt_date)
コード例 #3
0
    def handle(self, **options):
        if settings.CLOUD_PLATFORM_MIGRATION_MODE:
            logger.warning(
                f'{self.__class__.__module__} management command will not run in migration mode'
            )
            return

        date = options['date']
        scheduled = options['scheduled']

        if date and scheduled:
            raise CommandError(
                'Date cannot be provided if running as a scheduled command')

        elif scheduled:
            try:
                should_continue = is_first_instance()
            except StackException:
                should_continue = True
            if not should_continue:
                logger.warning(
                    'Not processing private estate emails as running on non-key instance '
                    '(command is not idempotent)')
                return
            today = timezone.now().date()
            workdays = WorkdayChecker()
            if not workdays.is_workday(today):
                logger.info(
                    'Non-workday: no private estate batches to process')
                return
            date = workdays.get_previous_workday(today)

        else:
            date = parse_date(date)
            if date is None:
                raise CommandError(
                    'Date cannot be parsed, use YYYY-MM-DD format')

        self.process_batches(date)
 def setUp(self):
     mock_bank_holidays()
     self.checker = WorkdayChecker()