本文整理汇总了Python中pgoapi.exceptions.ServerSideRequestThrottlingException方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.ServerSideRequestThrottlingException方法的具体用法?Python exceptions.ServerSideRequestThrottlingException怎么用?Python exceptions.ServerSideRequestThrottlingException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgoapi.exceptions
的用法示例。
在下文中一共展示了exceptions.ServerSideRequestThrottlingException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: accept_tos
# 需要导入模块: from pgoapi import exceptions [as 别名]
# 或者: from pgoapi.exceptions import ServerSideRequestThrottlingException [as 别名]
def accept_tos(username, password):
flag = False
while not flag:
try:
api = PGoApi()
#Set spawn to NYC
api.set_position(49.4536783, 11.077678699999979, 299.0)
api.login('ptc', username, password)
time.sleep(0.5)
req = api.create_request()
req.mark_tutorial_complete(tutorials_completed = 0, send_marketing_emails = False, send_push_notifications = False)
response = req.call()
print('Accepted Terms of Service for {}'.format(username))
flag = True
except ServerSideRequestThrottlingException:
print('This happens, just restart')
示例2: start
# 需要导入模块: from pgoapi import exceptions [as 别名]
# 或者: from pgoapi.exceptions import ServerSideRequestThrottlingException [as 别名]
def start(self):
self.login()
while True:
try:
self.spin_fort()
self.check_farming()
if not self.farming_mode:
self.snipe_pokemon()
self.check_awarded_badges()
self.inventorys.check_pokemons()
self.check_limit()
except (AuthException, NotLoggedInException, ServerSideRequestThrottlingException, TypeError, KeyError) as e:
self.logger.error(e)
self.logger.info(
'Token Expired, wait for 20 seconds.'
)
time.sleep(20)
self.login()
continue
示例3: acceptTos
# 需要导入模块: from pgoapi import exceptions [as 别名]
# 或者: from pgoapi.exceptions import ServerSideRequestThrottlingException [as 别名]
def acceptTos(username, password, pos):
api = PGoApi()
api.set_position(pos[0], pos[1], 0.0)
retryCount = 0
while True:
try:
api.login('ptc', username, password)
break
except AuthException, NotLoggedInException:
time.sleep(0.15)
if retryCount > 3:
return False
retryCount += 1
except ServerSideRequestThrottlingException:
time.sleep(requestSleepTimer)
if requestSleepTimer == 5.1:
logQueue.put(click.style('[TOS accepter] Received slow down warning. Using max delay of 5.1 already.', fg='red', bold=True))
else:
logQueue.put(click.style('[TOS accepter] Received slow down warning. Increasing delay from %d to %d.' % (requestSleepTimer, requestSleepTimer+0.2), fg='red', bold=True))
requestSleepTimer += 0.2
time.sleep(2)
req = api.create_request()
req.mark_tutorial_complete(tutorials_completed = 0, send_marketing_emails = False, send_push_notifications = False)
response = req.call()
if type(response) == dict and response['status_code'] == 1 and response['responses']['MARK_TUTORIAL_COMPLETE']['success'] == True:
return True
return False
示例4: accept_tos
# 需要导入模块: from pgoapi import exceptions [as 别名]
# 或者: from pgoapi.exceptions import ServerSideRequestThrottlingException [as 别名]
def accept_tos(username, password, location, proxy):
try:
accept_tos_helper(username, password, location, proxy)
except ServerSideRequestThrottlingException as e:
print('Server side throttling, Waiting 10 seconds.')
time.sleep(10)
accept_tos_helper(username, password, location, proxy)
except NotLoggedInException as e1:
print('Could not login, Waiting for 10 seconds')
time.sleep(10)
accept_tos_helper(username, password, location, proxy)
示例5: request
# 需要导入模块: from pgoapi import exceptions [as 别名]
# 或者: from pgoapi.exceptions import ServerSideRequestThrottlingException [as 别名]
def request(self, endpoint, subrequests, player_position):
if not self._auth_provider or self._auth_provider.is_login() is False:
raise NotLoggedInException()
request_proto = self._build_main_request(subrequests, player_position)
response = self._make_rpc(endpoint, request_proto)
response_dict = self._parse_main_response(response, subrequests)
self.check_authentication(response_dict)
"""
some response validations
"""
if isinstance(response_dict, dict):
status_code = response_dict.get('status_code', None)
if status_code == 102:
raise AuthTokenExpiredException()
elif status_code == 52:
raise ServerSideRequestThrottlingException("Request throttled by server... slow down man")
elif status_code == 53:
api_url = response_dict.get('api_url', None)
if api_url is not None:
exception = ServerApiEndpointRedirectException()
exception.set_redirected_endpoint(api_url)
raise exception
else:
raise UnexpectedResponseException()
return response_dict