当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.NotLoggedInException方法代码示例

本文整理汇总了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 
开发者ID:PokemonAlpha,项目名称:AlphaBot,代码行数:24,代码来源:__init__.py

示例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'])) 
开发者ID:PokemonGoF,项目名称:PokemonGo-Bot,代码行数:36,代码来源:pokecli.py

示例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() 
开发者ID:PokemonGoF,项目名称:PokemonGo-Bot-Backup,代码行数:9,代码来源:api_wrapper_test.py

示例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 
开发者ID:diksm8,项目名称:pGo-create,代码行数:31,代码来源:pgocreate.py

示例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) 
开发者ID:sriyegna,项目名称:Pikaptcha,代码行数:13,代码来源:tos.py

示例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 
开发者ID:joaoanes,项目名称:pokescan,代码行数:33,代码来源:rpc_api.py


注:本文中的pgoapi.exceptions.NotLoggedInException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。