Skip to content

Commit

Permalink
Исправления
Browse files Browse the repository at this point in the history
  • Loading branch information
Helow19274 committed Apr 17, 2018
1 parent 958b5d5 commit 27714a0
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ Use Session object
Notice that ``wait`` value only for long pool connection.

Real pause could be more ``wait`` time because of need time
for authorisation (if needed), reconnect and etc.
for authorization (if needed), reconnect and etc.
4 changes: 2 additions & 2 deletions aiovk/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def start(self, connection, read_until_eof=False):
await super().start(connection, read_until_eof)
headers = CIMultiDict(self.headers)
location = headers.get(hdrs.LOCATION, None)
if location is not None:
if location:
headers[hdrs.LOCATION] = location.replace('#', '?')
self.headers = CIMultiDictProxy(headers)
self.raw_headers = tuple(headers.items())
Expand Down Expand Up @@ -95,7 +95,7 @@ async def close(self):
await self.session.close()


if ProxyConnector is not None:
if ProxyConnector:
class Socks5Driver(HttpDriver):
connector = ProxyConnector

Expand Down
8 changes: 4 additions & 4 deletions aiovk/longpoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ async def _get_long_poll_server(self, need_pts=False):
self.base_url = 'https://{}'.format(response['server'])

async def wait(self, need_pts=False):
if self.base_url is None:
if not self.base_url:
await self._get_long_poll_server(need_pts)
params = {
'ts': self.ts,
'key': self.key,
}
params.update(self.base_params)
# invalid mymetype from server
code, response = await self.api._session.driver.get_text(self.base_url, params, timeout=2*self.base_params['wait'])
code, response = await self.api._session.driver.get_text(self.base_url, params, timeout=2 * self.base_params['wait'])
if code == 403:
raise VkLongPollError(403,
'smth weth wrong',
Expand All @@ -49,7 +49,7 @@ async def wait(self, need_pts=False):
)
response = json.loads(response)
failed = response.get('failed')
if failed is None:
if not failed:
self.ts = response['ts']
return response
if failed == 1:
Expand All @@ -64,7 +64,7 @@ async def wait(self, need_pts=False):
return await self.wait()

async def get_pts(self, need_ts=False):
if self.base_url is None or self.pts is None:
if not self.base_url or not self.pts:
await self._get_long_poll_server(need_pts=True)
if need_ts:
return self.pts, self.ts
Expand Down
4 changes: 2 additions & 2 deletions aiovk/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class LimitRateDriverMixin:
requests_per_period = 3
period = 1 #seconds
period = 1 # seconds

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -32,7 +32,7 @@ async def close(self):

class SimpleImplicitSessionMixin:
"""
Simple implementation of processing captcha and 2factor authorisation
Simple implementation of processing captcha and 2factor authorization
"""

async def enter_captcha(self, url, sid):
Expand Down
6 changes: 3 additions & 3 deletions aiovk/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def send_api_request(self, method_name: str, params: dict = None, timeout:
class TokenSession(BaseSession):
"""Implements simple session that ues existed token for work"""

API_VERSION = '5.63'
API_VERSION = '5.74'
REQUEST_URL = 'https://api.vk.com/method/'

def __init__(self, access_token: str = None, timeout: int = 10, driver=None):
Expand Down Expand Up @@ -111,7 +111,7 @@ async def enter_captcha(self, url: str, sid: str) -> str:

class ImplicitSession(TokenSession):
"""
For client authorisation in js apps and standalone (desktop and mobile) apps
For client authorization in js apps and standalone (desktop and mobile) apps
See more in https://new.vk.com/dev/implicit_flow_user
"""
AUTH_URL = 'https://oauth.vk.com/authorize'
Expand Down Expand Up @@ -269,7 +269,7 @@ async def enter_confirmation_code(self) -> str:

class AuthorizationCodeSession(TokenSession):
"""
For client authorisation in js apps and standalone (desktop and mobile) apps
For client authorization in js apps and standalone (desktop and mobile) apps
See more in https://new.vk.com/dev/implicit_flow_user
"""
CODE_URL = 'https://oauth.vk.com/access_token'
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Before testing
1) Rename `auth_data.py.example` to `auth_data.py`
2) Enter your authorisation data
2) Enter your authorization data
3) Add your 2factor code from security settings (under QR code)
4) Run tests
2 changes: 0 additions & 2 deletions tests/test_drivers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import json
import os
import unittest
from http.server import HTTPServer
from threading import Thread
from unittest import mock
import aio.testing
import time
import math
import asyncio
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def foo(a):
obj._queue = q

yield from foo(obj)
self.assertEqual(q.qsize(), size-1)
self.assertEqual(q.qsize(), size - 1)
q.canel()

@aio.testing.run_until_complete
Expand Down

0 comments on commit 27714a0

Please sign in to comment.