mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-06-08 04:25:25 +00:00
Abort if Chromedriver patch fails
This commit is contained in:
parent
009e38185f
commit
dbca4946c6
@ -256,7 +256,9 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
|||||||
user_multi_procs=user_multi_procs,
|
user_multi_procs=user_multi_procs,
|
||||||
)
|
)
|
||||||
# self.patcher.auto(user_multiprocess = user_multi_num_procs)
|
# self.patcher.auto(user_multiprocess = user_multi_num_procs)
|
||||||
self.patcher.auto()
|
if not self.patcher.auto():
|
||||||
|
logging.error("Unable to patch chromedriver.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# self.patcher = patcher
|
# self.patcher = patcher
|
||||||
if not options:
|
if not options:
|
||||||
|
@ -182,19 +182,19 @@ class Patcher(object):
|
|||||||
|
|
||||||
if not chromedriver_path or not os.path.isfile(chromedriver_path):
|
if not chromedriver_path or not os.path.isfile(chromedriver_path):
|
||||||
logging.error("Chromedriver not installed!")
|
logging.error("Chromedriver not installed!")
|
||||||
return
|
return False
|
||||||
if not os.access(chromedriver_path, os.X_OK):
|
if not os.access(chromedriver_path, os.X_OK):
|
||||||
logging.error(
|
logging.error(
|
||||||
f"Execution permissions are not granted for the file {chromedriver_path}.",
|
f"Execution permissions are not granted for the file {chromedriver_path}.",
|
||||||
)
|
)
|
||||||
return
|
return False
|
||||||
|
|
||||||
destination_path = os.path.dirname(self.executable_path)
|
destination_path = os.path.dirname(self.executable_path)
|
||||||
if not os.access(destination_path, os.R_OK | os.W_OK | os.X_OK):
|
if not os.access(destination_path, os.R_OK | os.W_OK | os.X_OK):
|
||||||
logging.error(
|
logging.error(
|
||||||
f"Read/write/execution permissions are not granted for the folder {destination_path}.",
|
f"Read/write/execution permissions are not granted for the folder {destination_path}.",
|
||||||
)
|
)
|
||||||
return
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
process = os.popen(f'"{chromedriver_path}" --version')
|
process = os.popen(f'"{chromedriver_path}" --version')
|
||||||
@ -202,18 +202,22 @@ class Patcher(object):
|
|||||||
process.close()
|
process.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Failed to retrieve chromedriver version: {str(e)}")
|
logging.error(f"Failed to retrieve chromedriver version: {str(e)}")
|
||||||
return
|
return False
|
||||||
|
|
||||||
version_path = os.path.join(destination_path, "version.txt")
|
version_path = os.path.join(destination_path, "version.txt")
|
||||||
current_version = None
|
current_version = None
|
||||||
if os.path.isfile(version_path):
|
if os.path.isfile(version_path) and os.path.isfile(self.executable_path):
|
||||||
if not os.access(version_path, os.W_OK):
|
if not os.access(version_path, os.R_OK | os.W_OK):
|
||||||
logging.error(f"Write permissions are not granted for the file {version_path}.")
|
logging.error(f"Read/write permissions are not granted for the file {version_path}.")
|
||||||
return
|
return False
|
||||||
with open(version_path, 'r') as f:
|
with open(version_path, 'r') as f:
|
||||||
current_version = f.read()
|
current_version = f.read()
|
||||||
|
|
||||||
if current_version == chromedriver_version:
|
if current_version == chromedriver_version:
|
||||||
|
if not os.access(self.executable_path, os.R_OK | os.W_OK | os.X_OK):
|
||||||
|
logging.error(f"Read/write/execution permissions are not granted for the file {self.executable_path}.")
|
||||||
|
return False
|
||||||
|
|
||||||
logging.info(f"The patched version of chromedriver in {destination_path} is the latest version on the system ({current_version}).")
|
logging.info(f"The patched version of chromedriver in {destination_path} is the latest version on the system ({current_version}).")
|
||||||
if self.is_binary_patched():
|
if self.is_binary_patched():
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user