Updated for pysocks import

This commit is contained in:
Dimitris Zlatanidis 2023-05-14 19:21:06 +03:00
parent 0a4c7eb66a
commit 178e4e724c

View file

@ -7,11 +7,6 @@ from pathlib import Path
from multiprocessing import Process
from urllib3 import PoolManager, ProxyManager, make_headers
try: # Try to import PySocks if it's installed.
from urllib3.contrib.socks import SOCKSProxyManager
except (ModuleNotFoundError, ImportError):
pass
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.progress_bar import ProgressBar
@ -121,6 +116,10 @@ class CheckUpdates(Configs):
self.http = ProxyManager(f'{self.proxy_address}', headers=self.proxy_default_headers)
def set_socks_proxy_server(self):
try: # Try to import PySocks if it's installed.
from urllib3.contrib.socks import SOCKSProxyManager
except (ModuleNotFoundError, ImportError) as error:
print(error)
# https://urllib3.readthedocs.io/en/stable/advanced-usage.html#socks-proxies
self.http = SOCKSProxyManager(f'{self.proxy_address}', headers=self.proxy_default_headers)