Debugging
Browse files
app.py
CHANGED
|
@@ -89,6 +89,10 @@ def verify_geckodriver2():
|
|
| 89 |
logger.error(f"Version check failed: {str(e)}")
|
| 90 |
raise
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
def create_service():
|
| 93 |
# 1. Verify geckodriver
|
| 94 |
geckodriver_path = shutil.which('geckodriver') or '/usr/local/bin/geckodriver'
|
|
@@ -109,14 +113,26 @@ def create_service():
|
|
| 109 |
if not os.access(log_dir, os.W_OK):
|
| 110 |
log_dir = '/tmp'
|
| 111 |
|
|
|
|
| 112 |
# 4. Create service
|
| 113 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
return Service(
|
| 115 |
-
executable_path=
|
| 116 |
-
service_args=[
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
| 119 |
)
|
|
|
|
| 120 |
except Exception as e:
|
| 121 |
print(f"Service creation failed: {str(e)}")
|
| 122 |
return Service() # Fallback to simplest config
|
|
@@ -159,7 +175,9 @@ def setup_selenium():
|
|
| 159 |
options.add_argument("--disable-notifications") # Disable notifications
|
| 160 |
options.set_preference("dom.webnotifications.enabled", False) # Disable web notifications
|
| 161 |
options.set_preference("general.useragent.override", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36") # Mimic a real browser's user agent
|
| 162 |
-
options.set_preference("marionette.port",
|
|
|
|
|
|
|
| 163 |
|
| 164 |
# service = Service(
|
| 165 |
# executable_path=os.path.join(os.getcwd(), 'geckodriver'),
|
|
|
|
| 89 |
logger.error(f"Version check failed: {str(e)}")
|
| 90 |
raise
|
| 91 |
|
| 92 |
+
# Use these specific ports
|
| 93 |
+
MARIONETTE_PORT = 2828
|
| 94 |
+
WEBDRIVER_PORT = 4444
|
| 95 |
+
|
| 96 |
def create_service():
|
| 97 |
# 1. Verify geckodriver
|
| 98 |
geckodriver_path = shutil.which('geckodriver') or '/usr/local/bin/geckodriver'
|
|
|
|
| 113 |
if not os.access(log_dir, os.W_OK):
|
| 114 |
log_dir = '/tmp'
|
| 115 |
|
| 116 |
+
|
| 117 |
# 4. Create service
|
| 118 |
try:
|
| 119 |
+
# return Service(
|
| 120 |
+
# executable_path=geckodriver_path,
|
| 121 |
+
# service_args=['--marionette-port', str(port)],
|
| 122 |
+
# log_path=os.path.join(log_dir, 'geckodriver.log'),
|
| 123 |
+
# # timeout=30
|
| 124 |
+
# )
|
| 125 |
+
|
| 126 |
return Service(
|
| 127 |
+
executable_path='/usr/local/bin/geckodriver',
|
| 128 |
+
service_args=[
|
| 129 |
+
'--marionette-port', str(MARIONETTE_PORT),
|
| 130 |
+
'--port', str(WEBDRIVER_PORT),
|
| 131 |
+
'--log', 'trace' # Enable verbose logging
|
| 132 |
+
],
|
| 133 |
+
log_path='/tmp/geckodriver.log'
|
| 134 |
)
|
| 135 |
+
|
| 136 |
except Exception as e:
|
| 137 |
print(f"Service creation failed: {str(e)}")
|
| 138 |
return Service() # Fallback to simplest config
|
|
|
|
| 175 |
options.add_argument("--disable-notifications") # Disable notifications
|
| 176 |
options.set_preference("dom.webnotifications.enabled", False) # Disable web notifications
|
| 177 |
options.set_preference("general.useragent.override", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36") # Mimic a real browser's user agent
|
| 178 |
+
options.set_preference("marionette.port", MARIONETTE_PORT)
|
| 179 |
+
options.set_preference("marionette.enabled", True)
|
| 180 |
+
options.set_preference("remote.enabled", True)
|
| 181 |
|
| 182 |
# service = Service(
|
| 183 |
# executable_path=os.path.join(os.getcwd(), 'geckodriver'),
|