Skip to content

Commit

Permalink
⚡ [Enhance] Set proxy in enver for easier use
Browse files Browse the repository at this point in the history
  • Loading branch information
Hansimov committed Dec 7, 2023
1 parent 3eecc54 commit dcbfe03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion conversations/conversation_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def connect(self):
self.wss = await self.aiohttp_session.ws_connect(
self.ws_url,
headers=headers_constructor.request_headers,
proxy=enver.envs.get("http_proxy") or None,
proxy=enver.proxy,
)
await self.init_handshake()

Expand Down
2 changes: 1 addition & 1 deletion conversations/conversation_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create(self):
self.response = httpx.get(
self.conversation_create_url,
headers=self.request_headers,
proxies=enver.envs.get("http_proxy") or None,
proxies=enver.proxy,
cookies=self.httpx_cookies,
)
try:
Expand Down
11 changes: 8 additions & 3 deletions utils/enver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ def set_envs(self, secrets=True, proxies=None, store_envs=True):
self.envs[proxy_env] = os.getenv("http_proxy")
else:
continue
print(f"Set {proxy_env} to {self.envs[proxy_env]}")
else:
pass
print(f"Set {proxy_env} to {self.envs.get(proxy_env)}")

self.proxy = (
self.envs.get("all_proxy")
or self.envs.get("http_proxy")
or self.envs.get("https_proxy")
or None
)


enver = OSEnver()

0 comments on commit dcbfe03

Please sign in to comment.