From e3e3262cd91c23884abcffa92d7a79ee20b5deed Mon Sep 17 00:00:00 2001 From: japandotorg Date: Wed, 25 Sep 2024 10:31:40 +0530 Subject: [PATCH] [Screenshot] more fixes --- screenshot/__init__.py | 6 +++--- screenshot/common/__init__.py | 8 +------- screenshot/common/downloader.py | 3 +-- screenshot/core.py | 4 ++-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/screenshot/__init__.py b/screenshot/__init__.py index ad14fba..75982c2 100644 --- a/screenshot/__init__.py +++ b/screenshot/__init__.py @@ -37,9 +37,9 @@ async def setup(bot: Red) -> None: urllib_logger.setLevel(logging.WARNING) - logging.getLogger("PIL").setLevel(logging.WARNING) - logging.getLogger("h5py").setLevel(logging.WARNING) - logging.getLogger("selenium").setLevel(logging.WARNING) + logging.getLogger("PIL").setLevel(logging.DEBUG) + logging.getLogger("h5py").setLevel(logging.DEBUG) + logging.getLogger("selenium").setLevel(logging.DEBUG) if platform.system().lower() not in ["windows", "linux"]: raise CogLoadError("This cog is only available for linux and windows devices right now.") cog: Screenshot = Screenshot(bot) diff --git a/screenshot/common/__init__.py b/screenshot/common/__init__.py index 5d9084c..52b85ad 100644 --- a/screenshot/common/__init__.py +++ b/screenshot/common/__init__.py @@ -132,7 +132,6 @@ def take_screenshot_with_url( raise commands.UserFeedbackCheckFailure("Timed out opening the website.") except WebDriverException as error: if re.search(pattern="about:neterror", string=str(error.msg), flags=re.IGNORECASE): - log.exception("Something went wrong connecting to the internet.", exc_info=error) raise ProxyConnectFailedError() raise commands.UserFeedbackCheckFailure( "Could not get a screenshot of that website, try again later." @@ -166,12 +165,7 @@ async def driver(self) -> AsyncGenerator[Firefox, None]: now: datetime = datetime.now(timezone.utc) try: driver: Firefox = await self.launcher() - ( - driver.install_addon(os.fspath(location), temporary=True) - if (location := self.cog.manager.get_extension_location("cookies")) - else None - ) - driver.set_page_load_timeout(time_to_wait=230.0) + driver.set_page_load_timeout(time_to_wait=30.0) driver.fullscreen_window() try: yield driver diff --git a/screenshot/common/downloader.py b/screenshot/common/downloader.py index ba41eea..6f7d25e 100644 --- a/screenshot/common/downloader.py +++ b/screenshot/common/downloader.py @@ -66,7 +66,6 @@ class DriverManager: ) FIREFOX_ADDONS = { "dark": "https://addons.mozilla.org/firefox/downloads/file/4351387/darkreader-4.9.92.xpi", - "cookies": "https://addons.mozilla.org/firefox/downloads/file/3625855/ninja_cookie-0.2.7.xpi", } def __init__(self, session: Optional[aiohttp.ClientSession] = None) -> None: @@ -193,7 +192,7 @@ async def wait_until_driver_downloaded(self) -> None: await self.__event.wait() async def execute_tor_binary(self) -> Optional[asyncio.subprocess.Process]: - if self.tor_location and self._tor_process is discord.utils.MISSING: + if self.tor_location: process: asyncio.subprocess.Process = await asyncio.subprocess.create_subprocess_shell( ( "{0}/tor/tor -f {0}/torrc" diff --git a/screenshot/core.py b/screenshot/core.py index 94057ab..69b0dee 100644 --- a/screenshot/core.py +++ b/screenshot/core.py @@ -152,8 +152,8 @@ async def screenshot(self, ctx: commands.Context, url: URLConverter, *, flags: s **Arguments**: - `` ``: a well formatted url. - ````: - - ``--full`` for a full screenshot of the page. - - ``--mode `` either ``light`` or ``dark``. + - ``--full`` for a full screenshot of the page. + - ``--mode `` either ``light`` or ``dark``. **Examples**: - ``[p]screenshot https://seina-cogs.readthedocs.io``