當前位置: 首頁>>代碼示例>>Python>>正文


Python RpcApi.request_proto方法代碼示例

本文整理匯總了Python中pgoapi.rpc_api.RpcApi.request_proto方法的典型用法代碼示例。如果您正苦於以下問題:Python RpcApi.request_proto方法的具體用法?Python RpcApi.request_proto怎麽用?Python RpcApi.request_proto使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pgoapi.rpc_api.RpcApi的用法示例。


在下文中一共展示了RpcApi.request_proto方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: call

# 需要導入模塊: from pgoapi.rpc_api import RpcApi [as 別名]
# 或者: from pgoapi.rpc_api.RpcApi import request_proto [as 別名]
    def call(self, use_dict = True):
        if (self._position_lat is None) or (self._position_lng is None):
            raise NoPlayerPositionSetException

        if self._auth_provider is None or not self._auth_provider.is_login():
            self.log.info('Not logged in')
            raise NotLoggedInException

        request = RpcApi(self._auth_provider, self.device_info)
        request._session = self.__parent__._session

        hash_server_token = self.__parent__.get_hash_server_token()
        request.activate_hash_server(hash_server_token)

        response = None
        execute = True
        
        while execute:
            execute = False

            try:
                response = request.request(self._api_endpoint, self._req_method_list, self._req_platform_list, self.get_position(), use_dict)
            except AuthTokenExpiredException as e:
                """
                This exception only occures if the OAUTH service provider (google/ptc) didn't send any expiration date
                so that we are assuming, that the access_token is always valid until the API server states differently.
                """
                try:
                    self.log.info('Access Token rejected! Requesting new one...')
                    self._auth_provider.get_access_token(force_refresh=True)
                except Exception as e:
                    error = 'Reauthentication failed: {}'.format(e)
                    self.log.error(error)
                    raise NotLoggedInException(error)

                request.request_proto = None  # reset request and rebuild
                execute = True  # reexecute the call
            except ServerApiEndpointRedirectException as e:
                self.log.info('API Endpoint redirect... re-execution of call')
                new_api_endpoint = e.get_redirected_endpoint()

                self._api_endpoint = parse_api_endpoint(new_api_endpoint)
                self.__parent__.set_api_endpoint(self._api_endpoint)

                execute = True  # reexecute the call

        # cleanup after call execution
        self._req_method_list = []

        return response
開發者ID:Devilkk,項目名稱:pgoapi,代碼行數:52,代碼來源:pgoapi.py


注:本文中的pgoapi.rpc_api.RpcApi.request_proto方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。