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.
PyFunceble.cli.tool()[source]

Provides the CLI.

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, each PyFunceble.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.

dispatch_url_file_test(url_file_path, generate_results_only, generate_all_results_only)[source]

Dispatches to the brain in charge of url file testing.

Parameters:
  • url_file_path (str) – The file to test.
  • generate_results_only (bool) – Tell us to only regenerate from the data stored into the MariaDB/MySQL databases.

ExecutionTime()

class PyFunceble.cli.execution_time.ExecutionTime(action='start', last=False)[source]

Sets and returns the execution time of the program.

Parameters:
  • action (str) – The action related the execution time. Can be start or stop.
  • last (bool) – Tell the subsystem if we are at the very end of the file testing.
classmethod authorization()[source]

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:
  • start (int, str) – A starting time.
  • stop (int, str) – A ending time.
Returns:

A dict with following as index.

  • days
  • hours
  • minutes
  • seconds

as index.

Return type:

dict

format_execution_time(start=None, end=None)[source]

Formats the calculated time into a human readable format.

Parameters:
  • start (int, str) – A starting time.
  • stop (int, str) – A ending time.
Returns:

A human readable date.

Return type:

str

save(last=False)[source]

Saves the current time to our backup file.

Parameters:last (bool) – Tell us if we are at the very end of the file testing.
classmethod set_starting_time()[source]

Sets the starting time.

classmethod set_stoping_time()[source]

Sets the ending time.