Skip to content

Commit

Permalink
[apps/browser] investigate crash in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Sep 10, 2024
1 parent 2b007be commit 7fc79bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions apps/browser/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import WebDriverException

import json
import hal9 as h9
import shutil
import time
import psutil

from sitefind import site_find
from siteuse import site_use
Expand All @@ -18,7 +20,6 @@ def take_screenshot():
shutil.copy("screenshot.png", f"storage/screenshot-{int(time.time())}.png")

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
custom_user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
Expand All @@ -36,8 +37,11 @@ def take_screenshot():
code = site_use(prompt, driver.current_url)
exec(code)
take_screenshot()
except WebDriverException as e:
print(f"Failed to use browser, driver details follow.\n```\n{code}\n```\n\n```\n{e}\n```\n")
print(f"Available Memory: {(psutil.virtual_memory().available/ (1024 ** 2)):.2f} MB")
except Exception as e:
print(f"Failed to use browser, details follow.\n```{code}```\n\n```\n{e}```\n")
print(f"Failed to use browser, details follow.\n```\n{code}\n```\n\n```\n{e}\n```\n")

prompt = h9.input("Taking screenshot, what next?")

Expand Down
3 changes: 2 additions & 1 deletion apps/browser/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
selenium
selenium
psutil

0 comments on commit 7fc79bf

Please sign in to comment.