本文整理匯總了Python中pgoapi.exceptions.NotLoggedInException方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.NotLoggedInException方法的具體用法?Python exceptions.NotLoggedInException怎麽用?Python exceptions.NotLoggedInException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pgoapi.exceptions
的用法示例。
在下文中一共展示了exceptions.NotLoggedInException方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: from pgoapi import exceptions [as 別名]
# 或者: from pgoapi.exceptions import NotLoggedInException [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
示例2: report_summary
# 需要導入模塊: from pgoapi import exceptions [as 別名]
# 或者: from pgoapi.exceptions import NotLoggedInException [as 別名]
def report_summary(bot):
if bot.metrics.start_time is None:
return # Bot didn't actually start, no metrics to show.
metrics = bot.metrics
try:
metrics.capture_stats()
except NotLoggedInException:
bot.event_manager.emit(
'api_error',
sender=bot,
level='info',
formatted='Not logged in, reconnecting in {:d} seconds'.format(5)
)
time.sleep(5)
return
logger.info('')
logger.info('Ran for {}'.format(metrics.runtime()))
logger.info('Total XP Earned: {} Average: {:.2f}/h'.format(metrics.xp_earned(), metrics.xp_per_hour()))
logger.info('Travelled {:.2f}km'.format(metrics.distance_travelled()))
logger.info('Visited {} stops'.format(metrics.visits['latest'] - metrics.visits['start']))
logger.info('Encountered {} pokemon, {} caught, {} released, {} evolved, {} never seen before ({})'
.format(metrics.num_encounters(), metrics.num_captures(), metrics.releases,
metrics.num_evolutions(), metrics.num_new_mons(), metrics.uniq_caught()))
logger.info('Threw {} pokeball{}'.format(metrics.num_throws(), '' if metrics.num_throws() == 1 else 's'))
logger.info('Earned {} Stardust'.format(metrics.earned_dust()))
logger.info('Hatched eggs {}'.format(metrics.hatched_eggs(0)))
if (metrics.next_hatching_km(0)):
logger.info('Next egg hatches in {:.2f} km'.format(metrics.next_hatching_km(0)))
logger.info('')
if metrics.highest_cp is not None:
logger.info('Highest CP Pokemon: {}'.format(metrics.highest_cp['desc']))
if metrics.most_perfect is not None:
logger.info('Most Perfect Pokemon: {}'.format(metrics.most_perfect['desc']))
示例3: test_raises_not_logged_in_exception
# 需要導入模塊: from pgoapi import exceptions [as 別名]
# 或者: from pgoapi.exceptions import NotLoggedInException [as 別名]
def test_raises_not_logged_in_exception(self):
api = ApiWrapper(get_fake_conf())
api.set_position(*(42, 42, 0))
request = api.create_request()
request.get_inventory(test='awesome')
with self.assertRaises(NotLoggedInException):
request.call()
示例4: acceptTos
# 需要導入模塊: from pgoapi import exceptions [as 別名]
# 或者: from pgoapi.exceptions import NotLoggedInException [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
示例5: accept_tos
# 需要導入模塊: from pgoapi import exceptions [as 別名]
# 或者: from pgoapi.exceptions import NotLoggedInException [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)
示例6: request
# 需要導入模塊: from pgoapi import exceptions [as 別名]
# 或者: from pgoapi.exceptions import NotLoggedInException [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