From 14960aa5b649150862cd5774aa5eb573259dcb54 Mon Sep 17 00:00:00 2001 From: MountainGod2 Date: Tue, 17 Dec 2024 00:25:34 +0000 Subject: [PATCH] deploy: 987a0f7501396a2839da035e0e2c4610fac3ade5 --- .../chaturbate_poller/chaturbate_client.html | 9 +- _modules/chaturbate_poller/event_handler.html | 3 - .../chaturbate_poller/logging_config.html | 112 +--------- _modules/chaturbate_poller/main.html | 193 ++++-------------- .../chaturbate_poller/signal_handler.html | 6 +- _modules/chaturbate_poller/utils.html | 14 +- .../logging_config/index.rst.txt | 61 +----- .../chaturbate_poller/main/index.rst.txt | 46 +---- .../chaturbate_poller/utils/index.rst.txt | 11 + .../logging_config/index.html | 95 +-------- autoapi/chaturbate_poller/main/index.html | 72 +------ autoapi/chaturbate_poller/utils/index.html | 14 ++ genindex.html | 48 +---- objects.inv | Bin 2327 -> 2232 bytes searchindex.js | 2 +- 15 files changed, 111 insertions(+), 575 deletions(-) diff --git a/_modules/chaturbate_poller/chaturbate_client.html b/_modules/chaturbate_poller/chaturbate_client.html index f86c718d..2df7e5a7 100644 --- a/_modules/chaturbate_poller/chaturbate_client.html +++ b/_modules/chaturbate_poller/chaturbate_client.html @@ -90,9 +90,7 @@

Source code for chaturbate_poller.chaturbate_client

) from chaturbate_poller.influxdb_handler import InfluxDBHandler from chaturbate_poller.logging_config import ( - generate_correlation_id, sanitize_sensitive_data, - set_correlation_id, ) from chaturbate_poller.models import EventsAPIResponse from chaturbate_poller.utils import ChaturbateUtils @@ -128,9 +126,6 @@

Source code for chaturbate_poller.chaturbate_client

verbose: bool = False, ) -> None: """Initialize the client.""" - correlation_id = generate_correlation_id() - set_correlation_id(correlation_id) - if verbose: logger.setLevel(logging.DEBUG) if not username or not token: @@ -145,8 +140,6 @@

Source code for chaturbate_poller.chaturbate_client

logger.debug("Using testbed environment.") else: self.base_url = DEFAULT_BASE_URL - - logger.info("Initializing ChaturbateClient for user: %s", username) self.timeout = timeout self.username = username self.token = token @@ -208,7 +201,7 @@

Source code for chaturbate_poller.chaturbate_client

exception=httpx.HTTPStatusError, giveup=lambda retry: not ChaturbateUtils.need_retry(retry), on_giveup=ChaturbateUtils.giveup_handler, - max_tries=6, + max_tries=ChaturbateUtils.get_max_tries, on_backoff=ChaturbateUtils.backoff_handler, logger=None, raise_on_giveup=False, diff --git a/_modules/chaturbate_poller/event_handler.html b/_modules/chaturbate_poller/event_handler.html index f66ab6b2..773773b6 100644 --- a/_modules/chaturbate_poller/event_handler.html +++ b/_modules/chaturbate_poller/event_handler.html @@ -82,7 +82,6 @@

Source code for chaturbate_poller.event_handler

< from chaturbate_poller.format_messages import format_message from chaturbate_poller.influxdb_handler import InfluxDBHandler -from chaturbate_poller.logging_config import generate_correlation_id, set_correlation_id from chaturbate_poller.models import Event logger = logging.getLogger(__name__) @@ -150,8 +149,6 @@

Source code for chaturbate_poller.event_handler

< Args: event (Event): The event to be logged. """ - correlation_id = generate_correlation_id() - set_correlation_id(correlation_id) logger.debug("Handling event for logging: %s", event.method) message = await format_message(event) logger.info(message)
diff --git a/_modules/chaturbate_poller/logging_config.html b/_modules/chaturbate_poller/logging_config.html index c3e650b7..de829cba 100644 --- a/_modules/chaturbate_poller/logging_config.html +++ b/_modules/chaturbate_poller/logging_config.html @@ -77,14 +77,9 @@

Source code for chaturbate_poller.logging_config

 """Logging configuration for the chaturbate_poller package."""
 
-import contextvars
 import logging
 import logging.config
-import os
 import re
-import uuid
-from datetime import datetime
-from pathlib import Path
 from typing import Any
 
 from dateutil import tz
@@ -95,28 +90,7 @@ 

Source code for chaturbate_poller.logging_config

TOKEN_REGEX = re.compile(r"token=[^&]+") # Timezone setup for log timestamps -timezone_name = tz.gettz(os.getenv("TZ", "America/Edmonton")) -log_timestamp = datetime.now(tz=timezone_name).strftime("%Y-%m-%d_%H-%M-%S") -log_filename = f"logs/{log_timestamp}.log" # Convert to string for compatibility - - -correlation_id_var = contextvars.ContextVar("correlation_id", default="N/A") - - -
-[docs] -def generate_correlation_id() -> str: - """Generate a unique correlation ID.""" - return str(uuid.uuid4())
- - - -
-[docs] -def set_correlation_id(correlation_id: str) -> None: - """Set the correlation ID in the context.""" - correlation_id_var.set(correlation_id)
- +timezone_name = tz.gettz("America/Edmonton")
@@ -130,21 +104,6 @@

Source code for chaturbate_poller.logging_config

-
-[docs] -class CorrelationIDFilter(logging.Filter): - """Filter to add the correlation ID to log records.""" - -
-[docs] - def filter(self, record: logging.LogRecord) -> bool: - """Add the correlation ID to the log record.""" - record.correlation_id = correlation_id_var.get() - return True
-
- - -
[docs] class SanitizeSensitiveDataFilter(logging.Filter): @@ -178,43 +137,15 @@

Source code for chaturbate_poller.logging_config

extra["level"] = record.levelname extra["name"] = record.name extra["time"] = self.formatTime(record, self.datefmt) - extra["correlation_id"] = getattr(record, "correlation_id", "N/A") return extra
-
-[docs] -class CustomFormatter(logging.Formatter): - """Custom log formatter for detailed logs.""" - -
-[docs] - def format(self, record: logging.LogRecord) -> str: - """Format the log record. - - Args: - record (logging.LogRecord): The log record. - - Returns: - str: The formatted log record. - """ - record.module = record.module.split(".")[-1] # Simplify module name - return super().format(record)
-
- - - LOGGING_CONFIG: dict[str, Any] = { "version": 1, "disable_existing_loggers": False, "formatters": { - "standard": { - "()": CustomFormatter, # Use CustomFormatter - "format": "%(asctime)s - %(name)s - %(levelname)s - [Correlation ID: %(correlation_id)s] - %(message)s", # noqa: E501 - "datefmt": "%Y-%m-%d %H:%M:%S", - }, "json": { "()": CustomJSONFormatter, "datefmt": "%Y-%m-%d %H:%M:%S", @@ -224,33 +155,18 @@

Source code for chaturbate_poller.logging_config

"sanitize_sensitive_data": { "()": SanitizeSensitiveDataFilter, }, - "correlation_id": { - "()": CorrelationIDFilter, - }, }, "handlers": { "console": { - "class": "rich.logging.RichHandler", - "formatter": "standard", # CustomFormatter applied here - "level": "INFO", - "filters": ["sanitize_sensitive_data", "correlation_id"], - "rich_tracebacks": True, - }, - "file": { - "class": "logging.handlers.RotatingFileHandler", - "filename": log_filename, - "mode": "w", - "encoding": "utf-8", - "backupCount": 5, - "maxBytes": 10485760, + "class": "logging.StreamHandler", "formatter": "json", # Use JSONFormatter for structured logs - "level": "DEBUG", - "filters": ["sanitize_sensitive_data", "correlation_id"], + "level": "INFO", + "filters": ["sanitize_sensitive_data"], }, }, "loggers": { "chaturbate_poller": { - "handlers": ["console", "file"], + "handlers": ["console"], "level": "DEBUG", }, }, @@ -260,24 +176,14 @@

Source code for chaturbate_poller.logging_config

[docs] def setup_logging(*, verbose: bool = False) -> None: - """Set up logging configuration and ensure log directory exists.""" - log_directory = Path("logs") - try: - if not log_directory.exists(): - log_directory.mkdir(parents=True, exist_ok=True) - log_directory.chmod(0o750) # Restrict permissions - except PermissionError as e: - logging.critical("Cannot create or access log directory '%s': %s", log_directory, e) - msg = f"Cannot create or access log directory '{log_directory}': {e}" - raise RuntimeError(msg) from e - + """Set up logging configuration.""" logging.config.dictConfig(LOGGING_CONFIG) logging.captureWarnings(capture=True) if verbose: - root_logger = logging.getLogger() - root_logger.setLevel(logging.DEBUG) - logging.getLogger("chaturbate_poller").setLevel(logging.DEBUG)
+ logging.getLogger("chaturbate_poller").setLevel(logging.DEBUG) + console_handler = logging.getLogger("chaturbate_poller").handlers[0] + console_handler.setLevel(logging.DEBUG)
diff --git a/_modules/chaturbate_poller/main.html b/_modules/chaturbate_poller/main.html index 9b59d98c..55a2f64d 100644 --- a/_modules/chaturbate_poller/main.html +++ b/_modules/chaturbate_poller/main.html @@ -83,13 +83,11 @@

Source code for chaturbate_poller.main

 """
 
 import asyncio
+import logging
 import textwrap
-from pathlib import Path
 
 import rich_click as click
 from rich.console import Console
-from rich.progress import Progress, SpinnerColumn, TextColumn, TimeElapsedColumn
-from rich.prompt import Confirm, Prompt
 from rich.traceback import install
 
 from chaturbate_poller import __version__
@@ -97,7 +95,9 @@ 

Source code for chaturbate_poller.main

 from chaturbate_poller.config_manager import ConfigManager
 from chaturbate_poller.event_handler import EventHandler, create_event_handler
 from chaturbate_poller.exceptions import AuthenticationError, NotFoundError, PollingError
-from chaturbate_poller.logging_config import setup_logging
+from chaturbate_poller.logging_config import (
+    setup_logging,
+)
 from chaturbate_poller.signal_handler import SignalHandler
 
 # Enable detailed and formatted error handling with Rich
@@ -109,88 +109,10 @@ 

Source code for chaturbate_poller.main

 
 @click.group()
 @click.version_option(version=__version__)
-def cli() -> None:  # pragma: no cover
+def cli() -> None:
     """Manage and run the Chaturbate Poller CLI."""
 
 
-@cli.command()
-def setup() -> None:  # pragma: no cover
-    """Interactive setup to generate the .env file.
-
-    This command guides the user through configuring the application by
-    prompting for essential credentials and optional database settings.
-    """
-    console.print("[bold green]Chaturbate Poller Setup[/bold green]")
-    console.print("This setup will help you configure the necessary settings.")
-
-    # Prompt user for essential settings
-    cb_username = Prompt.ask("Enter your Chaturbate username")
-    cb_token = Prompt.ask("Enter your Chaturbate API token", password=True)
-    use_influxdb = Confirm.ask("Would you like to configure InfluxDB?", default=False)
-
-    # Gather configurations into a dictionary
-    config = {"CB_USERNAME": cb_username, "CB_TOKEN": cb_token}
-
-    # Add InfluxDB configurations if enabled
-    if use_influxdb:
-        config.update(_get_influxdb_config())
-
-    # Save the configuration to an .env file
-    _save_env_file(config)
-
-
-
-[docs] -def _get_influxdb_config() -> dict[str, str]: # pragma: no cover - """Prompt for InfluxDB configuration details. - - Returns: - dict[str, str]: A dictionary containing InfluxDB connection details. - """ - console.print("\n[bold cyan]InfluxDB Configuration[/bold cyan]") - influxdb_url = Prompt.ask("Enter your InfluxDB URL", default="http://localhost:8086") - influxdb_token = Prompt.ask("Enter your InfluxDB token", password=True) - influxdb_org = Prompt.ask("Enter your InfluxDB organization") - influxdb_bucket = Prompt.ask("Enter your InfluxDB bucket") - - return { - "INFLUXDB_URL": influxdb_url, - "INFLUXDB_TOKEN": influxdb_token, - "INFLUXDB_ORG": influxdb_org, - "INFLUXDB_BUCKET": influxdb_bucket, - "USE_DATABASE": "true", - }
- - - -
-[docs] -def _save_env_file(config: dict[str, str]) -> None: # pragma: no cover - """Save the provided configuration to a .env file. - - Args: - config (dict[str, str]): Key-value pairs to write to the .env file. - - This function ensures existing configurations are not overwritten without user confirmation. - """ - env_file_path = Path(".env") - if env_file_path.exists() and not Confirm.ask( - f"{env_file_path} already exists. Overwrite?", default=False - ): - console.print("[yellow]Setup aborted. Existing configuration preserved.[/yellow]") - return - - try: - with env_file_path.open("w", encoding="utf-8") as file: - # Write each configuration key-value pair to the file - file.writelines(f'{key}="{value}"\n' for key, value in config.items()) - console.print(f"[bold green]Configuration saved to {env_file_path}[/bold green]") - except OSError as exc: - # Catch file writing errors and display an appropriate message - console.print(f"[red]Error saving configuration: {exc}[/red]")
- - - @cli.command( help=textwrap.dedent( """ @@ -230,13 +152,10 @@

Source code for chaturbate_poller.main

 )
 @click.option("--testbed", is_flag=True, help="Enable testbed mode.")
 @click.option("--verbose", is_flag=True, help="Enable verbose logging.")
-def start(  # pylint: disable=too-many-arguments,too-many-positional-arguments  # noqa: PLR0913  # pragma: no cover
+def start(  # noqa: PLR0913  # pragma: no cover
     username: str, token: str, timeout: int, *, testbed: bool, database: bool, verbose: bool
 ) -> None:
-    """Start the Chaturbate Poller.
-
-    This command initializes the application and runs the main async polling loop.
-    """
+    """Start the Chaturbate Poller."""
     asyncio.run(
         main(
             username=username,
@@ -251,7 +170,7 @@ 

Source code for chaturbate_poller.main

 
 
[docs] -async def main( # pylint: disable=too-many-arguments # noqa: PLR0913 # pragma: no cover +async def main( # noqa: PLR0913 # pragma: no cover username: str, token: str, api_timeout: int, @@ -274,11 +193,21 @@

Source code for chaturbate_poller.main

         verbose (bool): Enable verbose logging.
     """
     setup_logging(verbose=verbose)
-    _validate_inputs(username, token)
 
-    # Determine the appropriate event handler
-    event_handler = create_event_handler("database" if use_database else "logging")
-    console.print(f"[bold green]Starting Chaturbate Poller v{__version__}...[/bold green]")
+    logger = logging.getLogger(__name__)
+
+    # Validate inputs
+    if not username:
+        logger.warning("A username is required.")
+        return
+    if not token:
+        logger.warning("An API token is required.")
+        return
+
+    if use_database:
+        event_handler = create_event_handler("database")
+    else:
+        event_handler = create_event_handler("logging")
 
     stop_future: asyncio.Future[None] = asyncio.Future()
 
@@ -300,40 +229,19 @@ 

Source code for chaturbate_poller.main

             stop_future,
         )
     except AuthenticationError as exc:
-        console.print(f"[red]Authentication Error: {exc}[/red]")
+        logger.error("Authentication Error: %s", exc)  # noqa: TRY400
     except NotFoundError as exc:
-        console.print(f"[red]Not Found Error: {exc}[/red]")
+        logger.error("Not Found Error: %s", exc)  # noqa: TRY400
     except PollingError as exc:
-        console.print(f"[red]Polling Error: {exc}[/red]")
+        logger.error("Polling Error %s", exc)  # noqa: TRY400
     except (asyncio.CancelledError, KeyboardInterrupt):
-        console.print("[yellow]Polling stopped by user request.[/yellow]")
- - - -
-[docs] -def _validate_inputs(username: str, token: str) -> None: # pragma: no cover - """Validate mandatory inputs for running the poller. - - Args: - username (str): Chaturbate username. - token (str): API token. - - Raises: - click.BadParameter: If required inputs are missing. - """ - if not username: - msg = "A username is required." - raise click.BadParameter(msg) - if not token: - msg = "An API token is required." - raise click.BadParameter(msg)
+ logger.debug("Polling stopped by user.")
[docs] -async def start_polling( # pylint: disable=too-many-arguments,too-many-positional-arguments # noqa: PLR0913 # pragma: no cover +async def start_polling( # noqa: PLR0913 # pragma: no cover username: str, token: str, api_timeout: int, @@ -342,7 +250,7 @@

Source code for chaturbate_poller.main

     testbed: bool,
     verbose: bool,
 ) -> None:
-    """Begin polling Chaturbate events with feedback.
+    """Begin polling Chaturbate events.
 
     Args:
         username (str): Chaturbate username.
@@ -359,41 +267,20 @@ 

Source code for chaturbate_poller.main

         testbed=testbed,
         verbose=verbose,
     ) as client:
-        total_events = 0  # Track the total number of processed events
         url = None  # Initialize the URL for event polling
 
-        # Use a rich progress spinner to provide user feedback
-        with Progress(
-            SpinnerColumn(),
-            TextColumn("[progress.description]{task.description}"),
-            TimeElapsedColumn(),
-        ) as progress:
-            task = progress.add_task("[cyan]Polling events...", total=None)
-
-            while True:
-                try:
-                    # Fetch events from the API
-                    response = await client.fetch_events(url)
-                    if not response:
-                        break
-
-                    # Process each event and increment the counter
-                    for event in response.events:
-                        total_events += 1
-                        await event_handler.handle_event(event)
-
-                    # Update the URL for the next fetch cycle
-                    url = str(response.next_url)
-
-                    # Update progress feedback
-                    progress.update(
-                        task,
-                        description=f"[green]{total_events} events processed.",
-                    )
-                except Exception as exc:
-                    # Log and re-raise errors encountered during polling
-                    progress.update(task, description=f"[red]Error: {exc}[/red]")
-                    raise
+ while True: + # Fetch events from the API + response = await client.fetch_events(url) + if not response: + break + + # Process each event + for event in response.events: + await event_handler.handle_event(event) + + # Update the URL for the next fetch cycle + url = str(response.next_url)
diff --git a/_modules/chaturbate_poller/signal_handler.html b/_modules/chaturbate_poller/signal_handler.html index 884fda5d..d6de6027 100644 --- a/_modules/chaturbate_poller/signal_handler.html +++ b/_modules/chaturbate_poller/signal_handler.html @@ -81,8 +81,6 @@

Source code for chaturbate_poller.signal_handler

import logging import signal -from chaturbate_poller.logging_config import generate_correlation_id, set_correlation_id - logger = logging.getLogger(__name__) """logging.Logger: The module-level logger.""" @@ -99,8 +97,6 @@

Source code for chaturbate_poller.signal_handler

loop (asyncio.AbstractEventLoop): The event loop. stop_future (asyncio.Future[None]): The future to set when the signal is received. """ - correlation_id = generate_correlation_id() - set_correlation_id(correlation_id) self.loop = loop self.stop_future = stop_future logger.debug("SignalHandler initialized.") @@ -126,7 +122,7 @@

Source code for chaturbate_poller.signal_handler

Args: sig (signal.Signals): The received signal. """ - logger.info("Received shutdown signal: %s", sig.name) + logger.debug("Received shutdown signal: %s", sig.name) if not self.stop_future.done(): await self._shutdown() diff --git a/_modules/chaturbate_poller/utils.html b/_modules/chaturbate_poller/utils.html index 82466389..11e4b585 100644 --- a/_modules/chaturbate_poller/utils.html +++ b/_modules/chaturbate_poller/utils.html @@ -94,6 +94,18 @@

Source code for chaturbate_poller.utils

 class ChaturbateUtils:
     """Utility functions for the Chaturbate poller."""
 
+
+[docs] + @staticmethod + def get_max_tries() -> int: + """Get the maximum number of tries for polling. + + Returns: + int: The maximum number of tries. + """ + return 6
+ +
[docs] @staticmethod @@ -105,7 +117,7 @@

Source code for chaturbate_poller.utils

         """
         wait = int(details.get("wait", 0))
         tries = int(details.get("tries", 0))
-        logger.info("Backing off %s seconds after %s tries", wait, tries)
+ logger.warning("Backing off %s seconds after %s tries", wait, tries)
diff --git a/_sources/autoapi/chaturbate_poller/logging_config/index.rst.txt b/_sources/autoapi/chaturbate_poller/logging_config/index.rst.txt index a49ea3af..67981937 100644 --- a/_sources/autoapi/chaturbate_poller/logging_config/index.rst.txt +++ b/_sources/autoapi/chaturbate_poller/logging_config/index.rst.txt @@ -17,9 +17,6 @@ Attributes chaturbate_poller.logging_config.URL_REGEX chaturbate_poller.logging_config.TOKEN_REGEX chaturbate_poller.logging_config.timezone_name - chaturbate_poller.logging_config.log_timestamp - chaturbate_poller.logging_config.log_filename - chaturbate_poller.logging_config.correlation_id_var chaturbate_poller.logging_config.LOGGING_CONFIG @@ -28,10 +25,8 @@ Classes .. autoapisummary:: - chaturbate_poller.logging_config.CorrelationIDFilter chaturbate_poller.logging_config.SanitizeSensitiveDataFilter chaturbate_poller.logging_config.CustomJSONFormatter - chaturbate_poller.logging_config.CustomFormatter Functions @@ -39,8 +34,6 @@ Functions .. autoapisummary:: - chaturbate_poller.logging_config.generate_correlation_id - chaturbate_poller.logging_config.set_correlation_id chaturbate_poller.logging_config.sanitize_sensitive_data chaturbate_poller.logging_config.setup_logging @@ -54,43 +47,11 @@ Module Contents .. py:data:: timezone_name -.. py:data:: log_timestamp - -.. py:data:: log_filename - :value: 'logs/Uninferable.log' - - -.. py:data:: correlation_id_var - -.. py:function:: generate_correlation_id() -> str - - Generate a unique correlation ID. - - -.. py:function:: set_correlation_id(correlation_id: str) -> None - - Set the correlation ID in the context. - - .. py:function:: sanitize_sensitive_data(arg: str | float) -> str | int | float Sanitize sensitive data like URLs and tokens. -.. py:class:: CorrelationIDFilter(name='') - - Bases: :py:obj:`logging.Filter` - - - Filter to add the correlation ID to log records. - - - .. py:method:: filter(record: logging.LogRecord) -> bool - - Add the correlation ID to the log record. - - - .. py:class:: SanitizeSensitiveDataFilter(name='') Bases: :py:obj:`logging.Filter` @@ -119,31 +80,11 @@ Module Contents -.. py:class:: CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) - - Bases: :py:obj:`logging.Formatter` - - - Custom log formatter for detailed logs. - - - .. py:method:: format(record: logging.LogRecord) -> str - - Format the log record. - - :param record: The log record. - :type record: logging.LogRecord - - :returns: The formatted log record. - :rtype: str - - - .. py:data:: LOGGING_CONFIG :type: dict[str, Any] .. py:function:: setup_logging(*, verbose: bool = False) -> None - Set up logging configuration and ensure log directory exists. + Set up logging configuration. diff --git a/_sources/autoapi/chaturbate_poller/main/index.rst.txt b/_sources/autoapi/chaturbate_poller/main/index.rst.txt index 89150321..7c81d68b 100644 --- a/_sources/autoapi/chaturbate_poller/main/index.rst.txt +++ b/_sources/autoapi/chaturbate_poller/main/index.rst.txt @@ -27,12 +27,8 @@ Functions .. autoapisummary:: chaturbate_poller.main.cli - chaturbate_poller.main.setup - chaturbate_poller.main._get_influxdb_config - chaturbate_poller.main._save_env_file chaturbate_poller.main.start chaturbate_poller.main.main - chaturbate_poller.main._validate_inputs chaturbate_poller.main.start_polling @@ -46,38 +42,10 @@ Module Contents Manage and run the Chaturbate Poller CLI. -.. py:function:: setup() -> None - - Interactive setup to generate the .env file. - - This command guides the user through configuring the application by - prompting for essential credentials and optional database settings. - - -.. py:function:: _get_influxdb_config() -> dict[str, str] - - Prompt for InfluxDB configuration details. - - :returns: A dictionary containing InfluxDB connection details. - :rtype: dict[str, str] - - -.. py:function:: _save_env_file(config: dict[str, str]) -> None - - Save the provided configuration to a .env file. - - :param config: Key-value pairs to write to the .env file. - :type config: dict[str, str] - - This function ensures existing configurations are not overwritten without user confirmation. - - .. py:function:: start(username: str, token: str, timeout: int, *, testbed: bool, database: bool, verbose: bool) -> None Start the Chaturbate Poller. - This command initializes the application and runs the main async polling loop. - .. py:function:: main(username: str, token: str, api_timeout: int, *, testbed: bool, use_database: bool, verbose: bool) -> None :async: @@ -102,23 +70,11 @@ Module Contents :type verbose: bool -.. py:function:: _validate_inputs(username: str, token: str) -> None - - Validate mandatory inputs for running the poller. - - :param username: Chaturbate username. - :type username: str - :param token: API token. - :type token: str - - :raises click.BadParameter: If required inputs are missing. - - .. py:function:: start_polling(username: str, token: str, api_timeout: int, event_handler: chaturbate_poller.event_handler.EventHandler, *, testbed: bool, verbose: bool) -> None :async: - Begin polling Chaturbate events with feedback. + Begin polling Chaturbate events. :param username: Chaturbate username. :type username: str diff --git a/_sources/autoapi/chaturbate_poller/utils/index.rst.txt b/_sources/autoapi/chaturbate_poller/utils/index.rst.txt index 4398d91f..97f51213 100644 --- a/_sources/autoapi/chaturbate_poller/utils/index.rst.txt +++ b/_sources/autoapi/chaturbate_poller/utils/index.rst.txt @@ -39,6 +39,17 @@ Module Contents Utility functions for the Chaturbate poller. + .. py:method:: get_max_tries() -> int + :staticmethod: + + + Get the maximum number of tries for polling. + + :returns: The maximum number of tries. + :rtype: int + + + .. py:method:: backoff_handler(details: backoff._typing.Details) -> None :staticmethod: diff --git a/autoapi/chaturbate_poller/logging_config/index.html b/autoapi/chaturbate_poller/logging_config/index.html index 4c6be9fa..30a6cd7b 100644 --- a/autoapi/chaturbate_poller/logging_config/index.html +++ b/autoapi/chaturbate_poller/logging_config/index.html @@ -119,16 +119,7 @@

Attributes

timezone_name

-

log_timestamp

-

- -

log_filename

-

- -

correlation_id_var

-

- -

LOGGING_CONFIG

+

LOGGING_CONFIG

@@ -138,18 +129,12 @@

Attributes

- - - - + - + - - -

CorrelationIDFilter

Filter to add the correlation ID to log records.

SanitizeSensitiveDataFilter

SanitizeSensitiveDataFilter

Filter to sanitize sensitive data from logs.

CustomJSONFormatter

CustomJSONFormatter

Custom JSON Formatter for structured logging.

CustomFormatter

Custom log formatter for detailed logs.

@@ -157,17 +142,11 @@

Classes

Functions

- - - - - - - +

generate_correlation_id(→ str)

Generate a unique correlation ID.

set_correlation_id(→ None)

Set the correlation ID in the context.

sanitize_sensitive_data(→ str | int | float)

Sanitize sensitive data like URLs and tokens.

setup_logging(→ None)

Set up logging configuration and ensure log directory exists.

Set up logging configuration.

@@ -189,52 +168,12 @@

Module Contentschaturbate_poller.logging_config.timezone_name
-
-
-chaturbate_poller.logging_config.log_timestamp
-
- -
-
-chaturbate_poller.logging_config.log_filename = 'logs/Uninferable.log'
-
- -
-
-chaturbate_poller.logging_config.correlation_id_var
-
- -
-
-chaturbate_poller.logging_config.generate_correlation_id() str[source]
-

Generate a unique correlation ID.

-
- -
-
-chaturbate_poller.logging_config.set_correlation_id(correlation_id: str) None[source]
-

Set the correlation ID in the context.

-
-
chaturbate_poller.logging_config.sanitize_sensitive_data(arg: str | float) str | int | float[source]

Sanitize sensitive data like URLs and tokens.

-
-
-class chaturbate_poller.logging_config.CorrelationIDFilter(name='')[source]
-

Bases: logging.Filter

-

Filter to add the correlation ID to log records.

-
-
-filter(record: logging.LogRecord) bool[source]
-

Add the correlation ID to the log record.

-
- -
-
class chaturbate_poller.logging_config.SanitizeSensitiveDataFilter(name='')[source]
@@ -261,30 +200,6 @@

Module Contents -
-class chaturbate_poller.logging_config.CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]
-

Bases: logging.Formatter

-

Custom log formatter for detailed logs.

-
-
-format(record: logging.LogRecord) str[source]
-

Format the log record.

-
-
Parameters:
-

record (logging.LogRecord) – The log record.

-
-
Returns:
-

The formatted log record.

-
-
Return type:
-

str

-
-
-
- -

-
chaturbate_poller.logging_config.LOGGING_CONFIG: dict[str, Any]
@@ -293,7 +208,7 @@

Module Contents
chaturbate_poller.logging_config.setup_logging(*, verbose: bool = False) None[source]
-

Set up logging configuration and ensure log directory exists.

+

Set up logging configuration.

diff --git a/autoapi/chaturbate_poller/main/index.html b/autoapi/chaturbate_poller/main/index.html index 3d69d120..f5a56967 100644 --- a/autoapi/chaturbate_poller/main/index.html +++ b/autoapi/chaturbate_poller/main/index.html @@ -126,26 +126,14 @@

Functions

cli(→ None)

Manage and run the Chaturbate Poller CLI.

-

setup(→ None)

-

Interactive setup to generate the .env file.

- -

_get_influxdb_config(→ dict[str, str])

-

Prompt for InfluxDB configuration details.

- -

_save_env_file(→ None)

-

Save the provided configuration to a .env file.

- -

start(→ None)

+

start(→ None)

Start the Chaturbate Poller.

-

main(→ None)

+

main(→ None)

Main logic for starting the Chaturbate Poller.

-

_validate_inputs(→ None)

-

Validate mandatory inputs for running the poller.

-

start_polling(→ None)

-

Begin polling Chaturbate events with feedback.

+

Begin polling Chaturbate events.

@@ -163,45 +151,10 @@

Module Contents -
-chaturbate_poller.main.setup() None
-

Interactive setup to generate the .env file.

-

This command guides the user through configuring the application by -prompting for essential credentials and optional database settings.

-
- -
-
-chaturbate_poller.main._get_influxdb_config() dict[str, str][source]
-

Prompt for InfluxDB configuration details.

-
-
Returns:
-

A dictionary containing InfluxDB connection details.

-
-
Return type:
-

dict[str, str]

-
-
-
- -
-
-chaturbate_poller.main._save_env_file(config: dict[str, str]) None[source]
-

Save the provided configuration to a .env file.

-
-
Parameters:
-

config (dict[str, str]) – Key-value pairs to write to the .env file.

-
-
-

This function ensures existing configurations are not overwritten without user confirmation.

-
-
chaturbate_poller.main.start(username: str, token: str, timeout: int, *, testbed: bool, database: bool, verbose: bool) None

Start the Chaturbate Poller.

-

This command initializes the application and runs the main async polling loop.

@@ -224,27 +177,10 @@

Module Contents -
-chaturbate_poller.main._validate_inputs(username: str, token: str) None[source]
-

Validate mandatory inputs for running the poller.

-
-
Parameters:
-
    -
  • username (str) – Chaturbate username.

  • -
  • token (str) – API token.

  • -
-
-
Raises:
-

click.BadParameter – If required inputs are missing.

-
-
-

-
async chaturbate_poller.main.start_polling(username: str, token: str, api_timeout: int, event_handler: chaturbate_poller.event_handler.EventHandler, *, testbed: bool, verbose: bool) None[source]
-

Begin polling Chaturbate events with feedback.

+

Begin polling Chaturbate events.

Parameters:
    diff --git a/autoapi/chaturbate_poller/utils/index.html b/autoapi/chaturbate_poller/utils/index.html index d4bf442a..fd936f7c 100644 --- a/autoapi/chaturbate_poller/utils/index.html +++ b/autoapi/chaturbate_poller/utils/index.html @@ -143,6 +143,20 @@

    Module Contents class chaturbate_poller.utils.ChaturbateUtils[source]

    Utility functions for the Chaturbate poller.

    +
    +
    +static get_max_tries() int[source]
    +

    Get the maximum number of tries for polling.

    +
    +
    Returns:
    +

    The maximum number of tries.

    +
    +
    Return type:
    +

    int

    +
    +
    +
    +
    static backoff_handler(details: backoff._typing.Details) None[source]
    diff --git a/genindex.html b/genindex.html index e09b2709..64e00ad0 100644 --- a/genindex.html +++ b/genindex.html @@ -118,27 +118,21 @@

    _

  • _cancel_tasks() (chaturbate_poller.signal_handler.SignalHandler method)
  • + + - @@ -266,6 +260,8 @@

    C

  • module
  • + +
    • chaturbate_poller.signal_handler @@ -273,8 +269,6 @@

      C

    • module
    - - -
  • filter() (chaturbate_poller.logging_config.CorrelationIDFilter method) - -
  • flatten_dict() (chaturbate_poller.influxdb_handler.InfluxDBHandler method)
  • font (chaturbate_poller.models.Message attribute)
  • FORBIDDEN (chaturbate_poller.constants.HttpStatusCode attribute)
  • -
  • format() (chaturbate_poller.logging_config.CustomFormatter method) +
  • format_broadcast_event() (in module chaturbate_poller.format_messages)
  • @@ -518,10 +500,6 @@

    L

  • (chaturbate_poller.ConfigManager method)
  • -
  • log_filename (in module chaturbate_poller.logging_config) -
  • -
  • log_timestamp (in module chaturbate_poller.logging_config) -
  • logger (in module chaturbate_poller.chaturbate_client) - +
    • start_polling() (in module chaturbate_poller.main)
    • stop_future (chaturbate_poller.signal_handler.SignalHandler attribute) diff --git a/objects.inv b/objects.inv index 0a1eb326866508301f549d2f202001ede84bd696..a9e4880bb19fc39cad02b7357d1b2ff48f0e8964 100644 GIT binary patch delta 2094 zcmV+}2+{YK61WkNp?_H7Akpd0uOA8UtGjJWG{RZ6Td4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