Skip to content

Commit 452e29f

Browse files
committed
SecurityCheck: update __str__
1 parent 2dca89c commit 452e29f

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

vk_api/vk_api.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def __init__(self, login=None, password=None, number=None, sec_number=None,
7575
'User-agent': 'Mozilla/5.0 (Windows NT 6.1; rv:31.0)'
7676
' Gecko/20100101 Firefox/31.0'
7777
}
78-
self.http.verify = False
7978

8079
self.last_request = 0.0
8180

@@ -186,7 +185,10 @@ def security_check(self, url=None, response=None):
186185
if response.text.split('<!>')[4] == '4':
187186
return True
188187

189-
raise SecurityCheck(phone_prefix, phone_postfix)
188+
if phone_prefix and phone_postfix:
189+
raise SecurityCheck(phone_prefix, phone_postfix)
190+
else:
191+
raise SecurityCheck(response=response)
190192

191193
def check_sid(self):
192194
""" Прверка Cookies remixsid на валидность """
@@ -388,14 +390,19 @@ class BadPassword(AuthorizationError):
388390

389391
class SecurityCheck(AuthorizationError):
390392

391-
def __init__(self, phone_prefix, phone_postfix):
393+
def __init__(self, phone_prefix, phone_postfix, response=None):
392394
self.phone_prefix = phone_prefix
393395
self.phone_postfix = phone_postfix
396+
self.response = response
394397

395398
def __str__(self):
396-
return 'Security check. Enter number: {} ... {}'.format(
397-
self.phone_prefix, self.phone_postfix
398-
)
399+
if self.phone_prefix and self.phone_postfix:
400+
return 'Security check. Enter number: {} ... {}'.format(
401+
self.phone_prefix, self.phone_postfix
402+
)
403+
else:
404+
return ('Security check. Phone prefix and postfix not detected. '
405+
'Please send bugreport. Response in self.response')
399406

400407

401408
class ApiError(Exception):

0 commit comments

Comments
 (0)