Tweak some parameters to fix chromedriver

This commit is contained in:
Nexus 2024-01-15 11:02:31 +00:00
parent f759f9ddb2
commit 0e8f5758ef
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -22,13 +22,13 @@ class ScreenshotCog(commands.Cog):
self.log = logging.getLogger("jimmy.cogs.screenshot") self.log = logging.getLogger("jimmy.cogs.screenshot")
self.chrome_options = ChromeOptions() self.chrome_options = ChromeOptions()
self.chrome_options.add_argument("--headless") # self.chrome_options.add_argument("--headless")
self.chrome_options.add_argument("--disable-extensions") # self.chrome_options.add_argument("--disable-extensions")
self.chrome_options.add_argument("--incognito") self.chrome_options.add_argument("--incognito")
self.chrome_options.add_argument("--remote-debugging-port=9222") self.chrome_options.add_argument("--remote-debugging-port=9222")
if os.getuid() == 0: if os.getuid() == 0:
self.chrome_options.add_argument("--no-sandbox") self.chrome_options.add_argument("--no-sandbox")
self.chrome_options.add_argument("--disable-setuid-sandbox") # self.chrome_options.add_argument("--disable-setuid-sandbox")
self.log.warning("Running as root, disabling chrome sandbox.") self.log.warning("Running as root, disabling chrome sandbox.")
prefs = { prefs = {
@ -38,9 +38,9 @@ class ScreenshotCog(commands.Cog):
"plugins.always_open_pdf_externally": False, "plugins.always_open_pdf_externally": False,
"download_restrictions": 3, "download_restrictions": 3,
} }
self.chrome_options.add_experimental_option( # self.chrome_options.add_experimental_option(
"prefs", prefs # "prefs", prefs
) # )
def compress_png(self, input_file: io.BytesIO) -> io.BytesIO: def compress_png(self, input_file: io.BytesIO) -> io.BytesIO:
img = Image.open(input_file) img = Image.open(input_file)
@ -81,7 +81,8 @@ class ScreenshotCog(commands.Cog):
if eager is None: if eager is None:
eager = render_timeout is None eager = render_timeout is None
if render_timeout is None: if render_timeout is None:
render_timeout = 30 if eager else 10 # render_timeout = 30 if eager else 10
render_timeout = 30
if not url.startswith("http"): if not url.startswith("http"):
url = "https://" + url url = "https://" + url
self.log.debug( self.log.debug(