summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/helper.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2023-12-06 09:35:36 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2023-12-06 09:35:36 +0100
commit3576dee75a1623aa2385b6afe8b922ad5affca26 (patch)
treef54f68590875e4e67adaab03139f18167ffc7fa1 /g4f/Provider/helper.py
parentAdd get_session_from_browser as cloudflare bypass (diff)
downloadgpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar
gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.gz
gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.bz2
gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.lz
gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.xz
gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.zst
gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.zip
Diffstat (limited to 'g4f/Provider/helper.py')
-rw-r--r--g4f/Provider/helper.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/g4f/Provider/helper.py b/g4f/Provider/helper.py
index 2171f0b7..61d9cb62 100644
--- a/g4f/Provider/helper.py
+++ b/g4f/Provider/helper.py
@@ -6,6 +6,7 @@ import webbrowser
import random
import string
import secrets
+import os
from os import path
from asyncio import AbstractEventLoop
from platformdirs import user_config_dir
@@ -18,7 +19,7 @@ from browser_cookie3 import (
edge,
vivaldi,
firefox,
- BrowserCookieError
+ _LinuxPasswordManager
)
from ..typing import Dict, Messages
@@ -81,6 +82,10 @@ def init_cookies():
except webbrowser.Error:
continue
+# Check for broken dbus address in docker image
+if os.environ.get('DBUS_SESSION_BUS_ADDRESS') == "/dev/null":
+ _LinuxPasswordManager.get_password = lambda a, b: b"secret"
+
# Load cookies for a domain from all supported browsers.
# Cache the results in the "_cookies" variable.
def get_cookies(domain_name=''):
@@ -100,7 +105,7 @@ def get_cookies(domain_name=''):
for cookie in cookie_jar:
if cookie.name not in cookies:
cookies[cookie.name] = cookie.value
- except BrowserCookieError as e:
+ except:
pass
_cookies[domain_name] = cookies
return _cookies[domain_name]