Skip to content

# Producer

The tool to check the availability or syntax of domain, IP or URL.

::

    ██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
    ██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
    ██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
    ██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
    ██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
    ╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides our producer worker. This is the description of a single producer worker.

Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom

Special thanks: https://pyfunceble.github.io/#/special-thanks

Contributors: https://pyfunceble.github.io/#/contributors

Project link: https://github.com/funilrys/PyFunceble

Project documentation: https://docs.pyfunceble.com

Project homepage: https://pyfunceble.github.io/

License: ::

    Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        https://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

## `ProducerWorker`

Bases: `WorkerBase`

Provides our producer worker. The objective of this worker is to provides a single worker (or process if you prefer) which will be used to handle the production of output to stdout or files.

Source code in `PyFunceble/cli/processes/workers/producer.py`

     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450

    class ProducerWorker(WorkerBase):
        """
        Provides our producer worker. The objective of this worker is to provides
        a single worker (or process if you prefer) which will be used to handle
        the production of output to stdout or files.
        """

        stdout_printer: Optional[StdoutPrinter] = None
        file_printer: Optional[FilePrinter] = None
        whois_dataset: Optional[WhoisDatasetBase] = None
        inactive_dataset: Optional[InactiveDatasetBase] = None
        continue_dataset: Optional[ContinueDatasetBase] = None
        status_file_generator: Optional[StatusFileGenerator] = None
        counter: Optional[FilesystemCounter] = None
        registrar_counter: Optional[RegistrarCounter] = None
        platform_query_tool: Optional[PlatformQueryTool] = None

        header_already_printed: Optional[bool] = None

        INACTIVE_STATUSES: Tuple[str, ...] = (
            PyFunceble.storage.STATUS.down,
            PyFunceble.storage.STATUS.invalid,
        )

        def perform_external_poweron_checks(self) -> None:
            result = super().perform_external_poweron_checks()

            skip_columns = []
            extra_formatters = {}

            if not PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.registrar:
                skip_columns.append("registrar")

            if not PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.datetime:
                skip_columns.append("tested_at")
            else:
                # pylint: disable=line-too-long
                extra_formatters["tested_at"] = lambda x: x.strftime(
                    PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.datetime_format
                )

            self.stdout_printer = StdoutPrinter(
                skip_column=skip_columns, extra_formatters=extra_formatters
            )
            self.file_printer = FilePrinter(
                skip_column=skip_columns, extra_formatters=extra_formatters
            )
            self.whois_dataset = get_whois_dataset_object(db_session=self.db_session)
            self.inactive_dataset = get_inactive_dataset_object(db_session=self.db_session)
            self.continue_dataset = get_continue_dataset_object(db_session=self.db_session)
            self.status_file_generator = StatusFileGenerator().guess_all_settings()
            self.counter = FilesystemCounter()
            self.registrar_counter = RegistrarCounter()
            self.platform_query_tool = PlatformQueryTool()

            self.header_already_printed = False

            return result

        @staticmethod
        def should_we_ignore(test_result: CheckerStatusBase) -> bool:
            """
            Checks if we should ignore the given datasets.

            :param test_result:
                The test result to check.
            """

            return isinstance(test_result, str) and test_result.startswith("ignored_")

        @staticmethod
        def should_we_print_status_to_stdout(status: str) -> bool:
            """
            Checks if we are allows to print the given status (to stdout).

            :param status:
                The status to check.
            """

            if isinstance(
                PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.status, list
            ):
                to_keep = PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.status
            else:
                to_keep = [PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.status]

            to_keep = [x.upper() for x in to_keep]
            status = status.upper()

            return "ALL" in to_keep or status in to_keep

        def should_we_block_status_file_printer(
            self, test_dataset: dict, test_result: CheckerStatusBase
        ) -> bool:
            """
            Checks if we should block the file printer.

            The reason behind this is that we don't want to generate an output
            when a subject was already into the inactive database.
            """

            return (
                "from_inactive" in test_dataset
                and test_result.status in self.INACTIVE_STATUSES
            )

        def run_stdout_printer(self, test_result: CheckerStatusBase) -> None:
            """
            Runs the stdout printer (if necessary).

            :param test_result:
                The rest result dataset.
            """

            if not PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.quiet:
                # pylint: disable=line-too-long

                if self.should_we_print_status_to_stdout(test_result.status):
                    self.stdout_printer.template_to_use = get_template_to_use()

                    if not self.header_already_printed:
                        self.stdout_printer.print_header()
                        self.header_already_printed = True

                    self.stdout_printer.set_dataset(
                        test_result.to_dict()
                    ).print_interpolated_line()
                else:
                    print_single_line()
            else:
                print_single_line()

        def run_whois_backup(self, test_result: CheckerStatusBase) -> None:
            """
            Runs the backup or update of the WHOIS record in our dataset storage.

            :param test_result:
                The test result.
            """

            if (
                hasattr(test_result, "expiration_date")
                and test_result.expiration_date
                and test_result.whois_record
            ):
                # Note: The whois record is always given if the status does not come
                # from the database.

                self.whois_dataset.update(
                    {
                        "subject": test_result.subject,
                        "idna_subject": test_result.idna_subject,
                        "expiration_date": test_result.expiration_date,
                        "epoch": datetime.datetime.strptime(
                            test_result.expiration_date, "%d-%b-%Y"
                        ).timestamp(),
                        "registrar": test_result.registrar,
                    }
                )

        def run_inactive_backup(
            self, test_dataset: dict, test_result: CheckerStatusBase
        ) -> None:
            """
            Runs the backup or update of the Inactive dataset storage.

            The idea is that if the status is OK (active), we just remove it from
            the dataset storage. Otherwise, we just keep it in there :-)
            """

            if test_dataset["type"] != "single" and self.inactive_dataset.authorized:
                dataset = test_result.to_dict()
                dataset.update(test_dataset)

                PyFunceble.facility.Logger.debug("Test Dataset: %r", test_dataset)
                PyFunceble.facility.Logger.debug("Test Result: %r", test_result)

                if "from_inactive" in dataset:
                    if test_result.status in self.INACTIVE_STATUSES:
                        if dataset["destination"]:
                            # Note: This handles the case that someone try to test a
                            # single subject.
                            # In fact, we should not generate any file if the output
                            # directory is not given.
                            self.inactive_dataset.update(dataset)
                    else:
                        self.inactive_dataset.remove(dataset)
                elif (
                    test_result.status in self.INACTIVE_STATUSES and dataset["destination"]
                ):
                    self.inactive_dataset.update(dataset)

        def run_continue_backup(
            self, test_dataset: dict, test_result: CheckerStatusBase
        ) -> None:
            """
            Runs the backup or update of the auto-continue dataset storage.
            """

            if test_dataset["type"] != "single" and self.continue_dataset.authorized:
                dataset = test_result.to_dict()
                dataset.update(test_dataset)

                if (
                    isinstance(self.continue_dataset, CSVContinueDataset)
                    and dataset["output_dir"]
                ):
                    # Note: This handles the case that someone try to test a single subject.
                    # In fact, we should not generate any file if the output directory
                    # is not given.
                    #
                    # The exception handler is just there to catch the case that the
                    # method is not implemented because we are more likely using an
                    # alternative backup (for example mariadb).

                    self.continue_dataset.set_base_directory(dataset["output_dir"])
                self.continue_dataset.update(dataset)

        def run_ignored_file_printer(self, test_dataset: dict, test_result: str) -> None:
            """
            Runs the analytic behind the file printer.

            .. warning::
                Thie method assume that the given dataset is ignored from the normal
                file printer.
            """

            if (
                test_result == "ignored_inactive"
                and test_dataset["destination"]
                and not PyFunceble.storage.CONFIGURATION.cli_testing.file_generation.no_file
            ):
                if "idna_subject" not in test_dataset:
                    # The printer always prints the idna subject.
                    test_dataset["idna_subject"] = domain2idna(test_dataset["subject"])

                # We use this object just to get the output directory :-)
                self.status_file_generator.set_parent_dirname(test_dataset["destination"])

                # We now generate the file which let the end-user know that
                # we ignored the test of the current test dataset because there
                # is no need to retest it yet.
                # pylint: disable=line-too-long
                self.file_printer.destination = os.path.join(
                    self.status_file_generator.get_output_basedir(),
                    PyFunceble.cli.storage.OUTPUTS.logs.directories.parent,
                    PyFunceble.cli.storage.OUTPUTS.logs.filenames.inactive_not_retested,
                )

                self.file_printer.template_to_use = "plain"
                self.file_printer.dataset = test_dataset
                self.file_printer.print_interpolated_line()

        def run_status_file_printer(
            self, test_dataset: dict, test_result: CheckerStatusBase
        ) -> None:
            """
            Runs the status file printer.
            """

            if (
                test_dataset["destination"]
                and not PyFunceble.storage.CONFIGURATION.cli_testing.file_generation.no_file
            ):
                previous_allow_hosts_file = self.status_file_generator.allow_hosts_files
                previous_allow_plain_file = self.status_file_generator.allow_plain_files

                self.status_file_generator.parent_dirname = test_dataset["destination"]
                self.status_file_generator.status = test_result
                self.status_file_generator.test_dataset = test_dataset

                if test_dataset["subject_type"] == "url":
                    self.status_file_generator.allow_hosts_files = False
                    self.status_file_generator.allow_plain_files = True

                self.status_file_generator.start()
                self.status_file_generator.allow_hosts_files = previous_allow_hosts_file
                self.status_file_generator.allow_plain_files = previous_allow_plain_file

        def run_counter(self, test_dataset: dict, test_result: CheckerStatusBase) -> None:
            """
            Runs the counter of the current file.
            """

            if not PyFunceble.storage.CONFIGURATION.cli_testing.file_generation.no_file:
                # Note: We don't want hidden data to be counted.

                self.counter.set_differ_to_inline(True).set_parent_dirname(
                    test_dataset["destination"]
                )
                self.registrar_counter.set_differ_to_inline(True).set_parent_dirname(
                    test_dataset["destination"]
                )

                self.counter.count(test_result)

                if hasattr(test_result, "registrar") and test_result.registrar:
                    self.registrar_counter.count(test_result.registrar)

                self.counter.set_differ_to_inline(False)
                self.registrar_counter.set_differ_to_inline(False)

                if hasattr(test_result, "registrar") and test_result.registrar:
                    self.registrar_counter.set_parent_dirname(
                        test_dataset["destination"]
                    ).count(test_result.registrar)

        def target(self, consumed: Any) -> Optional[Tuple[Any, ...]]:
            """
            The producer of the worker.

            :param consumed:
                The consumed data to work with.
            """

            if not isinstance(consumed, tuple):
                PyFunceble.facility.Logger.info(
                    "Skipping latest dataset because consumed data was not a tuple."
                )
                return None

            # Just for human brain.
            test_dataset, test_result = consumed

            if not isinstance(test_dataset, dict):
                PyFunceble.facility.Logger.info(
                    "Skipping because test dataset is not a dictionary."
                )
                return None

            if self.should_we_ignore(test_result):
                PyFunceble.facility.Logger.info(
                    "Ignored test dataset. Reason: No output wanted."
                )
                self.run_ignored_file_printer(test_dataset, test_result)
                return None

            if not isinstance(test_result, CheckerStatusBase):
                PyFunceble.facility.Logger.info(
                    "Skipping latest dataset because consumed status is not "
                    "a status object.."
                )
                return None

            if test_dataset["type"] == "platform-contribution":
                self.platform_query_tool.deliver_contract(
                    test_dataset["contract"], test_result
                )

            if (
                PyFunceble.storage.CONFIGURATION.platform.push
                and test_result.status_source != "PLATFORM"
            ):
                self.platform_query_tool.push(test_result)

            if not PyFunceble.storage.CONFIGURATION.cli_testing.chancy_tester:
                self.run_whois_backup(test_result)
                self.run_inactive_backup(test_dataset, test_result)
                self.run_continue_backup(test_dataset, test_result)

            if not self.should_we_block_status_file_printer(test_dataset, test_result):
                self.run_status_file_printer(test_dataset, test_result)

                if not PyFunceble.storage.CONFIGURATION.cli_testing.chancy_tester:
                    self.run_counter(test_dataset, test_result)

            self.run_stdout_printer(test_result)
            test_dataset["from_producer"] = True

            return test_dataset, test_result

### `run_continue_backup(test_dataset, test_result)`

Runs the backup or update of the auto-continue dataset storage.

Source code in `PyFunceble/cli/processes/workers/producer.py`

    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297

    def run_continue_backup(
        self, test_dataset: dict, test_result: CheckerStatusBase
    ) -> None:
        """
        Runs the backup or update of the auto-continue dataset storage.
        """

        if test_dataset["type"] != "single" and self.continue_dataset.authorized:
            dataset = test_result.to_dict()
            dataset.update(test_dataset)

            if (
                isinstance(self.continue_dataset, CSVContinueDataset)
                and dataset["output_dir"]
            ):
                # Note: This handles the case that someone try to test a single subject.
                # In fact, we should not generate any file if the output directory
                # is not given.
                #
                # The exception handler is just there to catch the case that the
                # method is not implemented because we are more likely using an
                # alternative backup (for example mariadb).

                self.continue_dataset.set_base_directory(dataset["output_dir"])
            self.continue_dataset.update(dataset)

### `run_counter(test_dataset, test_result)`

Runs the counter of the current file.

Source code in `PyFunceble/cli/processes/workers/producer.py`

    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386

    def run_counter(self, test_dataset: dict, test_result: CheckerStatusBase) -> None:
        """
        Runs the counter of the current file.
        """

        if not PyFunceble.storage.CONFIGURATION.cli_testing.file_generation.no_file:
            # Note: We don't want hidden data to be counted.

            self.counter.set_differ_to_inline(True).set_parent_dirname(
                test_dataset["destination"]
            )
            self.registrar_counter.set_differ_to_inline(True).set_parent_dirname(
                test_dataset["destination"]
            )

            self.counter.count(test_result)

            if hasattr(test_result, "registrar") and test_result.registrar:
                self.registrar_counter.count(test_result.registrar)

            self.counter.set_differ_to_inline(False)
            self.registrar_counter.set_differ_to_inline(False)

            if hasattr(test_result, "registrar") and test_result.registrar:
                self.registrar_counter.set_parent_dirname(
                    test_dataset["destination"]
                ).count(test_result.registrar)

### `run_ignored_file_printer(test_dataset, test_result)`

Runs the analytic behind the file printer.

.. warning:: Thie method assume that the given dataset is ignored from the normal file printer.

Source code in `PyFunceble/cli/processes/workers/producer.py`

    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332

    def run_ignored_file_printer(self, test_dataset: dict, test_result: str) -> None:
        """
        Runs the analytic behind the file printer.

        .. warning::
            Thie method assume that the given dataset is ignored from the normal
            file printer.
        """

        if (
            test_result == "ignored_inactive"
            and test_dataset["destination"]
            and not PyFunceble.storage.CONFIGURATION.cli_testing.file_generation.no_file
        ):
            if "idna_subject" not in test_dataset:
                # The printer always prints the idna subject.
                test_dataset["idna_subject"] = domain2idna(test_dataset["subject"])

            # We use this object just to get the output directory :-)
            self.status_file_generator.set_parent_dirname(test_dataset["destination"])

            # We now generate the file which let the end-user know that
            # we ignored the test of the current test dataset because there
            # is no need to retest it yet.
            # pylint: disable=line-too-long
            self.file_printer.destination = os.path.join(
                self.status_file_generator.get_output_basedir(),
                PyFunceble.cli.storage.OUTPUTS.logs.directories.parent,
                PyFunceble.cli.storage.OUTPUTS.logs.filenames.inactive_not_retested,
            )

            self.file_printer.template_to_use = "plain"
            self.file_printer.dataset = test_dataset
            self.file_printer.print_interpolated_line()

### `run_inactive_backup(test_dataset, test_result)`

Runs the backup or update of the Inactive dataset storage.

The idea is that if the status is OK (active), we just remove it from the dataset storage. Otherwise, we just keep it in there :-)

Source code in `PyFunceble/cli/processes/workers/producer.py`

    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271

    def run_inactive_backup(
        self, test_dataset: dict, test_result: CheckerStatusBase
    ) -> None:
        """
        Runs the backup or update of the Inactive dataset storage.

        The idea is that if the status is OK (active), we just remove it from
        the dataset storage. Otherwise, we just keep it in there :-)
        """

        if test_dataset["type"] != "single" and self.inactive_dataset.authorized:
            dataset = test_result.to_dict()
            dataset.update(test_dataset)

            PyFunceble.facility.Logger.debug("Test Dataset: %r", test_dataset)
            PyFunceble.facility.Logger.debug("Test Result: %r", test_result)

            if "from_inactive" in dataset:
                if test_result.status in self.INACTIVE_STATUSES:
                    if dataset["destination"]:
                        # Note: This handles the case that someone try to test a
                        # single subject.
                        # In fact, we should not generate any file if the output
                        # directory is not given.
                        self.inactive_dataset.update(dataset)
                else:
                    self.inactive_dataset.remove(dataset)
            elif (
                test_result.status in self.INACTIVE_STATUSES and dataset["destination"]
            ):
                self.inactive_dataset.update(dataset)

### `run_status_file_printer(test_dataset, test_result)`

Runs the status file printer.

Source code in `PyFunceble/cli/processes/workers/producer.py`

    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358

    def run_status_file_printer(
        self, test_dataset: dict, test_result: CheckerStatusBase
    ) -> None:
        """
        Runs the status file printer.
        """

        if (
            test_dataset["destination"]
            and not PyFunceble.storage.CONFIGURATION.cli_testing.file_generation.no_file
        ):
            previous_allow_hosts_file = self.status_file_generator.allow_hosts_files
            previous_allow_plain_file = self.status_file_generator.allow_plain_files

            self.status_file_generator.parent_dirname = test_dataset["destination"]
            self.status_file_generator.status = test_result
            self.status_file_generator.test_dataset = test_dataset

            if test_dataset["subject_type"] == "url":
                self.status_file_generator.allow_hosts_files = False
                self.status_file_generator.allow_plain_files = True

            self.status_file_generator.start()
            self.status_file_generator.allow_hosts_files = previous_allow_hosts_file
            self.status_file_generator.allow_plain_files = previous_allow_plain_file

### `run_stdout_printer(test_result)`

Runs the stdout printer (if necessary).

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`test_result` | `CheckerStatusBase` | The rest result dataset. | required

Source code in `PyFunceble/cli/processes/workers/producer.py`

    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211

    def run_stdout_printer(self, test_result: CheckerStatusBase) -> None:
        """
        Runs the stdout printer (if necessary).

        :param test_result:
            The rest result dataset.
        """

        if not PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.quiet:
            # pylint: disable=line-too-long

            if self.should_we_print_status_to_stdout(test_result.status):
                self.stdout_printer.template_to_use = get_template_to_use()

                if not self.header_already_printed:
                    self.stdout_printer.print_header()
                    self.header_already_printed = True

                self.stdout_printer.set_dataset(
                    test_result.to_dict()
                ).print_interpolated_line()
            else:
                print_single_line()
        else:
            print_single_line()

### `run_whois_backup(test_result)`

Runs the backup or update of the WHOIS record in our dataset storage.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`test_result` | `CheckerStatusBase` | The test result. | required

Source code in `PyFunceble/cli/processes/workers/producer.py`

    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239

    def run_whois_backup(self, test_result: CheckerStatusBase) -> None:
        """
        Runs the backup or update of the WHOIS record in our dataset storage.

        :param test_result:
            The test result.
        """

        if (
            hasattr(test_result, "expiration_date")
            and test_result.expiration_date
            and test_result.whois_record
        ):
            # Note: The whois record is always given if the status does not come
            # from the database.

            self.whois_dataset.update(
                {
                    "subject": test_result.subject,
                    "idna_subject": test_result.idna_subject,
                    "expiration_date": test_result.expiration_date,
                    "epoch": datetime.datetime.strptime(
                        test_result.expiration_date, "%d-%b-%Y"
                    ).timestamp(),
                    "registrar": test_result.registrar,
                }
            )

### `should_we_block_status_file_printer(test_dataset, test_result)`

Checks if we should block the file printer.

The reason behind this is that we don't want to generate an output when a subject was already into the inactive database.

Source code in `PyFunceble/cli/processes/workers/producer.py`

    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185

    def should_we_block_status_file_printer(
        self, test_dataset: dict, test_result: CheckerStatusBase
    ) -> bool:
        """
        Checks if we should block the file printer.

        The reason behind this is that we don't want to generate an output
        when a subject was already into the inactive database.
        """

        return (
            "from_inactive" in test_dataset
            and test_result.status in self.INACTIVE_STATUSES
        )

### `should_we_ignore(test_result)` `staticmethod`

Checks if we should ignore the given datasets.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`test_result` | `CheckerStatusBase` | The test result to check. | required

Source code in `PyFunceble/cli/processes/workers/producer.py`

    140
    141
    142
    143
    144
    145
    146
    147
    148
    149

    @staticmethod
    def should_we_ignore(test_result: CheckerStatusBase) -> bool:
        """
        Checks if we should ignore the given datasets.

        :param test_result:
            The test result to check.
        """

        return isinstance(test_result, str) and test_result.startswith("ignored_")

### `should_we_print_status_to_stdout(status)` `staticmethod`

Checks if we are allows to print the given status (to stdout).

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`status` | `str` | The status to check. | required

Source code in `PyFunceble/cli/processes/workers/producer.py`

    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170

    @staticmethod
    def should_we_print_status_to_stdout(status: str) -> bool:
        """
        Checks if we are allows to print the given status (to stdout).

        :param status:
            The status to check.
        """

        if isinstance(
            PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.status, list
        ):
            to_keep = PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.status
        else:
            to_keep = [PyFunceble.storage.CONFIGURATION.cli_testing.display_mode.status]

        to_keep = [x.upper() for x in to_keep]
        status = status.upper()

        return "ALL" in to_keep or status in to_keep

### `target(consumed)`

The producer of the worker.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`consumed` | `Any` | The consumed data to work with. | required

Source code in `PyFunceble/cli/processes/workers/producer.py`

    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450

    def target(self, consumed: Any) -> Optional[Tuple[Any, ...]]:
        """
        The producer of the worker.

        :param consumed:
            The consumed data to work with.
        """

        if not isinstance(consumed, tuple):
            PyFunceble.facility.Logger.info(
                "Skipping latest dataset because consumed data was not a tuple."
            )
            return None

        # Just for human brain.
        test_dataset, test_result = consumed

        if not isinstance(test_dataset, dict):
            PyFunceble.facility.Logger.info(
                "Skipping because test dataset is not a dictionary."
            )
            return None

        if self.should_we_ignore(test_result):
            PyFunceble.facility.Logger.info(
                "Ignored test dataset. Reason: No output wanted."
            )
            self.run_ignored_file_printer(test_dataset, test_result)
            return None

        if not isinstance(test_result, CheckerStatusBase):
            PyFunceble.facility.Logger.info(
                "Skipping latest dataset because consumed status is not "
                "a status object.."
            )
            return None

        if test_dataset["type"] == "platform-contribution":
            self.platform_query_tool.deliver_contract(
                test_dataset["contract"], test_result
            )

        if (
            PyFunceble.storage.CONFIGURATION.platform.push
            and test_result.status_source != "PLATFORM"
        ):
            self.platform_query_tool.push(test_result)

        if not PyFunceble.storage.CONFIGURATION.cli_testing.chancy_tester:
            self.run_whois_backup(test_result)
            self.run_inactive_backup(test_dataset, test_result)
            self.run_continue_backup(test_dataset, test_result)

        if not self.should_we_block_status_file_printer(test_dataset, test_result):
            self.run_status_file_printer(test_dataset, test_result)

            if not PyFunceble.storage.CONFIGURATION.cli_testing.chancy_tester:
                self.run_counter(test_dataset, test_result)

        self.run_stdout_printer(test_result)
        test_dataset["from_producer"] = True

        return test_dataset, test_result