diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4102250..d0de4bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,6 @@ fail_fast: true exclude: ^docs repos: - - repo: https://github.com/PyCQA/flake8 - rev: '6.1.0' - hooks: - - id: flake8 - additional_dependencies: - - flake8-docstrings - - flake8-sfs - # SFS101: String literal formatting using percent operator. - # SFS201: String literal formatting using .format method. - # SFS301: String literal formatting using f-string. - args: [--max-line-length=120, --extend-ignore=SFS3 D107 D100 D104 D401 D412 SFS101 SFS201] - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -39,6 +27,18 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace + - repo: https://github.com/PyCQA/flake8 + rev: '6.1.0' + hooks: + - id: flake8 + additional_dependencies: + - flake8-docstrings + - flake8-sfs + # SFS101: String literal formatting using percent operator. + # SFS201: String literal formatting using .format method. + # SFS301: String literal formatting using f-string. + args: [--max-line-length=120, --extend-ignore=SFS3 D107 D100 D104 D401 D412 SFS101 SFS201] + - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/doc_gen/index.rst b/doc_gen/index.rst index eae7180..468772f 100644 --- a/doc_gen/index.rst +++ b/doc_gen/index.rst @@ -19,6 +19,20 @@ Main Module :members: :undoc-members: +Logger +====== + +.. automodule:: pystream.logger + :members: + :undoc-members: + +Utils +===== + +.. automodule:: pystream.utils + :members: + :undoc-members: + Models ====== Authenticator @@ -35,13 +49,6 @@ Config :members: :exclude-members: _abc_impl, model_config, model_fields -Filters -======= - -.. automodule:: pystream.models.filters - :members: - :undoc-members: - Ngrok ===== diff --git a/docs/_sources/index.rst.txt b/docs/_sources/index.rst.txt index eae7180..468772f 100644 --- a/docs/_sources/index.rst.txt +++ b/docs/_sources/index.rst.txt @@ -19,6 +19,20 @@ Main Module :members: :undoc-members: +Logger +====== + +.. automodule:: pystream.logger + :members: + :undoc-members: + +Utils +===== + +.. automodule:: pystream.utils + :members: + :undoc-members: + Models ====== Authenticator @@ -35,13 +49,6 @@ Config :members: :exclude-members: _abc_impl, model_config, model_fields -Filters -======= - -.. automodule:: pystream.models.filters - :members: - :undoc-members: - Ngrok ===== diff --git a/docs/genindex.html b/docs/genindex.html index 0e4c863..5cae456 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -45,6 +45,7 @@

Index

| E | F | G + | H | I | L | M @@ -92,12 +93,8 @@

F

@@ -107,9 +104,13 @@

G

  • get_dir_content() (in module pystream.models.squire)
  • get_favicon() (in module pystream.routers.basics) +
  • +
  • get_local_ip() (in module pystream.utils)
  • +

    H

    + + +
    +

    I

    @@ -192,6 +203,13 @@

    P

  • password (pystream.models.config.EnvConfig attribute)
  • + pystream.logger + +
  • +
  • pystream.main @@ -275,7 +293,7 @@

    R

  • diff --git a/docs/index.html b/docs/index.html index baa1264..3af8209 100644 --- a/docs/index.html +++ b/docs/index.html @@ -80,6 +80,79 @@

    Stream-Localhost - A secured interface to stream videos + +
    +

    Logger

    +
    +
    +class pystream.logger.RootFilter(name='')
    +

    Class to initiate / filter in logs while preserving other access logs.

    +
    >>> RootFilter
    +
    +
    +
    +

    See also

    +
      +
    • Filters "GET /login HTTP/1.1" 200 OK, "GET / HTTP/1.1" 307 Temporary Redirect, /video?vid_name=...

    • +
    • Includes redundant logging for each iterable passed in StreamingResponse

    • +
    • Overrides logging by implementing a subclass of logging.Filter

    • +
    • The method filter(record), that examines the log record and returns True to log it or False to discard it.

    • +
    +
    +

    Initialize a filter.

    +

    Initialize with the name of the logger which, together with its +children, will have its events allowed through the filter. If no +name is specified, allow every event.

    +
    +
    +filter(record: LogRecord) bool
    +

    Filter out logging at / from log streams.

    +
    +
    Parameters:
    +

    recordLogRecord represents an event which is created every time something is logged.

    +
    +
    Returns:
    +

    False flag for the endpoint that needs to be filtered.

    +
    +
    Return type:
    +

    bool

    +
    +
    +
    + +
    + +
    +
    +

    Utils

    +
    +
    +pystream.utils.get_local_ip() IPv4Address
    +

    Uses simple check on network id to retrieve the local IP address.

    +
    +
    Returns:
    +

    Private IP address of host machine.

    +
    +
    Return type:
    +

    IPv4Address

    +
    +
    +
    + +
    +
    +pystream.utils.get_public_ip() IPv4Address
    +

    Extract public IP address of the connection by making a request to external source.

    +
    +
    Returns:
    +

    Public IP address of host machine’s connection.

    +
    +
    Return type:
    +

    IPv4Address

    +
    +
    +
    +

    Models

    @@ -108,7 +181,7 @@

    Models

    Config

    -class pystream.models.config.EnvConfig(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, username: str, password: str, video_source: Path, video_port: int = 8000, website: Optional[Url] = None, ngrok_token: Optional[str] = None, video_host: IPv4Address = '127.0.0.1', workers: int = 1)
    +class pystream.models.config.EnvConfig(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, username: str, password: SecretStr, video_source: Path, video_port: int = 8000, website: Optional[Url] = None, ngrok_token: Optional[str] = None, video_host: IPv4Address = '127.0.0.1', workers: int = 1)

    Configure all env vars and validate using pydantic to share across modules.

    >>> EnvConfig
     
    @@ -125,7 +198,7 @@

    Models
    -password: str
    +password: SecretStr

    @@ -177,6 +250,11 @@

    Modelsextra = 'ignore'

    +
    +
    +hide_input_in_errors = True
    +
    + @@ -254,83 +332,6 @@

    Models

    alias of EnvConfig

    -

    -
    -

    Filters

    -
    -
    -class pystream.models.filters.VideoFilter(name='')
    -

    Class to initiate /video filter in logs while preserving other access logs.

    -
    >>> VideoFilter
    -
    -
    -
    -

    See also

    -
      -
    • Overrides logging by implementing a subclass of logging.Filter

    • -
    • The method filter(record), that examines the log record and returns True to log it or False to discard it.

    • -
    -
    -

    Initialize a filter.

    -

    Initialize with the name of the logger which, together with its -children, will have its events allowed through the filter. If no -name is specified, allow every event.

    -
    -
    -filter(record: LogRecord) bool
    -

    Filter out logging at /video from log streams.

    -
    -
    Parameters:
    -

    recordLogRecord represents an event which is created every time something is logged.

    -
    -
    Returns:
    -

    False flag for the endpoint that needs to be filtered.

    -
    -
    Return type:
    -

    bool

    -
    -
    -
    - -
    - -
    -
    -class pystream.models.filters.RootFilter(name='')
    -

    Class to initiate / filter in logs while preserving other access logs.

    -
    >>> RootFilter
    -
    -
    -
    -

    See also

    -
      -
    • Overrides logging by implementing a subclass of logging.Filter

    • -
    • The method filter(record), that examines the log record and returns True to log it or False to discard it.

    • -
    -
    -

    Initialize a filter.

    -

    Initialize with the name of the logger which, together with its -children, will have its events allowed through the filter. If no -name is specified, allow every event.

    -
    -
    -filter(record: LogRecord) bool
    -

    Filter out logging at / from log streams.

    -
    -
    Parameters:
    -

    recordLogRecord represents an event which is created every time something is logged.

    -
    -
    Returns:
    -

    False flag for the endpoint that needs to be filtered.

    -
    -
    Return type:
    -

    bool

    -
    -
    -
    - -
    -

    Ngrok

    @@ -608,10 +609,11 @@

    Table of Contents