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


Python client_exceptions.ClientConnectorError方法代码示例

本文整理汇总了Python中aiohttp.client_exceptions.ClientConnectorError方法的典型用法代码示例。如果您正苦于以下问题:Python client_exceptions.ClientConnectorError方法的具体用法?Python client_exceptions.ClientConnectorError怎么用?Python client_exceptions.ClientConnectorError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiohttp.client_exceptions的用法示例。


在下文中一共展示了client_exceptions.ClientConnectorError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __post

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def __post(self, payload):
        header = {'Content-type': 'application/json'}
        try:
            if self._session is None:
                async with ClientSession() as session:
                    async with session.post(self._url, json=payload, headers=header, timeout=10) as response:
                        res = json.loads(await response.content.read(-1))
            else:
                async with self._session.post(self._url, json=payload, headers=header, timeout=10) as response:
                    res = json.loads(await response.content.read(-1))
            if res['error'] != 0:
                if res['result'] != '':
                    raise SDKException(ErrorCode.other_error(res['result']))
                else:
                    raise SDKException(ErrorCode.other_error(res['desc']))
        except (asyncio.TimeoutError, client_exceptions.ClientConnectorError):
            raise SDKException(ErrorCode.connect_timeout(self._url)) from None
        return res 
开发者ID:ontio,项目名称:ontology-python-sdk,代码行数:20,代码来源:aiorpc.py

示例2: __post

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def __post(self, url: str, data: str):
        try:
            if self.__session is None:
                async with ClientSession() as session:
                    async with session.post(url, data=data, timeout=10) as response:
                        res = json.loads(await response.content.read(-1))
            else:
                async with self.__session.post(url, data=data, timeout=10) as response:
                    res = json.loads(await response.content.read(-1))
            if res['Error'] != 0:
                if res['Result'] != '':
                    raise SDKException(ErrorCode.other_error(res['Result']))
                else:
                    raise SDKException(ErrorCode.other_error(res['Desc']))
            return res
        except (asyncio.TimeoutError, client_exceptions.ClientConnectorError):
            raise SDKException(ErrorCode.connect_timeout(self._url)) from None 
开发者ID:ontio,项目名称:ontology-python-sdk,代码行数:19,代码来源:aiorestful.py

示例3: __get

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def __get(self, url):
        try:
            if self.__session is None:
                async with ClientSession() as session:

                    async with session.get(url, timeout=10) as response:
                        res = json.loads(await response.content.read(-1))
            else:
                async with self.__session.get(url, timeout=10) as response:
                    res = json.loads(await response.content.read(-1))
            if res['Error'] != 0:
                if res['Result'] != '':
                    raise SDKException(ErrorCode.other_error(res['Result']))
                else:
                    raise SDKException(ErrorCode.other_error(res['Desc']))
            return res
        except (asyncio.TimeoutError, client_exceptions.ClientConnectorError):
            raise SDKException(ErrorCode.connect_timeout(self._url)) from None 
开发者ID:ontio,项目名称:ontology-python-sdk,代码行数:20,代码来源:aiorestful.py

示例4: initialize_wallet

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def initialize_wallet(self, _salt, _passphrase, bech32, rbf):
        try:
            server, port, proto = await nowallet.get_random_server(self.loop)
            connection = nowallet.Connection(self.loop, server, port, proto)
            self.wallet = nowallet.Wallet(
                _salt, _passphrase, connection, self.loop, self.chain)
            await connection.do_connect()
        except (SocksConnectionError, ClientConnectorError):
            self.print_json({
                "error": "Make sure Tor is installed and running before using nowalletd."
            })
            sys.exit(1)

        self.wallet.bech32 = bech32
        self.rbf = rbf

        await self.wallet.discover_all_keys()
        self.print_history()
        self.wallet.new_history = False 
开发者ID:metamarcdw,项目名称:nowallet,代码行数:21,代码来源:nowalletd.py

示例5: check_send_exception

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def check_send_exception():
    try:
        global SEND_EXCEPTION
        if SEND_EXCEPTION:
            raise SEND_EXCEPTION

    # An StitchClientResponseError means we received > 2xx response
    # Try to parse the "message" from the
    # json body of the response, since Stitch should include
    # the human-oriented message in that field. If there are
    # any errors parsing the message, just include the
    # stringified response.
    except StitchClientResponseError as exc:
        try:
            msg = "{}: {}".format(str(exc.status), exc.response_body)
        except: # pylint: disable=bare-except
            LOGGER.exception('Exception while processing error response')
            msg = '{}'.format(exc)
        raise TargetStitchException('Error persisting data to Stitch: ' +
                                    msg)

    # A ClientConnectorErrormeans we
    # couldn't even connect to stitch. The exception is likely
    # to be very long and gross. Log the full details but just
    # include the summary in the critical error message.
    except ClientConnectorError as exc:
        LOGGER.exception(exc)
        raise TargetStitchException('Error connecting to Stitch')

    except concurrent.futures._base.TimeoutError as exc: #pylint: disable=protected-access
        raise TargetStitchException("Timeout sending to Stitch") 
开发者ID:singer-io,项目名称:target-stitch,代码行数:33,代码来源:__init__.py

示例6: call

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def call(self, method, *params, **kwargs):
        if self.api_client is None:
            await self.init_client()

        try:
            return await self.api_client.request(
                method, *params,
                trim_log_values=True, **kwargs
            )
        except JsonRpcClientError as e:
            # fix for jsonrpcclient < 3.3.1
            if str(e) == INVALID_PARAMS:
                if len(params) == 1 and (isinstance(params[0], (dict, list))):
                    params = (list(params),)
                    return await self.api_client.request(
                        method, *params,
                        trim_log_values=True, **kwargs
                    )

            raise e
        except ClientConnectorError as e:
            logging.warning(f"Client connect exception captured, please check network or Zilliqa API server. Exception: {e}")
        except asyncio.CancelledError as e:
            logging.warning(f"Cancelled exception captured: {e}")
        except asyncio.TimeoutError as e:
            logging.warning("Timeout exception captured, please check network or Zilliqa API server")
        except:
            logging.warning(f"Unknown exception captured: {e}") 
开发者ID:DurianStallSingapore,项目名称:Zilliqa-Mining-Proxy,代码行数:30,代码来源:zilliqa_api.py

示例7: do_login

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def do_login(self):
        email = self.root.ids.email_field.text
        passphrase = self.root.ids.pass_field.text
        confirm = self.root.ids.confirm_field.text
        if not email or not passphrase or not confirm:
            self.show_dialog("Error", "All fields are required.")
            return
        if passphrase != confirm:
            self.show_dialog("Error", "Passwords did not match.")
            return
        self.bech32 = self.root.ids.bech32_checkbox.active
        self.menu_items[0]["text"] = "View {}PUB".format(self.pub_char.upper())

        self.root.ids.sm.current = "wait"
        try:
            await self.do_login_tasks(email, passphrase)
        except (SocksConnectionError, ClientConnectorError):
            self.show_dialog("Error",
                             "Make sure Tor/Orbot is installed and running before using Nowallet.",
                             cb=lambda x: sys.exit(1))
            return
        self.update_screens()
        self.root.ids.sm.current = "main"
        await asyncio.gather(
            self.new_history_loop(),
            self.do_listen_task()
        ) 
开发者ID:metamarcdw,项目名称:nowallet,代码行数:29,代码来源:main.py

示例8: fetch

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def fetch(self, sem, url, cname, session):
		async with sem:
			response_obj = {}
			response_obj['subdomain'] = "http://" + url
			response_obj['cname'] = cname
			response_obj['takeover'] = False
			for obj in PROVIDER_LIST:
				if all(key in cname for key in obj['cname']):
					try:
						async with session.get(response_obj['subdomain']) as response:
							print("Testing: {}".format(url))
							print("URL: {} Status: {}".format(response.url, response.status))
							data = await response.read()							
							for r in obj['response']:
								if r in str(data):
									response_obj['takeover'] = True
									response_obj['type'] = {}
									response_obj['type']['confidence'] = "HIGH"
									response_obj['type']['provider'] = obj['name']
									response_obj['type']['response'] = r
									response_obj['type']['response_status'] = response.status
									print("Got one: {}".format(response_obj))
									return response_obj
							return response_obj
					except ClientConnectorError as e:
						print("Connection Error: {} CNAME: {}".format(e,cname))
						response_obj['takeover'] = True
						response_obj['type'] = {}
						response_obj['type']['confidence'] = "MEDIUM"
						response_obj['type']['provider'] = obj['name']
						response_obj['type']['response'] = e
						response_obj['type']['response_status'] = None
						return response_obj
					except Exception as e:
						print("Doh!: {} ErrorType: {} CNAME: {}".format(e, type(e),cname))
			return None 
开发者ID:SimplySecurity,项目名称:simplydomain,代码行数:38,代码来源:module_checker.py

示例9: call

# 需要导入模块: from aiohttp import client_exceptions [as 别名]
# 或者: from aiohttp.client_exceptions import ClientConnectorError [as 别名]
def call(
        self,
        method: str,
        data: Dict[str, Any] = None,
        *,
        token: str = None,
        json_mode: bool = False,
    ) -> APIResponse:
        """Call API methods."""

        async with aiohttp.ClientSession() as session:
            headers = {
                'Content-Type': 'application/x-www-form-urlencoded',
            }
            payload: Union[str, aiohttp.FormData]
            if json_mode:
                payload = json.dumps(data)
                headers['Content-Type'] = 'application/json'
                headers['Authorization'] = 'Bearer {}'.format(
                    token or self.config.TOKEN
                )
            else:
                payload = aiohttp.FormData(data or {})
                payload.add_field('token', token or self.config.TOKEN)

            try:
                async with session.post(
                    'https://slack.com/api/{}'.format(method),
                    data=payload,
                    headers=headers,
                ) as response:
                    try:
                        result = await response.json(loads=json.loads)
                    except ContentTypeError:
                        result = await response.text()
                    return APIResponse(
                        body=result,
                        status=response.status,
                        headers=response.headers,
                    )
            except ClientConnectorError:
                raise APICallError(
                    'fail to call {} with {}'.format(method, data)
                ) 
开发者ID:item4,项目名称:yui,代码行数:46,代码来源:bot.py


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