mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-07-23 18:40:07 +00:00
fix: uc: Update for Python 3.13+ compatibility
This commit addresses several points to ensure compatibility with Python 3.13 and incorporates modern Python practices: - Replaced `distutils.version.LooseVersion` with `packaging.version.Version` in `patcher.py` and added `packaging` to dependencies. - Modernized `os.system` calls in `patcher.py` to use `subprocess.run` for better control and error handling. - Updated `setup.py`: - Bumped versions for `selenium`, `requests`, `websockets`, and `packaging`. - Replaced `codecs.open` with standard `open`. - Added Python 3.12 and 3.13 classifiers. - Updated `super()` calls in `__init__.py` to the concise Python 3 syntax.
This commit is contained in:
parent
377e0e2306
commit
06ce856585
@ -471,7 +471,7 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
|||||||
self.patcher.executable_path
|
self.patcher.executable_path
|
||||||
)
|
)
|
||||||
|
|
||||||
super(Chrome, self).__init__(
|
super().__init__(
|
||||||
service=service,
|
service=service,
|
||||||
options=options,
|
options=options,
|
||||||
keep_alive=keep_alive,
|
keep_alive=keep_alive,
|
||||||
@ -727,10 +727,8 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
|||||||
def start_session(self, capabilities=None, browser_profile=None):
|
def start_session(self, capabilities=None, browser_profile=None):
|
||||||
if not capabilities:
|
if not capabilities:
|
||||||
capabilities = self.options.to_capabilities()
|
capabilities = self.options.to_capabilities()
|
||||||
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
|
super().start_session(capabilities)
|
||||||
capabilities
|
# super(Chrome, self).start_session(capabilities, browser_profile) # Original explicit call commented out
|
||||||
)
|
|
||||||
# super(Chrome, self).start_session(capabilities, browser_profile)
|
|
||||||
|
|
||||||
def find_elements_recursive(self, by, value):
|
def find_elements_recursive(self, by, value):
|
||||||
"""
|
"""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# this module is part of undetected_chromedriver
|
# this module is part of undetected_chromedriver
|
||||||
|
|
||||||
from distutils.version import LooseVersion
|
from packaging.version import Version as LooseVersion
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
@ -12,6 +12,7 @@ import random
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import string
|
import string
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
@ -373,10 +374,31 @@ class Patcher(object):
|
|||||||
"""
|
"""
|
||||||
exe_name = os.path.basename(exe_name)
|
exe_name = os.path.basename(exe_name)
|
||||||
if IS_POSIX:
|
if IS_POSIX:
|
||||||
r = os.system("kill -f -9 $(pidof %s)" % exe_name)
|
# Using shell=True for pidof, consider a more robust pid finding method if issues arise.
|
||||||
|
# pgrep can be an alternative: ["pgrep", "-f", exe_name]
|
||||||
|
# Or psutil if adding a dependency is acceptable.
|
||||||
|
command = f"pidof {exe_name}"
|
||||||
|
try:
|
||||||
|
result = subprocess.run(command, shell=True, capture_output=True, text=True, check=True)
|
||||||
|
pids = result.stdout.strip().split()
|
||||||
|
if pids:
|
||||||
|
subprocess.run(["kill", "-9"] + pids, check=False) # Changed from -f -9 to -9 as -f is not standard for kill
|
||||||
|
return True
|
||||||
|
return False # No PIDs found
|
||||||
|
except subprocess.CalledProcessError: # pidof returns 1 if no process found
|
||||||
|
return False # No process found
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"Error killing process on POSIX: {e}")
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
r = os.system("taskkill /f /im %s" % exe_name)
|
try:
|
||||||
return not r
|
# TASKKILL /F /IM chromedriver.exe
|
||||||
|
result = subprocess.run(["taskkill", "/f", "/im", exe_name], check=False, capture_output=True)
|
||||||
|
# taskkill returns 0 if process was killed, 128 if not found.
|
||||||
|
return result.returncode == 0
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"Error killing process on Windows: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def gen_random_cdc():
|
def gen_random_cdc():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user