PyFunceble-dev 4.3.0a15__py3-none-any.whl → 4.3.0a17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyFunceble/__init__.py +1 -1
- PyFunceble/checker/__init__.py +1 -1
- PyFunceble/checker/availability/__init__.py +1 -1
- PyFunceble/checker/availability/base.py +36 -33
- PyFunceble/checker/availability/domain.py +1 -1
- PyFunceble/checker/availability/domain_and_ip.py +1 -1
- PyFunceble/checker/availability/extras/__init__.py +1 -1
- PyFunceble/checker/availability/extras/base.py +4 -4
- PyFunceble/checker/availability/extras/dns.py +1 -1
- PyFunceble/checker/availability/extras/etoxic.py +1 -1
- PyFunceble/checker/availability/extras/external.py +1 -1
- PyFunceble/checker/availability/extras/parked.py +1 -1
- PyFunceble/checker/availability/extras/rules.py +1 -1
- PyFunceble/checker/availability/extras/subject_switch.py +1 -1
- PyFunceble/checker/availability/ip.py +1 -1
- PyFunceble/checker/availability/params.py +1 -1
- PyFunceble/checker/availability/status.py +1 -1
- PyFunceble/checker/availability/url.py +1 -1
- PyFunceble/checker/base.py +1 -1
- PyFunceble/checker/complex_json_encoder.py +1 -1
- PyFunceble/checker/params_base.py +1 -1
- PyFunceble/checker/reputation/__init__.py +1 -1
- PyFunceble/checker/reputation/base.py +1 -1
- PyFunceble/checker/reputation/domain.py +1 -1
- PyFunceble/checker/reputation/domain_and_ip.py +1 -1
- PyFunceble/checker/reputation/ip.py +1 -1
- PyFunceble/checker/reputation/params.py +1 -1
- PyFunceble/checker/reputation/status.py +1 -1
- PyFunceble/checker/reputation/url.py +1 -1
- PyFunceble/checker/status_base.py +1 -1
- PyFunceble/checker/syntax/__init__.py +1 -1
- PyFunceble/checker/syntax/base.py +1 -1
- PyFunceble/checker/syntax/domain.py +1 -1
- PyFunceble/checker/syntax/domain_and_ip.py +1 -1
- PyFunceble/checker/syntax/domain_base.py +1 -1
- PyFunceble/checker/syntax/ip.py +1 -1
- PyFunceble/checker/syntax/ipv4.py +1 -1
- PyFunceble/checker/syntax/ipv6.py +1 -1
- PyFunceble/checker/syntax/params.py +1 -1
- PyFunceble/checker/syntax/second_lvl_domain.py +1 -1
- PyFunceble/checker/syntax/status.py +1 -1
- PyFunceble/checker/syntax/subdomain.py +1 -1
- PyFunceble/checker/syntax/url.py +1 -1
- PyFunceble/checker/utils/__init__.py +1 -1
- PyFunceble/checker/utils/whois.py +1 -1
- PyFunceble/cli/__init__.py +1 -1
- PyFunceble/cli/continuous_integration/__init__.py +1 -1
- PyFunceble/cli/continuous_integration/base.py +1 -1
- PyFunceble/cli/continuous_integration/exceptions.py +1 -1
- PyFunceble/cli/continuous_integration/github_actions.py +1 -1
- PyFunceble/cli/continuous_integration/gitlab_ci.py +1 -1
- PyFunceble/cli/continuous_integration/jenkins.py +1 -1
- PyFunceble/cli/continuous_integration/standalone.py +1 -1
- PyFunceble/cli/continuous_integration/travis_ci.py +1 -1
- PyFunceble/cli/continuous_integration/utils.py +1 -1
- PyFunceble/cli/credential_loader.py +1 -1
- PyFunceble/cli/entry_points/__init__.py +1 -1
- PyFunceble/cli/entry_points/clean.py +1 -1
- PyFunceble/cli/entry_points/iana.py +1 -1
- PyFunceble/cli/entry_points/production.py +1 -1
- PyFunceble/cli/entry_points/public_suffix.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/__init__.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/argsparser.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/cli.py +2 -2
- PyFunceble/cli/execution_time.py +1 -1
- PyFunceble/cli/facility.py +1 -1
- PyFunceble/cli/factory.py +1 -1
- PyFunceble/cli/file_preloader.py +1 -1
- PyFunceble/cli/filesystem/__init__.py +1 -1
- PyFunceble/cli/filesystem/cleanup.py +1 -1
- PyFunceble/cli/filesystem/counter.py +1 -1
- PyFunceble/cli/filesystem/dir_base.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/__init__.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/backup.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/base.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/restore.py +1 -1
- PyFunceble/cli/filesystem/json_base.py +1 -1
- PyFunceble/cli/filesystem/printer/__init__.py +1 -1
- PyFunceble/cli/filesystem/printer/base.py +1 -1
- PyFunceble/cli/filesystem/printer/file.py +1 -1
- PyFunceble/cli/filesystem/printer/stdout.py +1 -1
- PyFunceble/cli/filesystem/registrar_counter.py +1 -1
- PyFunceble/cli/filesystem/status_file.py +1 -1
- PyFunceble/cli/migrators/__init__.py +1 -1
- PyFunceble/cli/migrators/alembic.py +1 -1
- PyFunceble/cli/migrators/base.py +1 -1
- PyFunceble/cli/migrators/csv_file/__init__.py +1 -1
- PyFunceble/cli/migrators/csv_file/base.py +1 -1
- PyFunceble/cli/migrators/csv_file/inactive_source_delete.py +1 -1
- PyFunceble/cli/migrators/csv_file/whois_registrar_add.py +1 -1
- PyFunceble/cli/migrators/db_base.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/__init__.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/base.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/hashes_file.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/mining_file.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/production_config_file.py +1 -1
- PyFunceble/cli/migrators/json2csv/__init__.py +1 -1
- PyFunceble/cli/migrators/json2csv/base.py +1 -1
- PyFunceble/cli/migrators/json2csv/inactive.py +1 -1
- PyFunceble/cli/migrators/json2csv/whois.py +1 -1
- PyFunceble/cli/migrators/mariadb/__init__.py +1 -1
- PyFunceble/cli/migrators/mariadb/base.py +1 -1
- PyFunceble/cli/migrators/mariadb/file_and_status.py +1 -1
- PyFunceble/cli/migrators/mariadb/whois_record_idna_subject.py +1 -1
- PyFunceble/cli/processes/__init__.py +1 -1
- PyFunceble/cli/processes/base.py +4 -442
- PyFunceble/cli/processes/chancy_producer.py +3 -2
- PyFunceble/cli/processes/chancy_tester.py +3 -2
- PyFunceble/cli/processes/dir_files_sorter.py +3 -2
- PyFunceble/cli/processes/file_sorter.py +3 -2
- PyFunceble/cli/processes/migrator.py +25 -14
- PyFunceble/cli/processes/miner.py +3 -2
- PyFunceble/cli/processes/producer.py +3 -2
- PyFunceble/cli/processes/tester.py +3 -2
- PyFunceble/cli/processes/workers/__init__.py +1 -1
- PyFunceble/cli/processes/workers/base.py +33 -324
- PyFunceble/cli/processes/workers/chancy_producer.py +1 -3
- PyFunceble/cli/processes/workers/chancy_tester.py +5 -5
- PyFunceble/cli/processes/workers/dir_files_sorter.py +8 -3
- PyFunceble/cli/processes/workers/file_sorter.py +8 -3
- PyFunceble/cli/processes/workers/file_sorter_base.py +1 -1
- PyFunceble/cli/processes/workers/migrator.py +5 -3
- PyFunceble/cli/processes/workers/miner.py +10 -5
- PyFunceble/cli/processes/workers/producer.py +15 -8
- PyFunceble/cli/processes/workers/tester.py +5 -5
- PyFunceble/cli/scripts/__init__.py +1 -1
- PyFunceble/cli/scripts/iana.py +1 -1
- PyFunceble/cli/scripts/production.py +1 -1
- PyFunceble/cli/scripts/public_suffix.py +1 -1
- PyFunceble/cli/storage.py +1 -1
- PyFunceble/cli/storage_facility.py +1 -1
- PyFunceble/cli/system/__init__.py +1 -1
- PyFunceble/cli/system/base.py +2 -2
- PyFunceble/cli/system/integrator.py +2 -1
- PyFunceble/cli/system/launcher.py +81 -57
- PyFunceble/cli/utils/__init__.py +1 -1
- PyFunceble/cli/utils/ascii_logo.py +1 -1
- PyFunceble/cli/utils/sort.py +1 -1
- PyFunceble/cli/utils/stdout.py +1 -1
- PyFunceble/cli/utils/testing.py +1 -1
- PyFunceble/cli/utils/version.py +1 -1
- PyFunceble/config/__init__.py +1 -1
- PyFunceble/config/compare.py +1 -1
- PyFunceble/config/loader.py +1 -1
- PyFunceble/converter/__init__.py +1 -1
- PyFunceble/converter/adblock_input_line2subject.py +1 -1
- PyFunceble/converter/base.py +1 -1
- PyFunceble/converter/cidr2subject.py +1 -1
- PyFunceble/converter/input_line2subject.py +1 -1
- PyFunceble/converter/internal_url.py +1 -1
- PyFunceble/converter/rpz_input_line2subject.py +1 -1
- PyFunceble/converter/rpz_policy2subject.py +1 -1
- PyFunceble/converter/subject2complements.py +1 -1
- PyFunceble/converter/url2netloc.py +1 -1
- PyFunceble/converter/wildcard2subject.py +1 -1
- PyFunceble/data/alembic/__init__.py +1 -1
- PyFunceble/data/alembic/mysql/__init__.py +1 -1
- PyFunceble/data/alembic/mysql/env.py +1 -1
- PyFunceble/data/alembic/mysql/versions/__init__.py +1 -1
- PyFunceble/data/alembic/postgresql/__init__.py +1 -1
- PyFunceble/data/alembic/postgresql/env.py +1 -1
- PyFunceble/data/alembic/postgresql/versions/__init__.py +1 -1
- PyFunceble/database/__init__.py +1 -1
- PyFunceble/database/credential/__init__.py +1 -1
- PyFunceble/database/credential/base.py +1 -1
- PyFunceble/database/credential/mariadb.py +1 -1
- PyFunceble/database/credential/mysql.py +1 -1
- PyFunceble/database/credential/postgresql.py +1 -1
- PyFunceble/database/schemas/__init__.py +1 -1
- PyFunceble/database/schemas/autocontinue.py +1 -1
- PyFunceble/database/schemas/inactive.py +1 -1
- PyFunceble/database/schemas/status.py +1 -1
- PyFunceble/database/schemas/whois_record.py +1 -1
- PyFunceble/database/session.py +1 -1
- PyFunceble/database/sqlalchemy/__init__.py +1 -1
- PyFunceble/database/sqlalchemy/all_schemas.py +1 -1
- PyFunceble/database/sqlalchemy/base_schema.py +1 -1
- PyFunceble/dataset/__init__.py +1 -1
- PyFunceble/dataset/autocontinue/__init__.py +1 -1
- PyFunceble/dataset/autocontinue/base.py +1 -1
- PyFunceble/dataset/autocontinue/csv.py +1 -1
- PyFunceble/dataset/autocontinue/sql.py +1 -1
- PyFunceble/dataset/base.py +2 -2
- PyFunceble/dataset/csv_base.py +1 -1
- PyFunceble/dataset/db_base.py +1 -1
- PyFunceble/dataset/iana.py +1 -1
- PyFunceble/dataset/inactive/__init__.py +1 -1
- PyFunceble/dataset/inactive/base.py +1 -1
- PyFunceble/dataset/inactive/csv.py +1 -1
- PyFunceble/dataset/inactive/sql.py +1 -1
- PyFunceble/dataset/ipv4_reputation.py +1 -1
- PyFunceble/dataset/public_suffix.py +1 -1
- PyFunceble/dataset/sql_base.py +4 -3
- PyFunceble/dataset/user_agent.py +1 -1
- PyFunceble/dataset/whois/__init__.py +1 -1
- PyFunceble/dataset/whois/base.py +1 -1
- PyFunceble/dataset/whois/csv.py +1 -1
- PyFunceble/dataset/whois/sql.py +1 -1
- PyFunceble/downloader/__init__.py +1 -1
- PyFunceble/downloader/base.py +1 -1
- PyFunceble/downloader/exceptions.py +1 -1
- PyFunceble/downloader/iana.py +1 -1
- PyFunceble/downloader/ipv4_reputation.py +1 -1
- PyFunceble/downloader/public_suffix.py +1 -1
- PyFunceble/downloader/user_agents.py +1 -1
- PyFunceble/exceptions.py +1 -1
- PyFunceble/facility.py +1 -1
- PyFunceble/factory.py +1 -1
- PyFunceble/helpers/__init__.py +1 -1
- PyFunceble/helpers/command.py +1 -1
- PyFunceble/helpers/dict.py +1 -1
- PyFunceble/helpers/directory.py +1 -1
- PyFunceble/helpers/download.py +1 -1
- PyFunceble/helpers/environment_variable.py +1 -1
- PyFunceble/helpers/exceptions.py +1 -1
- PyFunceble/helpers/file.py +1 -1
- PyFunceble/helpers/hash.py +1 -1
- PyFunceble/helpers/list.py +1 -1
- PyFunceble/helpers/merge.py +1 -1
- PyFunceble/helpers/regex.py +1 -1
- PyFunceble/logger.py +34 -11
- PyFunceble/query/__init__.py +1 -1
- PyFunceble/query/dns/__init__.py +1 -1
- PyFunceble/query/dns/nameserver.py +1 -1
- PyFunceble/query/dns/query_tool.py +1 -1
- PyFunceble/query/dns/resolver.py +1 -1
- PyFunceble/query/http_status_code.py +1 -1
- PyFunceble/query/netinfo/__init__.py +1 -1
- PyFunceble/query/netinfo/address.py +1 -1
- PyFunceble/query/netinfo/base.py +1 -1
- PyFunceble/query/netinfo/hostbyaddr.py +1 -1
- PyFunceble/query/platform.py +1 -1
- PyFunceble/query/record/__init__.py +1 -1
- PyFunceble/query/record/base.py +1 -1
- PyFunceble/query/record/dns.py +1 -1
- PyFunceble/query/record/whois.py +1 -1
- PyFunceble/query/requests/__init__.py +1 -1
- PyFunceble/query/requests/adapter/__init__.py +1 -1
- PyFunceble/query/requests/adapter/base.py +1 -1
- PyFunceble/query/requests/adapter/http.py +1 -1
- PyFunceble/query/requests/adapter/https.py +1 -1
- PyFunceble/query/requests/requester.py +1 -1
- PyFunceble/query/whois/__init__.py +1 -1
- PyFunceble/query/whois/converter/__init__.py +1 -1
- PyFunceble/query/whois/converter/base.py +1 -1
- PyFunceble/query/whois/converter/digit2digits.py +1 -1
- PyFunceble/query/whois/converter/expiration_date.py +1 -1
- PyFunceble/query/whois/converter/month2unified.py +1 -1
- PyFunceble/query/whois/converter/registrar.py +1 -1
- PyFunceble/query/whois/query_tool.py +1 -1
- PyFunceble/sessions.py +1 -1
- PyFunceble/storage.py +2 -2
- PyFunceble/storage_facility.py +1 -1
- PyFunceble/utils/__init__.py +1 -1
- PyFunceble/utils/platform.py +1 -1
- PyFunceble/utils/profile.py +1 -1
- PyFunceble/utils/version.py +1 -1
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a17.dist-info}/LICENSE +1 -1
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a17.dist-info}/METADATA +120 -99
- pyfunceble_dev-4.3.0a17.dist-info/RECORD +284 -0
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a17.dist-info}/WHEEL +1 -1
- PyFunceble_dev-4.3.0a15.dist-info/RECORD +0 -284
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a17.dist-info}/entry_points.txt +0 -0
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a17.dist-info}/top_level.txt +0 -0
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -50,24 +50,21 @@ License:
|
|
50
50
|
limitations under the License.
|
51
51
|
"""
|
52
52
|
|
53
|
+
# pylint: disable=import-error,no-name-in-module,no-member
|
54
|
+
|
53
55
|
import multiprocessing
|
54
|
-
import
|
55
|
-
import queue
|
56
|
-
import time
|
57
|
-
import traceback
|
58
|
-
from datetime import datetime, timedelta, timezone
|
59
|
-
from typing import Any, List, Optional, Tuple
|
56
|
+
from typing import Optional
|
60
57
|
|
61
58
|
import PyFunceble.cli.facility
|
62
59
|
import PyFunceble.cli.factory
|
60
|
+
import PyFunceble.ext.process_manager
|
63
61
|
import PyFunceble.facility
|
64
62
|
import PyFunceble.sessions
|
65
63
|
import PyFunceble.storage
|
66
|
-
from PyFunceble.cli.continuous_integration.base import ContinuousIntegrationBase
|
67
64
|
from PyFunceble.query.requests.requester import Requester
|
68
65
|
|
69
66
|
|
70
|
-
class WorkerBase(
|
67
|
+
class WorkerBase(PyFunceble.ext.process_manager.WorkerCore):
|
71
68
|
"""
|
72
69
|
Provides the base of all our workers.
|
73
70
|
|
@@ -77,61 +74,15 @@ class WorkerBase(multiprocessing.Process):
|
|
77
74
|
The output queue to write.
|
78
75
|
"""
|
79
76
|
|
80
|
-
STD_NAME: str = "pyfunceble_base_worker"
|
81
|
-
|
82
|
-
MINING_WAIT_TIME: int = 60
|
83
|
-
BREAKOFF: float = 2.0
|
84
|
-
|
85
|
-
input_queue: Optional[queue.Queue] = None
|
86
|
-
output_queue: Optional[queue.Queue] = None
|
87
|
-
|
88
|
-
continuous_integration: ContinuousIntegrationBase = None
|
89
|
-
|
90
|
-
global_exit_event: Optional[multiprocessing.Event] = None
|
91
|
-
exit_it: Optional[multiprocessing.Event] = None
|
92
|
-
|
93
|
-
send_stop_message: Optional[bool] = None
|
94
|
-
accept_waiting_delay: Optional[bool] = None
|
95
|
-
|
96
|
-
concurrent_worker_names: Optional[List[str]] = None
|
97
77
|
db_session: Optional[PyFunceble.cli.factory.db_session] = None
|
98
|
-
|
99
|
-
_parent_connection: Optional[multiprocessing.connection.Connection] = None
|
100
|
-
_child_connection: Optional[multiprocessing.connection.Connection] = None
|
101
|
-
_exception: Optional[multiprocessing.Pipe] = None
|
102
|
-
|
103
|
-
_params: Optional[dict] = {}
|
104
78
|
requester: Optional[Requester] = None
|
105
79
|
|
106
|
-
def
|
107
|
-
self
|
108
|
-
|
109
|
-
output_queue: Optional[queue.Queue] = None,
|
110
|
-
global_exit_event: Optional[multiprocessing.Event] = None,
|
111
|
-
*,
|
112
|
-
name: Optional[str] = None,
|
113
|
-
daemon: Optional[bool] = None,
|
114
|
-
continuous_integration: Optional[ContinuousIntegrationBase] = None,
|
115
|
-
configuration: Optional[dict] = None,
|
116
|
-
) -> None:
|
117
|
-
self.configuration = self._params["configuration"] = configuration
|
118
|
-
self.input_queue = self._params["input_queue"] = input_queue
|
119
|
-
self.output_queue = self._params["output_queue"] = output_queue
|
120
|
-
|
121
|
-
self.continuous_integration = self._params["continuous_integration"] = (
|
122
|
-
continuous_integration
|
123
|
-
)
|
124
|
-
|
125
|
-
self.global_exit_event = self._params["global_exit_event"] = global_exit_event
|
126
|
-
self.exit_it = multiprocessing.Event()
|
127
|
-
|
128
|
-
self._parent_connection, self._child_connection = multiprocessing.Pipe()
|
129
|
-
self._exception = None
|
130
|
-
|
131
|
-
self.send_stop_message = True
|
132
|
-
self.accept_waiting_delay = True
|
133
|
-
self.concurrent_worker_names = []
|
80
|
+
def __del__(self) -> None:
|
81
|
+
if self.db_session is not None:
|
82
|
+
self.db_session.close()
|
134
83
|
|
84
|
+
def __post_init__(self) -> None:
|
85
|
+
self.requester = Requester(config=PyFunceble.storage.CONFIGURATION)
|
135
86
|
try:
|
136
87
|
self.db_session = (
|
137
88
|
PyFunceble.cli.factory.DBSession.get_db_session().get_new_session()()
|
@@ -139,281 +90,39 @@ class WorkerBase(multiprocessing.Process):
|
|
139
90
|
except TypeError:
|
140
91
|
self.db_session = None
|
141
92
|
|
142
|
-
|
143
|
-
|
144
|
-
self.__post_init__()
|
145
|
-
|
146
|
-
def __del__(self) -> None:
|
147
|
-
if self.db_session is not None:
|
148
|
-
self.db_session.close()
|
149
|
-
|
150
|
-
def __post_init__(self) -> None:
|
151
|
-
"""
|
152
|
-
A method which will be executed after the :code:`__init__` method.
|
153
|
-
"""
|
154
|
-
|
155
|
-
self.requester = Requester(config=PyFunceble.storage.CONFIGURATION)
|
156
|
-
|
157
|
-
@property
|
158
|
-
def exception(self):
|
159
|
-
"""
|
160
|
-
Provides the exception of the current worker.
|
161
|
-
"""
|
162
|
-
|
163
|
-
if self._parent_connection.poll():
|
164
|
-
self._exception = self._parent_connection.recv()
|
165
|
-
|
166
|
-
return self._exception
|
167
|
-
|
168
|
-
def add_to_input_queue(
|
169
|
-
self,
|
170
|
-
data: Any,
|
171
|
-
*,
|
172
|
-
worker_name: Optional[str] = None,
|
173
|
-
destination_worker: Optional[str] = None,
|
174
|
-
) -> "WorkerBase":
|
93
|
+
def perform_external_poweron_checks(self) -> bool:
|
175
94
|
"""
|
176
|
-
|
177
|
-
|
178
|
-
:param data:
|
179
|
-
The data to add into the queue.
|
180
|
-
:param destination_worker:
|
181
|
-
The name of the worker which is supposed to read the message.
|
182
|
-
"""
|
183
|
-
|
184
|
-
if worker_name:
|
185
|
-
to_send = (worker_name, destination_worker, data)
|
186
|
-
else:
|
187
|
-
to_send = (self.name, destination_worker, data)
|
188
|
-
|
189
|
-
self.input_queue.put(to_send)
|
190
|
-
|
191
|
-
PyFunceble.facility.Logger.debug("Added to the (input) queue: %r", data)
|
192
|
-
|
193
|
-
def add_to_output_queue(
|
194
|
-
self,
|
195
|
-
data: Any,
|
196
|
-
*,
|
197
|
-
worker_name: Optional[str] = None,
|
198
|
-
destination_worker: Optional[str] = None,
|
199
|
-
) -> "WorkerBase":
|
200
|
-
"""
|
201
|
-
Adds the given data to the output queue queue.
|
202
|
-
|
203
|
-
:param data:
|
204
|
-
The data to add into the queue.
|
95
|
+
Perform the external poweron checks.
|
205
96
|
"""
|
206
97
|
|
207
|
-
if
|
208
|
-
to_send = (worker_name, destination_worker, data)
|
209
|
-
else:
|
210
|
-
to_send = (self.name, destination_worker, data)
|
211
|
-
|
212
|
-
if self.output_queue is not None:
|
213
|
-
for output_queue in self.output_queue:
|
214
|
-
output_queue.put(to_send)
|
215
|
-
|
216
|
-
PyFunceble.facility.Logger.debug("Added to the (output) queue: %r", data)
|
217
|
-
|
218
|
-
return self
|
219
|
-
|
220
|
-
def target(self, consumed: Any) -> Optional[Tuple[Any, ...]]:
|
221
|
-
"""
|
222
|
-
This the target that is run to process something.
|
223
|
-
This method should return a result which will pu send to the output
|
224
|
-
queue.
|
225
|
-
"""
|
226
|
-
|
227
|
-
raise NotImplementedError()
|
228
|
-
|
229
|
-
def share_waiting_message(
|
230
|
-
self,
|
231
|
-
*,
|
232
|
-
overall: bool = False,
|
233
|
-
ignore_current_worker: bool = False,
|
234
|
-
apply_breakoff: bool = False,
|
235
|
-
) -> "WorkerBase":
|
236
|
-
"""
|
237
|
-
Shares a waiting message to both input and output queues.
|
238
|
-
The idea is to keep our worker awake when necessary. This functionality
|
239
|
-
is really important when running the mining worker because sometime
|
240
|
-
the flow is so long, that we may need some time.
|
241
|
-
|
242
|
-
:param overall:
|
243
|
-
Shares the message multiple time to specific destination in our
|
244
|
-
current stack.
|
245
|
-
:param ignore_current_worker:
|
246
|
-
Doesn't share the message with ourself.
|
247
|
-
:param apply_breakoff:
|
248
|
-
Activates the breakoff (sleep) before starting to share the message.
|
249
|
-
"""
|
250
|
-
|
251
|
-
if overall:
|
252
|
-
for worker_name in self.concurrent_worker_names:
|
253
|
-
if apply_breakoff:
|
254
|
-
time.sleep(self.BREAKOFF)
|
255
|
-
|
256
|
-
if not ignore_current_worker:
|
257
|
-
# Give the whole stack a bit more of time.
|
258
|
-
self.add_to_input_queue("wait", destination_worker=worker_name)
|
259
|
-
|
260
|
-
self.add_to_output_queue("wait")
|
261
|
-
else:
|
262
|
-
if apply_breakoff:
|
263
|
-
time.sleep(self.BREAKOFF)
|
264
|
-
|
265
|
-
if not ignore_current_worker:
|
266
|
-
self.add_to_input_queue("wait", destination_worker=self.name)
|
267
|
-
|
268
|
-
self.add_to_output_queue("wait")
|
269
|
-
|
270
|
-
def run(self) -> None: # pylint: disable=too-many-statements
|
271
|
-
def break_now() -> bool:
|
272
|
-
"""
|
273
|
-
Checks if it is time to make a break.
|
274
|
-
"""
|
275
|
-
|
276
|
-
if not wait_for_stop or not self.accept_waiting_delay:
|
277
|
-
return True
|
278
|
-
|
279
|
-
return datetime.now(timezone.utc) > break_time
|
280
|
-
|
281
|
-
if self.configuration is not None:
|
98
|
+
if hasattr(self, "configuration") and self.configuration is not None:
|
282
99
|
PyFunceble.facility.ConfigLoader.set_custom_config(self.configuration)
|
283
100
|
|
284
|
-
if
|
101
|
+
if (
|
102
|
+
multiprocessing.get_start_method() != "fork"
|
103
|
+
or not PyFunceble.storage.CONFIGURATION
|
104
|
+
):
|
285
105
|
PyFunceble.facility.ConfigLoader.start()
|
286
106
|
PyFunceble.cli.facility.CredentialLoader.start()
|
287
107
|
PyFunceble.cli.factory.DBSession.init_db_sessions()
|
288
108
|
|
289
|
-
|
290
|
-
bool(PyFunceble.storage.CONFIGURATION.cli_testing.mining) is True
|
291
|
-
)
|
292
|
-
break_time = datetime.now(timezone.utc) + timedelta(
|
293
|
-
seconds=self.MINING_WAIT_TIME
|
294
|
-
)
|
295
|
-
|
296
|
-
try: # pylint: disable=too-many-nested-blocks
|
297
|
-
while True:
|
298
|
-
if self.global_exit_event.is_set():
|
299
|
-
PyFunceble.facility.Logger.info(
|
300
|
-
"Got global exit event. Stopping worker."
|
301
|
-
)
|
302
|
-
|
303
|
-
break
|
304
|
-
|
305
|
-
if self.exit_it.is_set():
|
306
|
-
PyFunceble.facility.Logger.info("Got exit event. Stopping worker.")
|
307
|
-
break
|
308
|
-
|
309
|
-
if (
|
310
|
-
self.continuous_integration
|
311
|
-
and self.continuous_integration.is_time_exceeded()
|
312
|
-
):
|
313
|
-
PyFunceble.facility.Logger.info(
|
314
|
-
"CI time exceeded. Stopping worker."
|
315
|
-
)
|
316
|
-
|
317
|
-
if break_now():
|
318
|
-
self.exit_it.set()
|
319
|
-
continue
|
320
|
-
|
321
|
-
continue
|
322
|
-
|
323
|
-
try:
|
324
|
-
worker_name, destination_worker, consumed = self.input_queue.get()
|
325
|
-
except (EOFError, KeyboardInterrupt):
|
326
|
-
PyFunceble.facility.Logger.info(
|
327
|
-
"Got EOFError/KeyboardInterrupt. Stopping worker."
|
328
|
-
)
|
329
|
-
self.global_exit_event.set()
|
330
|
-
break
|
331
|
-
|
332
|
-
if destination_worker and destination_worker != self.name:
|
333
|
-
self.add_to_input_queue(
|
334
|
-
consumed,
|
335
|
-
worker_name=worker_name,
|
336
|
-
destination_worker=destination_worker,
|
337
|
-
)
|
338
|
-
continue
|
339
|
-
|
340
|
-
PyFunceble.facility.Logger.info(
|
341
|
-
"Got (from %r): %r",
|
342
|
-
worker_name,
|
343
|
-
consumed,
|
344
|
-
)
|
345
|
-
|
346
|
-
if consumed == "stop":
|
347
|
-
if break_now():
|
348
|
-
PyFunceble.facility.Logger.info(
|
349
|
-
"Got stop message from %r. Applying.",
|
350
|
-
worker_name,
|
351
|
-
)
|
352
|
-
|
353
|
-
self.exit_it.set()
|
354
|
-
continue
|
355
|
-
|
356
|
-
self.share_waiting_message(apply_breakoff=wait_for_stop)
|
357
|
-
continue
|
358
|
-
|
359
|
-
if consumed == "wait":
|
360
|
-
if not wait_for_stop:
|
361
|
-
continue
|
362
|
-
|
363
|
-
if break_now():
|
364
|
-
PyFunceble.facility.Logger.debug(
|
365
|
-
"Waited sufficiently. Stopping current worker."
|
366
|
-
)
|
367
|
-
|
368
|
-
# The real (break) action shouldn't be handled here.
|
369
|
-
self.exit_it.set()
|
370
|
-
continue
|
371
|
-
|
372
|
-
PyFunceble.facility.Logger.debug(
|
373
|
-
"We need to wait a bit more. Continue waiting."
|
374
|
-
)
|
375
|
-
|
376
|
-
self.share_waiting_message(apply_breakoff=wait_for_stop)
|
377
|
-
continue
|
378
|
-
|
379
|
-
try:
|
380
|
-
result = self.target(consumed)
|
381
|
-
except (EOFError, KeyboardInterrupt):
|
382
|
-
PyFunceble.facility.Logger.info(
|
383
|
-
"Got EOFError/KeyboardInterrupt. Stopping worker."
|
384
|
-
)
|
385
|
-
self.global_exit_event.set()
|
386
|
-
break
|
387
|
-
|
388
|
-
if result is not None:
|
389
|
-
self.add_to_output_queue(result)
|
390
|
-
|
391
|
-
PyFunceble.facility.Logger.info(
|
392
|
-
"Produced: %r",
|
393
|
-
result,
|
394
|
-
)
|
395
|
-
|
396
|
-
break_time = datetime.now(timezone.utc) + timedelta(
|
397
|
-
seconds=self.MINING_WAIT_TIME
|
398
|
-
)
|
399
|
-
|
400
|
-
except Exception as exception: # pylint: disable=broad-except
|
401
|
-
PyFunceble.facility.Logger.critical(
|
402
|
-
"Error while running target", exc_info=True
|
403
|
-
)
|
404
|
-
trace = traceback.format_exc()
|
405
|
-
self._child_connection.send((exception, trace))
|
109
|
+
return super().perform_external_poweron_checks()
|
406
110
|
|
407
|
-
|
408
|
-
raise exception
|
409
|
-
|
410
|
-
def terminate(self) -> None:
|
111
|
+
def perform_external_preflight_checks(self) -> bool:
|
411
112
|
"""
|
412
|
-
|
113
|
+
Perform the external preflight checks.
|
413
114
|
"""
|
414
115
|
|
415
|
-
|
116
|
+
if (
|
117
|
+
hasattr(self, "continuous_integration")
|
118
|
+
and self.continuous_integration
|
119
|
+
and self.continuous_integration.is_time_exceeded()
|
120
|
+
):
|
121
|
+
PyFunceble.facility.Logger.info("CI time exceeded. Stopping worker.")
|
122
|
+
|
123
|
+
if not self.delay_shutdown:
|
124
|
+
self.exit_event.set()
|
125
|
+
|
126
|
+
return False
|
416
127
|
|
417
|
-
|
418
|
-
# Necessary to avoid blocking.
|
419
|
-
self.add_to_input_queue("stop", destination_worker=self.name)
|
128
|
+
return super().perform_external_preflight_checks()
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -69,8 +69,6 @@ class ChancyProducerWorker(ProducerWorker):
|
|
69
69
|
USE AT YOUR OWN RISK. GOOD LUCK!
|
70
70
|
"""
|
71
71
|
|
72
|
-
STD_NAME: str = "pyfunceble_chancy_producer_worker"
|
73
|
-
|
74
72
|
def target(self, consumed: Any) -> Optional[Tuple[Any, ...]]:
|
75
73
|
if not isinstance(consumed, tuple):
|
76
74
|
PyFunceble.facility.Logger.info(
|
@@ -37,7 +37,7 @@ License:
|
|
37
37
|
::
|
38
38
|
|
39
39
|
|
40
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
40
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
41
41
|
|
42
42
|
Licensed under the Apache License, Version 2.0 (the "License");
|
43
43
|
you may not use this file except in compliance with the License.
|
@@ -70,10 +70,10 @@ class ChancyTesterWorker(TesterWorker):
|
|
70
70
|
USE AT YOUR OWN RISK. GOOD LUCK!
|
71
71
|
"""
|
72
72
|
|
73
|
-
STD_NAME: str = "pyfunceble_chancy_tester_worker"
|
74
|
-
|
75
73
|
def __post_init__(self) -> None:
|
76
|
-
self.producer_worker = ProducerWorker(**self.
|
74
|
+
self.producer_worker = ProducerWorker(**self._all_args)
|
75
|
+
self.producer_worker.name = f"{self.name}.producer"
|
76
|
+
self.producer_worker.perform_external_poweron_checks()
|
77
77
|
|
78
78
|
return super().__post_init__()
|
79
79
|
|
@@ -81,7 +81,7 @@ class ChancyTesterWorker(TesterWorker):
|
|
81
81
|
"""
|
82
82
|
The actually wall destructor.
|
83
83
|
|
84
|
-
:param
|
84
|
+
:param consumed:
|
85
85
|
The data that needs to be tested.
|
86
86
|
"""
|
87
87
|
|
@@ -37,7 +37,7 @@ License:
|
|
37
37
|
::
|
38
38
|
|
39
39
|
|
40
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
40
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
41
41
|
|
42
42
|
Licensed under the Apache License, Version 2.0 (the "License");
|
43
43
|
you may not use this file except in compliance with the License.
|
@@ -85,8 +85,6 @@ class DireFileSorterWorker(FileSorterWorkerBase):
|
|
85
85
|
None
|
86
86
|
"""
|
87
87
|
|
88
|
-
STD_NAME: str = "pyfunceble_dir_files_sorter_worker"
|
89
|
-
|
90
88
|
@staticmethod
|
91
89
|
def get_files_to_sort(directory: str) -> List[str]:
|
92
90
|
"""
|
@@ -130,6 +128,13 @@ class DireFileSorterWorker(FileSorterWorkerBase):
|
|
130
128
|
return result
|
131
129
|
|
132
130
|
def target(self, consumed: Any) -> Optional[Tuple[Any, ...]]:
|
131
|
+
"""
|
132
|
+
The producer of the worker.
|
133
|
+
|
134
|
+
:param consumed:
|
135
|
+
The consumed data to work with.
|
136
|
+
"""
|
137
|
+
|
133
138
|
if (
|
134
139
|
not isinstance(consumed, dict)
|
135
140
|
and "directory" not in consumed
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -81,9 +81,14 @@ class FileSorterWorker(FileSorterWorkerBase):
|
|
81
81
|
None
|
82
82
|
"""
|
83
83
|
|
84
|
-
STD_NAME: str = "pyfunceble_file_sorter_worker"
|
85
|
-
|
86
84
|
def target(self, consumed: Any) -> Optional[Tuple[Any, ...]]:
|
85
|
+
"""
|
86
|
+
The producer of the worker.
|
87
|
+
|
88
|
+
:param consumed:
|
89
|
+
The consumed data to work with.
|
90
|
+
"""
|
91
|
+
|
87
92
|
if (
|
88
93
|
not isinstance(consumed, dict)
|
89
94
|
and "file" not in consumed
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -64,9 +64,11 @@ class MigratorWorker(WorkerBase):
|
|
64
64
|
to handle the mining of dataset to test.
|
65
65
|
"""
|
66
66
|
|
67
|
-
STD_NAME: str = "pyfunceble_migrator_worker"
|
68
|
-
|
69
67
|
def run(self) -> None:
|
68
|
+
"""
|
69
|
+
This is the brain of the worker.
|
70
|
+
"""
|
71
|
+
|
70
72
|
try:
|
71
73
|
try:
|
72
74
|
self.target(self.continuous_integration, db_session=self.db_session)
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -71,8 +71,6 @@ class MinerWorker(WorkerBase):
|
|
71
71
|
the mining of dataset to test.
|
72
72
|
"""
|
73
73
|
|
74
|
-
STD_NAME: str = "pyfunceble_miner_worker"
|
75
|
-
|
76
74
|
INACTIVE_STATUSES: Tuple[str, ...] = (
|
77
75
|
PyFunceble.storage.STATUS.down,
|
78
76
|
PyFunceble.storage.STATUS.invalid,
|
@@ -123,6 +121,13 @@ class MinerWorker(WorkerBase):
|
|
123
121
|
return result
|
124
122
|
|
125
123
|
def target(self, consumed: Tuple[dict, CheckerStatusBase]) -> None:
|
124
|
+
"""
|
125
|
+
The producer of the worker.
|
126
|
+
|
127
|
+
:param consumed:
|
128
|
+
The consumed data to work with.
|
129
|
+
"""
|
130
|
+
|
126
131
|
if not isinstance(consumed, tuple) or not isinstance(
|
127
132
|
consumed[1], CheckerStatusBase
|
128
133
|
):
|
@@ -155,7 +160,7 @@ class MinerWorker(WorkerBase):
|
|
155
160
|
|
156
161
|
print_single_line("M")
|
157
162
|
|
158
|
-
self.
|
163
|
+
self.push_to_output_queues("pyfunceble")
|
159
164
|
self.share_waiting_message()
|
160
165
|
mined = self.mine_from(subject)
|
161
166
|
|
@@ -184,7 +189,7 @@ class MinerWorker(WorkerBase):
|
|
184
189
|
)
|
185
190
|
continue
|
186
191
|
|
187
|
-
self.
|
192
|
+
self.push_to_output_queues(to_send)
|
188
193
|
|
189
194
|
# Returning None because we manually add into the queue.
|
190
195
|
return None
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -85,8 +85,6 @@ class ProducerWorker(WorkerBase):
|
|
85
85
|
the production of output to stdout or files.
|
86
86
|
"""
|
87
87
|
|
88
|
-
STD_NAME: str = "pyfunceble_producer_worker"
|
89
|
-
|
90
88
|
stdout_printer: Optional[StdoutPrinter] = None
|
91
89
|
file_printer: Optional[FilePrinter] = None
|
92
90
|
whois_dataset: Optional[WhoisDatasetBase] = None
|
@@ -104,7 +102,9 @@ class ProducerWorker(WorkerBase):
|
|
104
102
|
PyFunceble.storage.STATUS.invalid,
|
105
103
|
)
|
106
104
|
|
107
|
-
def
|
105
|
+
def perform_external_poweron_checks(self) -> None:
|
106
|
+
result = super().perform_external_poweron_checks()
|
107
|
+
|
108
108
|
skip_columns = []
|
109
109
|
extra_formatters = {}
|
110
110
|
|
@@ -137,7 +137,7 @@ class ProducerWorker(WorkerBase):
|
|
137
137
|
|
138
138
|
self.header_already_printed = False
|
139
139
|
|
140
|
-
return
|
140
|
+
return result
|
141
141
|
|
142
142
|
@staticmethod
|
143
143
|
def should_we_ignore(test_result: CheckerStatusBase) -> bool:
|
@@ -177,7 +177,7 @@ class ProducerWorker(WorkerBase):
|
|
177
177
|
"""
|
178
178
|
Checks if we should block the file printer.
|
179
179
|
|
180
|
-
The reason
|
180
|
+
The reason behind this is that we don't want to generate an output
|
181
181
|
when a subject was already into the inactive database.
|
182
182
|
"""
|
183
183
|
|
@@ -303,7 +303,7 @@ class ProducerWorker(WorkerBase):
|
|
303
303
|
Runs the analytic behind the file printer.
|
304
304
|
|
305
305
|
.. warning::
|
306
|
-
Thie method assume that the
|
306
|
+
Thie method assume that the given dataset is ignored from the normal
|
307
307
|
file printer.
|
308
308
|
"""
|
309
309
|
|
@@ -388,6 +388,13 @@ class ProducerWorker(WorkerBase):
|
|
388
388
|
).count(test_result.registrar)
|
389
389
|
|
390
390
|
def target(self, consumed: Any) -> Optional[Tuple[Any, ...]]:
|
391
|
+
"""
|
392
|
+
The producer of the worker.
|
393
|
+
|
394
|
+
:param consumed:
|
395
|
+
The consumed data to work with.
|
396
|
+
"""
|
397
|
+
|
391
398
|
if not isinstance(consumed, tuple):
|
392
399
|
PyFunceble.facility.Logger.info(
|
393
400
|
"Skipping latest dataset because consumed data was not a tuple."
|
@@ -399,7 +406,7 @@ class ProducerWorker(WorkerBase):
|
|
399
406
|
|
400
407
|
if not isinstance(test_dataset, dict):
|
401
408
|
PyFunceble.facility.Logger.info(
|
402
|
-
"Skipping because test dataset is not a
|
409
|
+
"Skipping because test dataset is not a dictionary."
|
403
410
|
)
|
404
411
|
return None
|
405
412
|
|