__init__ (version 3.0.12)
index
__init__.py

This tool runs CLI scripts and displays output in a Web Interface.

 
Classes
       
builtins.object
WebScripts.Server
utils.DefaultNamespace(types.SimpleNamespace)
WebScripts.Configuration

 
class Configuration(utils.DefaultNamespace)
    Configuration(required: List[str] = [], optional: List[str] = [], default: dict = {}, types: dict = {})
 
This class build the configuration from dict(s) with
configuration files and arguments.
 
 
Method resolution order:
Configuration
utils.DefaultNamespace
types.SimpleNamespace
builtins.object

Methods defined here:
add_conf(self, **kwargs)
Add configurations from other configuration files found.

Data and other attributes defined here:
__defaults__ = {'accept_unauthenticated_user': True, 'accept_unknow_user': True, 'active_auth': False, 'auth_failures_to_blacklist': None, 'auth_script': None, 'cgi_path': [], 'documentations_path': [], 'exclude_auth_pages': ['/api/', '/auth/', '/web/auth/'], 'exclude_auth_paths': ['/static/', '/js/'], 'force_file_permissions': True, ...}
__optional__ = ('debug', 'security', 'active_auth', 'auth_script', 'accept_unknow_user', 'accept_unauthenticated_user', 'exclude_auth_paths', 'exclude_auth_pages', 'modules', 'modules_path', 'js_path', 'statics_path', 'documentations_path', 'scripts_path', 'json_scripts_config', 'ini_scripts_config', 'log_level', 'log_filename', 'log_level', 'log_format', ...)
__required__ = ('interface', 'port')
__types__ = {'accept_unauthenticated_user': <class 'bool'>, 'accept_unknow_user': <class 'bool'>, 'active_auth': <class 'bool'>, 'admin_adresses': <class 'list'>, 'admin_groups': typing.List[int], 'auth_failures_to_blacklist': <class 'int'>, 'blacklist_time': <class 'int'>, 'csrf_max_time': <class 'int'>, 'debug': <class 'bool'>, 'documentations_path': <class 'list'>, ...}

Methods inherited from utils.DefaultNamespace:
__getitem__(self, key: str)
Compatibility with dict.
__init__(self, required: List[str] = [], optional: List[str] = [], default: dict = {}, types: dict = {})
Initialize self.  See help(type(self)) for accurate signature.
build_type(self, attribut: str, value: Any, type_: type = None) -> None
This function builds type from configuration value.
build_types(self) -> None
This function builds type from configuration values.
check_required(self) -> None
This function checks required attributes
if one of required attributes is missing this
function raise MissingAttributesError.
export_as_json(self, name: str = None) -> None
This function export namespace values (useful for debugging).
get(self, key: str, default=None)
Compatibility with dict.
get_dict(self) -> None
This function return a dict of attributes.
get_missings(self) -> List[str]
This function checks required attributes
and return a List[str] of missing required attributes.
get_unexpecteds(self, log: bool = True) -> List[str]
This function return a List[str] of
all attributes not in optional and
required attributes.
 
If log argument is True a Warning log message is
write for all unexpected attributes.
set_defaults(self) -> None
This function set defaults attribut with defaults values.
update(self, **kwargs)
This function add/update attributes with **kwargs arguments.

Class methods inherited from utils.DefaultNamespace:
default_build(**kwargs) -> ~DefaultNamespace from builtins.type
Default build for DefaultNamespace (set defaults, add values,
check requirements and unexpected values and build types).

Data descriptors inherited from utils.DefaultNamespace:
__weakref__
list of weak references to the object (if defined)

Methods inherited from types.SimpleNamespace:
__delattr__(self, name, /)
Implement delattr(self, name).
__eq__(self, value, /)
Return self==value.
__ge__(self, value, /)
Return self>=value.
__getattribute__(self, name, /)
Return getattr(self, name).
__gt__(self, value, /)
Return self>value.
__le__(self, value, /)
Return self<=value.
__lt__(self, value, /)
Return self<value.
__ne__(self, value, /)
Return self!=value.
__reduce__(...)
Return state information for pickling
__repr__(self, /)
Return repr(self).
__setattr__(self, name, value, /)
Implement setattr(self, name, value).

Static methods inherited from types.SimpleNamespace:
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.

Data descriptors inherited from types.SimpleNamespace:
__dict__

Data and other attributes inherited from types.SimpleNamespace:
__hash__ = None

 
class Server(builtins.object)
    Server(configuration: WebScripts.Configuration)
 
This class implements the WebScripts server.
 
  Methods defined here:
__init__(self, configuration: WebScripts.Configuration)
Initialize self.  See help(type(self)) for accurate signature.
add_module_or_package(self) -> None
This function add packages and modules to build custom page.
add_paths(self) -> None
This function add js, static and scripts paths.
app(self, environ_: os._Environ, respond: method) -> List[bytes]
This function get function page,
return content page, catch errors and
return HTTP errors.
check_auth(self, environ: os._Environ) -> Tuple[commons.User, bool]
This function check if user is authenticated and blacklisted.
check_blacklist(self, user: commons.User, ip: str) -> bool
This function checks that the IP and the
username are not in the blacklist.
get_URLs(self) -> List[str]
This function return a list of urls (scripts, documentation...)
and the start of the URL of custom packages.
get_function_page(self, path: str, filename: str) -> Tuple[~FunctionOrNone, str, bool]
This function find function from URL path.
If the function is a WebScripts built-in function,
return the function, filename and True. Else return the
function, filename and False.
get_session(self, cookies: List[str], ip: str) -> commons.User
This function return User from cookies.
page_400(self, environ: os._Environ, user: commons.User, filename: str, method: str, respond: method)
This function return error 400 web page.
page_401(self, environ: os._Environ, user: commons.User, filename: str, error_description: str, respond: method)
This function return error 401 web page.
page_403(self, environ: os._Environ, user: commons.User, filename: str, error_description: str, respond: method)
This function return error 403 web page.
page_404(self, environ: os._Environ, user: commons.User, filename: str, url: str, respond: method)
This function return error 404 web page.
page_406(self, environ: os._Environ, user: commons.User, filename: str, error_description: str, respond: method)
This function return error 406 web page.
page_500(self, environ: os._Environ, user: commons.User, filename: str, error: Union[str, bytes, Iterable[bytes]], respond: method) -> List[bytes]
This function return error 500 web page.
parse_body(self, environ: os._Environ) -> Tuple[~Content, str, bool]
This function returns arguments from body.
return_inputs(self, arguments: List[Dict[str, ~JsonValue]], is_webscripts_request: bool) -> Tuple[List[str], List[str]]
This function returns inputs (using Server.get_inputs).
send_custom_error(self, environ: os._Environ, user: commons.User, filename: str, error: str, code: str) -> Tuple[str, Dict[str, str], str]
This function call custom errors pages.
send_error_page(self, environ: os._Environ, user: commons.User, filename: str, error: str, data: bytes, respond: method) -> List[bytes]
This function send HTTP errors.
send_headers(self, environ: os._Environ, respond: method, error: str = None, headers: Dict[str, str] = None) -> None
This function send error code, message and headers.
set_default_values_for_response(self, error: str, headers: Dict[str, str]) -> Tuple[str, Dict[str, str]]
This function returns default error if not defined and
default headers updated with custom headers.

Static methods defined here:
check_origin(environ_getter: collections.abc.Callable, environ: os._Environ) -> bool
This function checks Origin of POST methods.
get_attributes(object_: object, attributes: List[str], is_not_package: bool = True) -> Tuple[~FunctionOrNone, bool]
This function get recursive attribute from object.
get_baseurl(environ_getter: collections.abc.Callable, environ: os._Environ) -> str
This function returns URL base.
get_content_length(environ: os._Environ) -> int
This function returns the content length.
get_fullurl(environ: os._Environ) -> str
This function returns the full URL (based on the PEP 3333).
 
Link: https://peps.python.org/pep-3333/
get_inputs(arguments: List[Dict[str, ~JsonValue]]) -> Tuple[List[str], List[str]]
This function returns inputs and arguments from arguments.
get_json_content(body: bytes, content_type: str) -> ~JsonValue
This functions returns the loaded JSON content.
return_page(page: Union[bytes, str, Iterable[bytes]]) -> List[bytes]
This function returns response as a list of bytes.
set_default_headers(headers: Dict[str, str], security: bool, configuration: WebScripts.Configuration) -> None
This function sets defaults headers.
try_get_command(body: Dict[str, ~JsonValue]) -> Optional[Tuple[~Content, str, bool]]
This function returns arguments, CSRF token and True if is WebScripts
request. If is not a WebScripts request because there's no "arguments"
section in request content, this function returns None. If an error
is raised in arguments parser, this function returns the JSON
content, None and False.
use_basic_auth(credentials: str, pages: Pages.Pages, *args) -> Tuple[str, Dict[str, str], str]
This function decodes basic auth and
authenticates user with it.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
CommonsClasses = <class 'WebScripts.Server.CommonsClasses'>

 
Functions
       
main() -> int
Main function to build the
configurations and launch the server.

 
Data
        __all__ = ['Configuration', 'Server', 'main']
__author_email__ = 'mauricelambert434@gmail.com'
__copyright__ = '\nWebScripts Copyright (C) 2021, 2022, 2023 Mau...ome to redistribute it\nunder certain conditions.\n'
__description__ = 'This tool runs CLI scripts and displays output in a Web Interface.'
__license__ = 'GPL-3.0 License'
__maintainer__ = 'Maurice Lambert'
__maintainer_email__ = 'mauricelambert434@gmail.com'
__url__ = 'https://github.com/mauricelambert/WebScripts'

 
Author
        Maurice Lambert