Missing kid verify timeout handle
This commit is contained in:
@@ -4,6 +4,7 @@ from selenium.webdriver.firefox.options import Options
|
|||||||
from selenium.webdriver.firefox.service import Service
|
from selenium.webdriver.firefox.service import Service
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -39,14 +40,17 @@ class MissingKidsFetcher():
|
|||||||
# Load URL
|
# Load URL
|
||||||
driver.get(url)
|
driver.get(url)
|
||||||
# Wait for 404?
|
# Wait for 404?
|
||||||
WebDriverWait(driver, 1).until(EC.title_contains("404"))
|
try:
|
||||||
|
WebDriverWait(driver, 2).until(EC.title_contains("404"))
|
||||||
|
except TimeoutException:
|
||||||
|
pass
|
||||||
|
|
||||||
if ("404" in driver.title):
|
if ("404" in driver.title):
|
||||||
# Status invalid
|
# Status invalid
|
||||||
results = {"status": "invalid"}
|
results = {"status": "invalid"}
|
||||||
else:
|
else:
|
||||||
# Check until finished loading
|
# Check until finished loading
|
||||||
num_checks = 5
|
num_checks = 3
|
||||||
while (not load_finished(driver)) and (num_checks>=0):
|
while (not load_finished(driver)) and (num_checks>=0):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class DB_Handler():
|
|||||||
missingkids_fetch_endpoint = os.path.join(os.getenv("SELENIUM_ENDPOINT", "http://localhost:80"), "verify_missing_kid/")
|
missingkids_fetch_endpoint = os.path.join(os.getenv("SELENIUM_ENDPOINT", "http://localhost:80"), "verify_missing_kid/")
|
||||||
data = {"url": obj_url.url}
|
data = {"url": obj_url.url}
|
||||||
# POST
|
# POST
|
||||||
r = requests.post(missingkids_fetch_endpoint, json=data, timeout=30)
|
r = requests.post(missingkids_fetch_endpoint, json=data, timeout=120)
|
||||||
# Jsonify
|
# Jsonify
|
||||||
results = r.json()
|
results = r.json()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user