From 8613de9d7c860a8cb59373b44c6d72b4306817f9 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 19 Jun 2017 11:34:20 +0300 Subject: [PATCH] Fix NameError: name 'ProxyConnector' is not defined --- aiovk/drivers.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/aiovk/drivers.py b/aiovk/drivers.py index 5bb7d75..7a4c9ab 100644 --- a/aiovk/drivers.py +++ b/aiovk/drivers.py @@ -7,7 +7,7 @@ import aiosocks from aiosocks.connector import ProxyConnector except ImportError: - pass + ProxyConnector = None class CustomClientResponse(aiohttp.ClientResponse): @@ -95,16 +95,17 @@ def close(self): self.session.close() -class Socks5Driver(HttpDriver): - connector = ProxyConnector - - def __init__(self, address, port, login=None, password=None, timeout=10, loop=None): - super().__init__(timeout) - self.close() - addr = aiosocks.Socks5Addr(address, port) - if login and password: - auth = aiosocks.Socks5Auth(login, password=password) - else: - auth = None - conn = self.connector(proxy=addr, proxy_auth=auth, loop=loop) - self.session = aiohttp.ClientSession(connector=conn, response_class=CustomClientResponse) +if ProxyConnector is not None: + class Socks5Driver(HttpDriver): + connector = ProxyConnector + + def __init__(self, address, port, login=None, password=None, timeout=10, loop=None): + super().__init__(timeout) + self.close() + addr = aiosocks.Socks5Addr(address, port) + if login and password: + auth = aiosocks.Socks5Auth(login, password=password) + else: + auth = None + conn = self.connector(proxy=addr, proxy_auth=auth, loop=loop) + self.session = aiohttp.ClientSession(connector=conn, response_class=CustomClientResponse)