From b82cebd33f0413d5e33efcd4377c382b411b97c8 Mon Sep 17 00:00:00 2001 From: deemfox <102898877+deemfox@users.noreply.github.com> Date: Mon, 4 Apr 2022 17:28:41 -0600 Subject: [PATCH] change to proxy.py to fix failing to connect to websocket errors (#439) * Update proxy.py fix for "failed to connect to websocket" error * nox --- main.py | 4 +++- src/proxy.py | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 2f8c2d2d..07686123 100755 --- a/main.py +++ b/main.py @@ -291,7 +291,9 @@ def get_board(self, access_token_in): requests.get( msg["data"]["name"], stream=True, - proxies=proxy.get_random_proxy(self, name=None), + proxies=proxy.get_random_proxy( + self, name=None + ), ).content ) ), diff --git a/src/proxy.py b/src/proxy.py index 37fada32..4caf3e8c 100644 --- a/src/proxy.py +++ b/src/proxy.py @@ -57,8 +57,7 @@ def Init(self): ) self.tor_ip = ( self.json_data["tor_ip"] - if "tor_ip" in self.json_data - and self.json_data["tor_ip"] is not None + if "tor_ip" in self.json_data and self.json_data["tor_ip"] is not None else "127.0.0.1" ) @@ -110,12 +109,16 @@ def get_proxies(self, proxies): return proxies_list return proxies_list -#name is the username of the worker and is used for personal proxies + +# name is the username of the worker and is used for personal proxies def get_random_proxy(self, name=None): if not self.using_tor: random_proxy = None if name is not None: - if self.json_data["workers"][name]["personal_proxy"] is not None: + if ( + "personal_proxy" in self.json_data["workers"][name] + and self.json_data["workers"][name]["personal_proxy"] is not None + ): proxy = self.json_data["workers"][name]["personal_proxy"] return {"https": proxy, "http": proxy} if self.proxies is not None: