mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
feat: allow auto-restart on captcha (#481)
Co-authored-by: sebthom <sebthom@users.noreply.github.com>
This commit is contained in:
18
src/kleinanzeigen_bot/utils/exceptions.py
Normal file
18
src/kleinanzeigen_bot/utils/exceptions.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
SPDX-FileCopyrightText: © Sebastian Thomschke and contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanzeigen-bot/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
class KleinanzeigenBotError(RuntimeError):
|
||||
"""Base class for all custom bot-related exceptions."""
|
||||
|
||||
|
||||
class CaptchaEncountered(KleinanzeigenBotError):
|
||||
"""Raised when a Captcha was detected and auto-restart is enabled."""
|
||||
|
||||
def __init__(self, restart_delay: timedelta):
|
||||
super().__init__()
|
||||
self.restart_delay = restart_delay
|
||||
@@ -28,6 +28,9 @@ LOG_ROOT:Final[logging.Logger] = logging.getLogger()
|
||||
|
||||
|
||||
def configure_console_logging() -> None:
|
||||
# if a StreamHandler already exists, do not append it again
|
||||
if any(isinstance(h, logging.StreamHandler) for h in LOG_ROOT.handlers):
|
||||
return
|
||||
|
||||
class CustomFormatter(logging.Formatter):
|
||||
LEVEL_COLORS = {
|
||||
|
||||
Reference in New Issue
Block a user