本文整理匯總了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