From a582038465e36a2571d6235143c4377120dcb2e3 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Wed, 9 Oct 2024 14:29:51 +0200 Subject: [PATCH 1/3] Return driver object only when valid Without this, a driver that failed the sanity check could be returned. This leads to attempting to use it when checking URLs, which led to avoidable failures. Fixes #92 --- urlchecker/core/urlproc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/urlchecker/core/urlproc.py b/urlchecker/core/urlproc.py index 125ad0b..6f1eec5 100644 --- a/urlchecker/core/urlproc.py +++ b/urlchecker/core/urlproc.py @@ -153,10 +153,11 @@ def get_driver(self, port: Optional[int] = None, timeout: Optional[int] = 5): try: from .webdriver import WebDriver - driver = WebDriver(port=port, timeout=timeout) + default_driver = WebDriver(port=port, timeout=timeout) - # Do a sanity check of the driver - driver.check("https://google.com") + # Do a sanity check of the default driver + default_driver.check("https://google.com") + driver = default_driver except: logger.warning( "Issue with driver, results will be improved if you have it! Please match your version from https://googlechromelabs.github.io/chrome-for-testing" From 6f20a2561c83f37bbd1d30a1a4c0d0f685dfad24 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Thu, 10 Oct 2024 09:39:00 +0200 Subject: [PATCH 2/3] refactor --- urlchecker/core/urlproc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/urlchecker/core/urlproc.py b/urlchecker/core/urlproc.py index 6f1eec5..cc8ae7f 100644 --- a/urlchecker/core/urlproc.py +++ b/urlchecker/core/urlproc.py @@ -153,12 +153,12 @@ def get_driver(self, port: Optional[int] = None, timeout: Optional[int] = 5): try: from .webdriver import WebDriver - default_driver = WebDriver(port=port, timeout=timeout) + driver = WebDriver(port=port, timeout=timeout) # Do a sanity check of the default driver - default_driver.check("https://google.com") - driver = default_driver + driver.check("https://google.com") except: + driver = None logger.warning( "Issue with driver, results will be improved if you have it! Please match your version from https://googlechromelabs.github.io/chrome-for-testing" ) From 09db8e276124facf284417b96f7158c3d18b34db Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Thu, 10 Oct 2024 09:47:41 +0200 Subject: [PATCH 3/3] Bump version and changelog --- CHANGELOG.md | 1 + urlchecker/version.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a8d41..384b090 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and **Merged pull requests**. Critical items to know are: Referenced versions in headers are tagged on Github, in parentheses are for pypi. ## [vxx](https://github.com/urlstechie/urlschecker-python/tree/master) (master) + - avoid using web driver when it doesn't work (0.0.36) - allow variable to skip checking certificates (0.0.35) - switch back to pypi release of fake-useragent (0.0.34) - preparing to install from git for fake-useragent (0.0.33) diff --git a/urlchecker/version.py b/urlchecker/version.py index d164a6e..1dea1fe 100644 --- a/urlchecker/version.py +++ b/urlchecker/version.py @@ -7,7 +7,7 @@ """ -__version__ = "0.0.35" +__version__ = "0.0.36" AUTHOR = "Ayoub Malek, Vanessa Sochat" AUTHOR_EMAIL = "superkogito@gmail.com, vsochat@stanford.edu" NAME = "urlchecker"