Code Documentation¶
Logic representation¶
Don’t have time to review the code and want to know exactly what PyFunceble does in general? This flowchart is there for you!
Note
This is a simplified version of what we do.
Note
The diagrams were generated with the help of yEd Graph Editor.
Domain testing¶
IP testing¶
URL testing¶
Check¶
Problematic¶
How can we efficiently check the syntax of IP, domains, and URL?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the syntax checker interface.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
-
class
PyFunceble.check.
Check
(subject)[source]¶ Provides our syntax checkers.
Parameters: subject (str) – The subject (URL, IP or domain) to check. -
SPECIAL_USE_DOMAIN_NAMES_EXTENSIONS
= ['onion']¶ Specifies the extension which are specified as “Special-Use Domain Names” and supported by our project.
Type: list See also
- RFC6761
- IANA Special-Use Domain Names assignments.
- RFC7686
-
is_domain
(subdomain_check=False)[source]¶ Checks if the given subject is a valid domain.
Parameters: subdomain_check (bool) – Activates the subdomain checking.
Returns: The validity. Return type: bool
-
is_ip
()[source]¶ Checks if the given subject is a valid IPv4 or IPv6.
Returns: The validity. Return type: bool
-
is_ip_range
()[source]¶ Checks if the given subject is a valid IPv4 or IPv6 range.
Returns: The validity. Return type: bool
-
is_ipv4
()[source]¶ Checks if the given subject is a valid IPv4.
Returns: The validity. Return type: bool
-
is_ipv4_range
()[source]¶ Checks if the given subject is a valid IPv4 range.
Returns: The validity. Return type: bool
-
is_ipv6
()[source]¶ Checks if the given subject is a valid IPv6.
Returns: The validity. Return type: bool
-
is_ipv6_range
()[source]¶ Checks if the given subject is a valid IPv6 range.
Returns: The validity. Return type: bool
-
is_reserved_ip
()[source]¶ Checks if the given subject is a reserved IPv4 or IPv6.
Returns: The validity. Return type: bool
-
is_reserved_ipv4
()[source]¶ Checks if the given subject is a reserved IPv4.
Note
This method has been written on basis of the following links:
Returns: The validity. Return type: bool
-
is_reserved_ipv6
()[source]¶ Checks if the given subject is a reserved IPv6.
Returns: The validity. Return type: bool
-
is_subdomain
()[source]¶ Checks if the given subject is a valid subdomain.
Returns: The validity. Return type: bool
-
Exceptions¶
Problematic¶
How can we provide our very own exceptions ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides our exceptions.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
-
exception
PyFunceble.exceptions.
ConfigurationFileNotFound
[source]¶ Describes a missing configuration file.
-
exception
PyFunceble.exceptions.
NoConversionMade
[source]¶ Describes the fact that a conversion was expected but none was made.
-
exception
PyFunceble.exceptions.
NoDownloadDestinationGiven
[source]¶ Describes the fact that the download destination was not declared.
-
exception
PyFunceble.exceptions.
NoDownloadLinkGiven
[source]¶ Describes the fact that no download link was declared.
-
exception
PyFunceble.exceptions.
NoExtractionMade
[source]¶ Describes the fact that an extraction was expected but none was made.
-
exception
PyFunceble.exceptions.
PleaseUpdatePyFunceble
[source]¶ Describes the impossiblity to continue with an older version.
-
exception
PyFunceble.exceptions.
PyFuncebleExternalException
[source]¶ Describes an exception which is caused by an external input.
-
exception
PyFunceble.exceptions.
PyFuncebleInternalException
[source]¶ Describes an exception which is caused by our own logic.
-
exception
PyFunceble.exceptions.
UnknownSubject
[source]¶ Describes the fact that an unknown subject is inputed.
-
exception
PyFunceble.exceptions.
UserAgentBrowserNotFound
[source]¶ Describes the fact that we could not find a valid browser to work with.
-
exception
PyFunceble.exceptions.
UserAgentNotFound
[source]¶ Describes the fact that we could not find a user agent to work with.
Abstracts¶
Problematic¶
How can we work with abstracted data and information which are not directly related to our project main logic?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the abtracted logics/data.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
Infrastructure()
¶
-
class
PyFunceble.abstracts.infrastructure.
Infrastructure
[source]¶ Provides some infrastructure related abstractions.
-
CI_MIGRATION_TRIGGER_FILE
= '.trigger'¶ Sets the name of the file to write into for the case that we are migrating to sqlalchemy from inside a CI engine.
Type: str
-
CONFIGURATION_FILENAME
= '.PyFunceble.yaml'¶ Sets the name of the user editable configuration file.
Type: str
-
DEFAULT_CONFIGURATION_FILENAME
= '.PyFunceble_production.yaml'¶ Sets the name of the default configuration file.
Type: str
-
DOWN_FILENAME
= '.pyfunceble_intern_downtime.json'¶ Sets the name of our own download time record file.
Type: str
-
HASHES_FILENAME
= 'hashes_tracker.json'¶ Sets the name of the file which will save the hashes of the files we are testing.
-
IPV4_REPUTATION_FILENAME
= 'ipv4_reputation.data'¶ Sets the name of our own copy of the IPv4 reputation data file.
Type: str
-
PROD_CONFIG_LINK
= 'https://raw.githubusercontent.com/funilrys/PyFunceble/master/.PyFunceble_production.yaml'¶ Sets the link to the production configuration file.
Type: str
-
USER_AGENT_FILENAME
= 'user_agents.json'¶ Sets the name of our own copy of the user agents file.
-
Package()
¶
Platform()
¶
-
class
PyFunceble.abstracts.platform.
Platform
[source]¶ Provides an easy way to get the current platform.
-
WINDOWS
= ['windows', 'cygwin', 'cygwin_nt-10.0']¶ Provides the list of supported windows platform.
Type: list
-
Version()
¶
-
class
PyFunceble.abstracts.package.
Version
[source]¶ Provides a simple way to compare our own versions.
-
classmethod
compare
(upstream)[source]¶ Compares the given versions with the local one.
Parameters: Returns: True
: local < upstreamNone
: local == upstreamFalse
: local > upstream
Return type:
-
classmethod
literally_compare
(local, upstream)[source]¶ Compares the given versions, literally.
Parameters: Returns: True
: local == upstreamFalse
: local != upstream
Return type:
-
classmethod
CLI¶
Problematic¶
How can we easily work and distribute some CLI related logic?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the CLI entry points.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
Dispatcher()
¶
-
class
PyFunceble.cli.dispatcher.
Dispatcher
(preset, domain_or_ip=None, file_path=None, url_file_path=None, url_to_test=None, generate_results_only=False, generate_all_results_only=False)[source]¶ Dispatches to one of the other brain.
Note
We are talking about
brain
because, eachPyFunceble.core.*
is a unique brain which has it’s own function ;-)Sometimes, 2 brains depends from the other one. But that’s great because working together is always great ;-)
Parameters: - preset (
Preset
) – An instance of the configuration preset. - domain_or_ip (list) – A list of subject to test.
- file_path (str) –
A file path or a link.
Note
If a file path is given, we read and test its content.
Note
If a link is given, we download it’s content and test it.
Warning
If given, we consider each line to be an adblock filter, a host file format or a subject to test.
- url_file_path (str) –
A file path or a link.
Note
If a file path is given, we read and test its content.
Note
If a link is given, we download it’s content and test it.
Warning
If given, we consider each line to be a URL to test.
- url_to_test (str) – A list of URL to test.
-
classmethod
dispatch_file_test
(file_path, generate_results_only, generate_all_results_only)[source]¶ Dispatches to the brain in charge of file testing.
Parameters: - file_path (str) – The file path to test.
- generate_results_only (bool) – Tell us to only regenerate from the data stored into the MariaDB/MySQL databases.
- generate_all_results_only (bool) –
Tell us to only regenerate from the data stored into the MariaDB/MySQL databases.
Note
The difference with
generate_results_only
is that it includes the retested which status didn’t changed.
- preset (
ExecutionTime()
¶
-
class
PyFunceble.cli.execution_time.
ExecutionTime
(action='start', last=False)[source]¶ Sets and returns the execution time of the program.
Parameters: Checks the execution authorization.
Returns: The authorization status. Return type: bool
-
classmethod
calculate
(start=None, end=None)[source]¶ Calculates the difference between starting and ending time.
Parameters: Returns: A dict with following as index.
days
hours
minutes
seconds
as index.
Return type:
-
format_execution_time
(start=None, end=None)[source]¶ Formats the calculated time into a human readable format.
Parameters: Returns: A human readable date.
Return type:
Config¶
Problematic¶
- How can we make personalization more simple?
- How can we automatically merge the new configuration with the local one?
- How can we link some configuration endpoints with the real logic.
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the configuration logics.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
Load()
¶
Merge()
¶
Preset()
¶
-
class
PyFunceble.config.preset.
Preset
[source]¶ Checks or update the global configuration based on some events.
-
classmethod
_Preset__are_we_allowed_to_overwrite
(index)¶ Checks if we are allowed to overwrite an index.
-
classmethod
maximal_processes
()[source]¶ Ensures that the number of maximal processes is alway >= 2. If not, we don’t authorize the multiprocessing.
-
classmethod
switch
(variable, custom=False)[source]¶ Switches
PyFunceble.CONFIGURATION
variables to their opposite.Parameters: - variable (str|bool) – The variable name to switch. The variable should be an index our configuration system. If we want to switch a bool variable, we should parse it here.
- custom (bool) – Let us know if have to switch the parsed variable instead of our configuration index.
Returns: The opposite of the configuration index or the given variable.
Return type: Raises: Exception
When the configuration is not valid. In other words, if the PyFunceble.CONFIGURATION[variable_name] is not a bool.
-
classmethod
Converter¶
Problematic¶
How can we convert some data into something else or something our system understand.
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the converters.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
ConverterBase()
¶
AdBlock()
¶
-
class
PyFunceble.converter.adblock.
AdBlock
(data_to_convert, aggressive=False)[source]¶ Converts an adblock filter line to a list os subject to test.
-
_AdBlock__decode_v1
(data)¶ Decodes the v1.
Parameters: data (str) – A string to decode. Return type: list
-
_AdBlock__decode_v2
(data)¶ Decodes the v2.
Parameters: data (str) – A string to decode. Return type: list
-
_AdBlock__decode_v3
(data)¶ Decodes the v3.
Parameters: data (str) – A string to decode. Return type: list
-
_AdBlock__decode_v4
(data)¶ Decodes the v4.
Parameters: data (str) – A string to decode. Return type: list
-
extract_base
(subject)[source]¶ Extracts the base of the given element.
- As an example:
- given
"hello.world/?is=beautiful"
returns"hello.world"
Parameters: subject – The subject to work with.
-
extract_from_options
(options)[source]¶ Exctracts the relevant data from the list of options.
Parameters: options (list) – The list of options of a rule. Returns: The list of domains. Return type: list
-
format_decoded
(decoded, result=None)[source]¶ Formats the extracted adblock line in order to be compatible with what the system understand.
Parameters: Returns: The list of domains or IP compatible with the system.
Return type:
-
Digit2Digits()
¶
File()
¶
InternalUrl()
¶
-
class
PyFunceble.converter.internal_url.
InternalUrl
(data_to_convert)[source]¶ Converter of the internal URLs.
Note
The internal URLs are actually the URL that has nothing to do with what we are going to test.
They are only relevant for the software itself.
Parameters: data_to_convert (str) – The data to convert
Core¶
Problematic¶
How can we get started?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the core interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
APICore()
¶
-
class
PyFunceble.core.api.
APICore
(subject, complete=False, configuration=None, db_file_name='api_call', is_parent=True)[source]¶ Provides the logic and interface for the tests from the API.
Parameters: -
_APICore__inactive_database_management
(subject, status)¶ Given the subject and status, we add or remove the subject from the inactive database.
-
availability
(subject_type)[source]¶ Make an availability check.
Parameters: subject_type (str) – Should be one of the following.
domain
url
-
reputation
(subject_type)[source]¶ Make a reputation check.
Parameters: subject_type (str) – Should be one of the following.
domain
url
-
CLICore()
¶
-
class
PyFunceble.core.cli.
CLICore
[source]¶ Provides some methods which are dedicated for the CLI.
-
classmethod
_CLICore__check_deprecated
(upstream_version)¶ Checks if the local version is deprecated.
-
classmethod
_CLICore__check_force_update
(upstream_version)¶ Checks if we need to force the update.
If it’s the case, we will stop the tool.
-
classmethod
_CLICore__print_messages
(upstream_version)¶ Looks at the messages and prints the one that needs to be printed.
-
classmethod
colorify_logo
(home=False)[source]¶ Print the colored logo based on global results.
Parameters: home (bool) – Tell us if we have to print the initial coloration.
-
classmethod
compare_version_and_print_messages
()[source]¶ Compares the local with the upstream version.
-
classmethod
get_simple_coloration
(status)[source]¶ Given a status we give the coloration for the simple mode.
Parameters: status (str) – An official status output.
-
classmethod
logs_sharing
()[source]¶ Prints an information message when the logs sharing is activated.
-
classmethod
FileCore()
¶
-
class
PyFunceble.core.file.
FileCore
(file, file_content_type='domain')[source]¶ Brain of PyFunceble for file testing.
Parameters: -
_FileCore__run_single_test
(subject, ignore_inactive_db_check=False)¶ Run a test for a single subject.
-
_FileCore__test_line
(line, ignore_inactive_db_check=False)¶ Tests a given line.
-
cleanup
(auto_continue_db, auto_save, test_completed=False)[source]¶ Runs the logic to run at the end of all test.
-
construct_and_get_shadow_file
(file_stream, ignore_inactive_db_check=False)[source]¶ Provides a path to a file which contain the list to file.
The idea is to do a comparison between what we already tested and what we still have to test.
-
classmethod
download_link
(input_file)[source]¶ Downloads the file if it is an URL and return the name of the new file to test.
-
generate_files_of_status
(status, include_entries_without_changes=False)[source]¶ Generates the status file of all subjects of the given status.
Parameters:
-
post_test_treatment
(test_output, file_content_type, complements_test_started=False, auto_continue_db=None, inactive_db=None, mining=None, whois_db=None)[source]¶ Do the post test treatment.
-
OurProcessWrapper()
¶
-
class
PyFunceble.core.multiprocess.
OurProcessWrapper
(*args, **kwargs)[source]¶ Wrapper of Process. The object of this class is just to overwrite
Process.run()
in order to catch exceptions.Note
This class takes the same arguments as
Process
.-
exception
¶ Provides a way to check if an exception was send.
-
MultiprocessCore()
¶
-
class
PyFunceble.core.multiprocess.
MultiprocessCore
(file, file_content_type='domain')[source]¶ Brain of PyFunceble for file testing with multiple processes.s.
Parameters: -
_MultiprocessCore__check_exception
(processes, manager_data)¶ Checks if an exception is present into the given pool of processes.
:param list processes. A list of running processes.
-
_MultiprocessCore__merge_processes_data
(manager_data, tracker=None)¶ Reads all results and put them at the right location.
-
_MultiprocessCore__process_end_merging
(finished, manager_data, tracker)¶ Processes the end merging.
-
_MultiprocessCore__process_live_merging
(finished, manager_data, tracker)¶ Processes the live merging.
-
_MultiprocessCore__run_multiprocess_test
(stream, manager, ignore_inactive_db_check=False, tracker=None)¶ Tests the content of the given file.
-
_MultiprocessCore__start_process
(subject, manager_data, ignore_inactive_db_check=False)¶ Starts a new process.
-
construct_and_get_shadow_file
(file_stream, ignore_inactive_db_check=False)[source]¶ Provides a path to a file which contain the list to file.
The idea is to do a comparison between what we already tested and what we still have to test.
-
SimpleCore()
¶
Database¶
Problematic¶
How can we store our most relevant information?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the database interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
InactiveDB()
¶
-
class
PyFunceble.database.inactive.
InactiveDB
(filename, parent_process=False)[source]¶ Provides the inactive database logic and interface.
Parameters: filename (str) – The name of the file we are processing. -
_merge
()[source]¶ Merges the database with the older one which has already been set into the database.
Provides the execution authorization.
-
classmethod
datetime
()[source]¶ Gets the timestamp where we are going to save our current list.
Returns: The timestamp to append with the currently tested element. Return type: int|str
-
WhoisDB()
¶
-
class
PyFunceble.database.whois.
WhoisDB
(parent_process=False)[source]¶ Provides the WHOIS database interface and logic.
-
add
(subject, expiration_date, server, record=None)[source]¶ Adds the given subject and expiration date to the database.
Parameters:
Provides the operation authorization.
-
get_expiration_date
(subject)[source]¶ Gets the expiration date of the given subject.
Parameters: subject (str) – The subject we are working with. Returns: The expiration date from the database. Return type: tuple
-
is_time_older
(subject)[source]¶ Checks if the expiration time of the given subject is older.
Parameters: subject (str) – The subject we are working with. Note
Of course, we imply that the subject is in the database.
-
Downloader¶
Problematic¶
How can we easily download one of our static files ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the downloaders of all our static files.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
DownloaderBase()
¶
-
class
PyFunceble.downloader.base.
DownloaderBase
[source]¶ Provides the downloader base.
-
get_downtime
()[source]¶ Provides the download timestamp of the current
DOWN_TIME_INDEX
.Return type: dict, None
-
ConfigDownloader()
¶
DirectoryStructureDownloader()
¶
IANADownloader()
¶
IPv4ReputationDownloader()
¶
Engine¶
Problematic¶
- How to auto continue?
- How to auto save?
- How to implement a proper debugger?
- How to get subjects related to a tested subject?
- How to work with different database types?
- How to sort our outputs?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the engine interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
AutoContinue()
¶
-
class
PyFunceble.engine.auto_continue.
AutoContinue
(filename, parent_process=False)[source]¶ Provides the auto-continue subsystem.
-
_AutoContinue__generate_complements
()¶ Generates the complements from the given list of tested.
-
_AutoContinue__get_or_generate_complements_json
()¶ Gets or generates the complements while working with as JSON formatted database.
-
_AutoContinue__get_or_generate_complements_mysql
()¶ Gets or generates the complements while working with as MySQL/MariaDB formatted database.
Provides the execution authorization.
-
AutoSave()
¶
Logger()
¶
-
class
PyFunceble.engine.logger.
Logger
(debug=False, on_screen=False, output_directory=None)[source]¶ Provides our logging logic.
-
_Logger__get_handler
(handler_type)¶ Provides a handler for of the given type.
-
_Logger__init_loggers
()¶ Initiates all loggers.
-
_Logger__set_output_directory
(output_directory)¶ Shares the given output directory.
Note
If the given output directory does not exists, we create it.
Parameters: output_directory (string) – The output directory.
Provides the operation authorization.
-
format_to_apply
= '[%(asctime)s::%(levelname)s::%(origin_path)s:%(origin_line)s@%(origin_func)s](PID%(process)s:%(processName)s): %(message)s'¶ The format to apply.
-
classmethod
get_origin_info
()[source]¶ Returns the information about where the logger was triggered.
Returns: A tuple, which is composed of the following. (trigger file path, trigger line, trigger function/method name)
Return type: tuple
-
root_logger_format
= '[%(asctime)s::%(levelname)s](PID%(process)s:%(processName)s): %(message)s'¶ The format to parse to the root logger (if used).
-
Mining()
¶
-
class
PyFunceble.engine.mining.
Mining
(filename, parent_process=False)[source]¶ Manages the minig subsystem.
Provides the operation authorization.
-
classmethod
get_history
(url, verify=None)[source]¶ Gets the history of the given url.
Parameters: url (str) – An URL to call. Returns: The list of links. Return type: list
-
list_of_mined
()[source]¶ Provides the list of mined domains so that they can be tested.
Returns: The list of mined domains. The returned format is the following:
[ (index_to_delete_after_test, mined), (index_to_delete_after_test, mined), (index_to_delete_after_test, mined) ]
Return type: list
-
mine
(subject, subject_type)[source]¶ Searches for domain or URL related to the original URL or domain. If some are found, we add them into the database.
Parameters:
Sort()
¶
-
class
PyFunceble.engine.sort.
Sort
[source]¶ Provides some sorting presets which we can parse to
PyFunceble.helpers.list.List.custom_format
.-
classmethod
_Sort__get_url_base
(element)¶ Provides the URL base if needed.
-
classmethod
hierarchical
(element)[source]¶ The idea behind this method is to sort a list of domain hierarchically.
Parameters: element (str) – The element we are currently reading. Returns: The formatted element. Return type: str Note
For a domain like
aaa.bbb.ccc.tdl
.A normal sorting is done in the following order:
aaa
bbb
ccc
tdl
This method allow the sorting to be done in the following order:
tdl
ccc
bbb
aaa
-
classmethod
Extractor¶
Problematic¶
How can we extract data from other data?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the extractors.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
ExtractorBase()
¶
ExpirationDate()
¶
-
class
PyFunceble.extractor.expiration_date.
ExpirationDate
(data)[source]¶ Provides a way to extract the expiration date from a given WHOIS record.
Parameters: data (str) – The WHOIS record.s -
_ExpirationDate__extract_it
()¶ Try to extract the expiration date from the given data.
-
_ExpirationDate__format_it
(data)¶ Formats the given data.
-
_ExpirationDate__format_management
(index, matched)¶ A format management helper.
Note
Please note that the second value of the case represent the groups in order
[day,month,year]
.This means that a
[2,1,0]
will be for example for a date in format2017-01-02
where01
is the month.Parameters: Returns: A list representing the expiration date. The list can be “decoded” like
[day, month, year]
Return type: list|None
-
Helpers¶
Problematic¶
How can we avoid writing the same thing every time?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the helpers.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
Command()
¶
-
class
PyFunceble.helpers.
Command
(command, encoding='utf-8')[source]¶ Shell command execution.
Parameters: -
_decode_output
(to_decode)[source]¶ Decode the output of a shell command in order to be readable.
Parameters: to_decode (bytes) – Output of a command to decode. Returns: The decoded output. Return type: str
-
run
(rstrip=True)[source]¶ Run the given command and yield each line(s) one by one.
Note
The difference between this method and
execute()
is thatexecute()
wait for the process to end in order to return its output while this method return each line one by one - as they are outputed.Parameters: rstrip (bool) – Deactivates the rstrip of the output.
-
Dict()
¶
-
class
PyFunceble.helpers.
Dict
(main=None)[source]¶ Simplify some
dict
manipulation.Parameters: main (dict) – The main dict
to work with.Raises: TypeError – When main
is not a dict nor a list (tolarated).-
classmethod
from_json
(json_str, return_dict_on_error=True)[source]¶ Converts a given JSON string to dict/list.
Parameters: return_dict_on_error (bool) – Return a dict instead of a NoneType. Return type: dict|list
-
classmethod
from_json_file
(file_path, encoding='utf-8', return_dict_on_error=True)[source]¶ Reads the given file path and convert it’s content to dict/list (tolarated).
Parameters: Return type: dict|list
-
classmethod
from_yaml
(yaml_str)[source]¶ Converts the given YAML string to dict/list.
Parameters: yaml_str (str) – The YAML string to convert. Return type: dict|list
-
classmethod
from_yaml_file
(file_path, encoding='utf-8')[source]¶ Converts a given YAML formatted file, into dict/list.
Parameters: Return type: dict|list
-
has_same_keys_as
(to_check, loop=False)[source]¶ A dirty solution which checks keys are presents in both given
dict
.Parameters: Return type:
-
remove_key
(key_to_remove)[source]¶ Remove a given key from a given dictionary.
Parameters: key_to_remove (list|str) – The key(s) to delete. Returns: The dict without the given key(s). Return type: dict|None
-
rename_key
(key_to_rename, strict=True)[source]¶ Rename the given keys from the given dictionary.
Parameters: Returns: The well formatted dict.
Return type: dict|None
-
to_json
(ensure_ascii=False, indent=4, sort_keys=True)[source]¶ Converts a given dict to JSON and return the json string.
Parameters: Return type:
-
to_json_file
(file_path, ensure_ascii=False, indent=4, sort_keys=True, encoding='utf-8')[source]¶ Converts the given
dict
to JSON and save the result into a given file path.Parameters:
-
to_yaml
(encoding='utf-8', default_flow_style=False, indent=4, allow_unicode=True, sort_keys=True)[source]¶ Converts the given dict/list to the YAML format and return the result.
Parameters: Return type: dict|list
-
classmethod
Directory()
¶
-
class
PyFunceble.helpers.
Directory
(dir_path=None)[source]¶ Simplify the directories manipulation.
:param str dir_path the path to work with.
-
create
(dir_path=None)[source]¶ Creates the given directory path.
Returns: The output of self.exists
after the directory creation.Return type: bool
-
delete
(dir_path=None)[source]¶ Deletes the given directory path.
Returns: not self.exists
after the directory deletion.Rtypt: bool
-
Download()
¶
-
class
PyFunceble.helpers.
Download
(url, verify_certificate=True, retry=3)[source]¶ Simplification of the downloads.
Parameters: -
text
(destination=None)[source]¶ Download the body of the given url.
Note
if
destination
is set toNone
, we only return the output.Otherwise, we save the output into the given destination, but we also return the output.
Parameters: destination (str) – The download destination.
Return type: str:
Raises: - Exception – When the status code is not 200.
- NoInternetConnection – When no connection could be made.
-
File()
¶
-
class
PyFunceble.helpers.
File
(file_path=None)[source]¶ Simplify the file manipulations.
Parameters: file_path (str) – The file path to work with. -
copy
(destination)[source]¶ Copy the globaly given file path to the given destination.
Parameters: destination (str) – The destination of the copy.
-
delete
(file_path=None)[source]¶ Deletes the given file path if it exists.
Parameters: file_path (str) – The file path to check.
Note
If
None
is given, we report to the globally given file path.Returns: The non existance state of the file. Return type: bool
-
exists
(file_path=None)[source]¶ Checks if the given file path exists.
Parameters: file_path (str) – The file path to check.
Note
If
None
is given, we report to the globally given file path.Return type: bool
-
get_size
(file_path=None)[source]¶ Provides the size (in bytes) of the given file path.
Parameters: file_path (str) – The file path to check.
Note
If
None
is given, we report to the globally given file path.Return type: int
-
move
(destination)[source]¶ Move the globally given file path to the given destination.
Parameters: destination (str) – The destination of the file.
-
read
(file_path=None, encoding='utf-8')[source]¶ Read the given file path and return it’s content.
Parameters: Return type:
-
Hash()
¶
-
class
PyFunceble.helpers.
Hash
(algo='sha512_224')[source]¶ Simplify the hashing of data or file content.
Parameters: algo (str) – The algorithm to use for hashing. Raises: ValueError – When the given algo is not known.
List()
¶
-
class
PyFunceble.helpers.
List
(main, remove_empty=False)[source]¶ Simplify the list manipulation.
Parameters: -
custom_format
(key_method, reverse=False)[source]¶ Return a well formatted list. With the key_method as a function/method to format the elements before sorting.
Parameters: - key_method (function|method) – A function or method to use to format the readed element before sorting.
- reverse (bool) – Tell us if we have to reverse the list.
Returns: A sorted list.
Return type:
-
Merge()
¶
-
class
PyFunceble.helpers.
Merge
(main)[source]¶ Simplify the merging of dict and list.
Parameters: main (str, tuple, bool, int, dict, list, float) – The main data to work with. -
_Merge__dict
(origin, strict=True)¶ Process the dict merging.
Parameters: strict (bool) – Activates the strict mode. Return type: dict
-
Regex()
¶
-
class
PyFunceble.helpers.
Regex
(regex, escape=False)[source]¶ Simplify the regex matching and usage.
Parameters: -
get_matching_list
(data)[source]¶ Returns the strings which does the match the regex in the given data.
-
get_not_matching_list
(data)[source]¶ Returns the strings which does not the match the regex in the given data.
-
match
(data, rematch=False, group=0, return_match=True)[source]¶ Checks if the given data match the given regex string.
Parameters:
-
Lookup¶
Problematic¶
How can we look for information about a given subject ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the lookup interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
DNSLookup()
¶
-
class
PyFunceble.lookup.dns.
DNSLookup
(dns_server=None, lifetime=3, tcp=False)[source]¶ DNS lookup interface.
Parameters: -
_DNSLookup__get_dns_servers_from
(inputed_dns)¶ Given a list or an input representing dns servers, we ensure that we have a list of a string which represent an IP.
Parameters: input (str, list, tuple) – The inputed DNS server(s). Returns: The list of dns server to use. Return type: list
-
classmethod
_DNSLookup__get_resolver
(dns_server)¶ Provides the configured dns resolver.
-
_DNSLookup__request_complete_not_ip
(subject, tcp=None)¶ Requests and provides the complete DNS spectrum.
Return type: dict
-
_DNSLookup__request_ip
(subject, tcp=None)¶ Handle the request for a subject which is an IP.
Parameters: Return type: Raises: ValueError – When a non string
subject
is given.
-
_DNSLookup__request_not_ip
(subject, complete=False, tcp=None)¶ Handle the request for a subject which is not an IP.
Return type: dict Raises: ValueError – When a non string subject
is given.
-
_get_server_and_port_from
(inputed_dns)[source]¶ Given a list or an input representing dns server, we split the server from the port.
Parameters: inputed_dns – The inputed DNS server(s). Returns: A tuple with: (The DNS, the port)
Return type: tuple
-
a_record
(subject, tcp=None)[source]¶ Return the A record of the given subject (if found).
Parameters: Returns: A list of A record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
aaaa_record
(subject, tcp=None)[source]¶ Return the AAAA record of the given subject (if found).
Parameters: Returns: A list of A record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
cname_record
(subject, tcp=None)[source]¶ Return the CNAME record of the given subject (if found).
Parameters: Returns: A list of CNAME record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
dname_record
(subject, tcp=None)[source]¶ Return the DNAME record of the given subject (if found).
Parameters: Returns: A list of DNAME record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
classmethod
get_addr_info
(subject)[source]¶ Get and return the information of the given subject (address).
Parameters: subject (str) – The subject we are working with. Returns: A list of address. Return type: list, None Raises: ValueError – When a non string subject
is given.
-
classmethod
get_host_by_addr
(subject)[source]¶ Get and return the host of the given subject (address).
Parameters: subject (str) – The subject we are working with. Returns: A dict in the following format or None
.{ "hostname": "", "aliases": [], "ips": [] }
Return type: dict, None Raises: ValueError – When a non string subject
is given.
-
classmethod
is_record_present_in_result
(to_check, result, allow_empty=False)[source]¶ Checks if the given record type is in the result.
Parameters: Return type:
-
mx_record
(subject, tcp=None)[source]¶ Return the MX record of the given subject (if found).
Parameters: subject (str) – The subject we are working with. Returns: A list of MX record(s). Return type: list, None Raises: ValueError – When a non string subject
is given.
-
ns_record
(subject, tcp=None)[source]¶ Return the NS record of the given subject (if found).
Parameters: Returns: A list of NS record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
ptr_record
(subject, reverse_name=True, tcp=None)[source]¶ Return the PTR record of the given subject (if found).
Parameters: Returns: A list of PTR record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
request
(subject, complete=False, tcp=None)[source]¶ Perform a DNS lookup/requests.
Parameters: Returns: A dict with following index if the given subject is not registered into the given DNS server. (More likely local subjects).
{ "hostname": "", "aliases": [], "ips": [] }
A dict with following index for everything else (and if found).
{ "nameservers: [], "A": [], "AAAA": [], "CNAME": [], "DNAME": [], "MX": [], "NS": [], "TXT": [], "PTR": [] }
Return type: Raises: ValueError – When a non string
subject
is given.
-
txt_record
(subject, tcp=None)[source]¶ Return the TXT record of the given subject (if found).
Parameters: Returns: A list of TXT record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
HTTPCode()
¶
-
class
PyFunceble.lookup.http_code.
HTTPCode
(subject, subject_type)[source]¶ Get and return the HTTP code status of a given domain.
Parameters: - subject (str) – The subject we are working with.
- _type (subject) –
The type of the subject we are working with. Should be one of the following.
url
domain
file_url
file_domain
ipv6
Iana()
¶
PublicSuffix()
¶
Referer()
¶
-
class
PyFunceble.lookup.referer.
Referer
(subject)[source]¶ Get the WHOIS server (referer) of the current domain extension according to the IANA database.
Parameters: subject (str) – The subject we are working with. -
get
()[source]¶ Return the referer aka the WHOIS server of the current domain extension.
Returns: - [0]
None
if there is no referer. - [0]
False
if the extension is unknown which implicitly means - that the subject is
INVALID
- [0]
- [0]
str
The resolved IP to use. - [1]
str
,None
the domain referer.
Return type: tuple - [0]
-
HostSSLAdapter()
¶
-
class
PyFunceble.lookup.requests.
HostSSLAdapter
(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)[source]¶ Extends the build-in HTTP Adapter for urllib3 for our needs.
-
_HostSSLAdapter__resolve_with_cache
(hostname)¶ Resolve the IP of the given hostname.
Parameters: hostname (str) – The hostname to resolve. Returns: The IP of the host name or the hostname itself. Return type: None, str
-
classmethod
resolve
(hostname)[source]¶ Resolve the IP of the given hostname.
Parameters: hostname (str) – The hostname to resolve. Returns: The IP of the host name or the hostname itself. Return type: None, str
-
send
(request, **kwargs)[source]¶ Overwrite the upstream :code:send` method.
We basically do the same. We only ensure that we request the IP from the chosen DNS record.
Parameters: - request – The
PreparedRequest
being sent. - stream – (optional) Whether to stream the request content.
- timeout (float or tuple or urllib3 Timeout object) – (optional) How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
- verify – (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use
- cert – (optional) Any user-provided SSL certificate to be trusted.
- proxies – (optional) The proxies dictionary to apply to the request.
Return type: - request – The
-
HostAdapter()
¶
-
class
PyFunceble.lookup.requests.
HostAdapter
(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)[source]¶ Extends the build-in HTTP Adapter for urllib3 for our needs.
-
_HostAdapter__resolve_with_cache
(hostname)¶ Resolve the IP of the given hostname.
Parameters: hostname (str) – The hostname to resolve. Returns: The IP of the host name or the hostname itself. Return type: None, str
-
send
(request, **kwargs)[source]¶ Overwrite the upstream :code:send` method.
We basically do the same. We only ensure that we request the IP from the chosen DNS record.
Parameters: - request – The
PreparedRequest
being sent. - stream – (optional) Whether to stream the request content.
- timeout (float or tuple or urllib3 Timeout object) – (optional) How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
- verify – (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use.
- cert – (optional) Any user-provided SSL certificate to be trusted.
- proxies – (optional) The proxies dictionary to apply to the request.
Return type: - request – The
-
IPv4Reputation
¶
Requests()
¶
-
class
PyFunceble.lookup.requests.
Requests
(max_retries=None)[source]¶ Handles all usage of
requests
.Parameters: url (str) – The URL to work with. -
delete
(url, **kwargs)[source]¶ Sends a DELETE request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
exceptions
= <module 'requests.exceptions' from '/home/docs/checkouts/readthedocs.org/user_builds/pyfunceble/envs/3.3.3/lib/python3.7/site-packages/requests/exceptions.py'>¶
-
get
(url, **kwargs)[source]¶ Sends a GET request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
head
(url, **kwargs)[source]¶ Sends a HEAD request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
options
(url, **kwargs)[source]¶ Sends a OPTIONS request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
patch
(url, **kwargs)[source]¶ Sends a PATCH request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
post
(url, **kwargs)[source]¶ Sends a POST request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
Output¶
Problematic¶
How can we generate or work with outputs ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the output related interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
Clean()
¶
-
class
PyFunceble.output.clean.
Clean
(clean_all=False, file_path=None)[source]¶ Provide the cleaning logic.
Note
By cleaning we mean the cleaning of the
output
directory.Parameters: - list_to_test (list|None) – The list of domains we are testing.
- clean_all (bool) – Tell the subsystem if we need to clean all. Which include, of course, the output directory but also all other file(s) generated by our system.
- file_path (str) –
The path to the file we tested.
Note
This is only relevant if you use the MariaDB/MySQL database.
Constructor()
¶
-
class
PyFunceble.output.constructor.
Constructor
(production=False)[source]¶ Basically a backup/reconstructor of our
output
directory.Parameters: production (bool) – Tell the subsystem if we are preparing for production which imply the execution of the backup insteam of of the “reconstructore” mode. -
classmethod
_create_directory
(directory, loop=False)[source]¶ Creates the given directory if it does not exists.
Parameters:
-
_get_structure
()[source]¶ Get the structure we are going to work with.
Returns: The structure we have to work with. Return type: dict
-
_restore_replace
()[source]¶ Check if we need to replace “.gitignore” to “.keep”.
Returns: The replacement status. Return type: bool
-
_update_structure_from_config
(structure)[source]¶ Update the paths according to configs.
Parameters: structure (dict) – The read structure.
-
classmethod
Generate()
¶
-
class
PyFunceble.output.generate.
Generate
(subject, subject_type, status, source=None, expiration_date=None, http_status_code=None, whois_server='Unknown', filename=None, ip_validation=False, end=False)[source]¶ Generate different sort of files.
Parameters: - subject (str) – The subject we are working with.
- subject_type (str) – The type of the subject.
- status (str) – The catched status.
- source (str) – The source of the given status.
- expiration_date (str) – The expiration date of the domain (if catched).
- http_status_code (str|int) – The HTTP status code.
- whois_server (str) – The whois server.
- filename (str) – The name of the file we are testing.
- ip_validation (bool) – The IP validation check of the currently written subject.
-
_Generate___get_info_files_destinations
(output_hosts, output_domains, output_json)¶ Given the output directory, this method return several paths.
Note
The given output directories have to be partially completed.
Indeed, we only do
output % final_location
.Returns: The following paths: ( hosts_destination, plain_destination, json_destination, splited_destination )
Return type: tuple
Provide the authorization for the generation of info files.
Basically here is what we check:
- We are not testing as an imported module.
and
- The hosts file generation is activated.
or
- The plain list generation is activated.
or
- The “api_file_generation” was set into the CONFIGURATION.
-
_analytic_host_file_directory
()[source]¶ Return the analytic directory to write depending of the matched status.
-
analytic_file
(new_status, old_status=None)[source]¶ Generate
Analytic/*
files based on the given old and new statuses.Parameters:
-
file_production
¶ Check if we are allowed to produce a file based from the given information.
Returns: The state of the production. True: We do not produce file. False: We do produce file. Return type: bool
-
info_files
()[source]¶ Generate the hosts file, the plain list, the JSON file and the splitted files.
Logs()
¶
-
class
PyFunceble.output.logs.
Logs
(output=None)[source]¶ Provide a clean and unique way to work with logs. Indeed, it’s not good to have logs spread around the code :smile:
Parameters: output (str) – A path to the JSON file we are going to write. -
classmethod
_get_content
(file)[source]¶ Get and return the content of the given log file.
Parameters: file (str) – The file we have to get the content from. :return The content of the given file. :rtype: dict
-
classmethod
_write_content
(content, file)[source]¶ Write the content into the given file.
Parameters:
-
classmethod
Percentage()
¶
Prints()
¶
-
class
PyFunceble.output.prints.
Prints
(to_print, template, output_file=None, only_on_file=False)[source]¶ Print data on screen and into a file if needed. Template Possibilities: Percentage, Less, HTTP and any status you want.
Parameters: -
_Prints__get_print_size
()¶ Provides the size of the element to print.
-
_colorify
(data)[source]¶ Retun colored string.
Parameters: data (str) – The string to colorify. Returns: A colored string. Return type: str
-
classmethod
_size_from_header
(header)[source]¶ Get the size of each columns from the header.
Parameters: header (dict) – The header template we have to get the size from. Returns: The maximal size of the each data to print. Return type: list
-
before_header
()[source]¶ Print informations about PyFunceble and the date of generation of a file into a given path, if doesn’t exist.
-
data
()[source]¶ Management and input of data to the table.
Raises: Exception
When self.data_to_print is not a list.
-
data_constructor
(size)[source]¶ Construct the table of data according to given size.
Parameters: size (list) – The maximal length of each string in the table.
Returns: A dict with all information about the data and how to which what maximal size to print it.
Return type: OrderedDict
Raises: Exception
If the data and the size does not have the same length.
-
header
(do_not_print=False)[source]¶ Management and creation of templates of header. Please consider as “header” the title of each columns.
Parameters: do_not_print (bool) – Tell us if we have to print the header or not.
-
Status¶
Problematic¶
How can we gather, manage and provide a status for a given subject ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the status interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020 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
http://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.
GathererBase()
¶
Status()
¶
-
class
PyFunceble.status.status.
Status
(subject)[source]¶ The status object.
Provides the result of one of the status gatherer.
Parameters: subject (str) – The subject which we describe.
Variables: - _status_source (str) – The status source before the application of our extra rules (if activated).
- _status (str) – The status before the application of our extra rules (if activated).
- dns_lookup (list) – The result of the DNS Lookup logic.
- domain_syntax_validation (bool) – The domain syntax validation status.
- expiration_date (str) – The expiration date of the subject.
- http_status_code (str) – The HTTP status code of the subject.
- ipv4_range_syntax_validation (bool) – The IPv4 range validation status.
- ipv4_syntax_validation (bool) – The IPv4 syntax validation status.
- ipv6_range_syntax_validation (bool) – The IPv6 range validation status.
- ipv6_syntax_validation (bool) – The IPv6 syntax validation status.
- status_source (str) – The final status source.
- status (str) – The final status.
- subdomain_syntax_validation (bool) – The subdomain syntax validation status.
- tested (str) – The tested subject.
- url_syntax_validation (bool) – The URL syntax validation status.
- whois_server (str) – The WHOIS server we contact-ed to get the WHOIS record.
- whois_record (str) – The WHOIS record.
Availability: DomainAndIp()
¶
-
class
PyFunceble.status.availability.domain_and_ip.
DomainAndIp
(subject, filename=None, whois_db=None, inactive_db=None)[source]¶ Gather the availability of the given IP or Domain.
-
_DomainAndIp__gather
()¶ Process the gathering.
-
_DomainAndIp__gather_expiration_date
()¶ Gather the expiration date.
-
_DomainAndIp__gather_extra_rules
()¶ Handle the lack of WHOIS record.
-
Availability: ExtraRules()
¶
-
class
PyFunceble.status.availability.extra_rules.
ExtraRules
(subject, subject_type, http_status_code)[source]¶ Manage some extra rules.,
Parameters: -
_ExtraRules__blogspot
()¶ Handle the blogspot SPECIAL case.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_http_code
(previous_state)¶ Handle the HTTP Code status escalation.
Parameters: previous_state (str) – The previously catched status. Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_ip_range
()¶ Handle the IP range status escalation.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_potentially_inactive
(previous_state)¶ Handle the potentially inactive case.
Parameters: previous_state (str) – The previously catched status. Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_potentially_up
()¶ Handle the potentially up case.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_reputation
()¶ Handle the reputation escalation.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
classmethod
_ExtraRules__http_status_code_up
()¶ Set what we return for the HTTP Code status escalation.
Returns: (new status, new source)
Return type: tuple
-
classmethod
_ExtraRules__special_down
()¶ Set what we return for the SPECIAL status de-escalation.
Returns: (new status, new source)
Return type: tuple
-
_ExtraRules__special_down_404
()¶ Set what we return for the SPECIAL status de-escalation when the 404 status code is caught.
Returns: (new status, new source)
Return type: tuple
-
_ExtraRules__special_down_410
()¶ Set what we return for the SPECIAL status de-escalation when the 410 status code is caught.
Returns: (new status, new source)
Return type: tuple
-
classmethod
_ExtraRules__special_up
()¶ Set what we return for the SPECIAL status escalation.
Returns: (new status, new source)
Return type: tuple
-
_ExtraRules__wordpress_dot_com
()¶ Handle the wordpress.com SPECIAL case.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-