• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python app_log.warning函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tornado.log.app_log.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: wait_for_http_server

def wait_for_http_server(url, timeout=10):
    """Wait for an HTTP Server to respond at url.

    Any non-5XX response code will do, even 404.
    """
    loop = ioloop.IOLoop.current()
    tic = loop.time()
    client = AsyncHTTPClient()
    while loop.time() - tic < timeout:
        try:
            r = yield client.fetch(url, follow_redirects=False)
        except HTTPError as e:
            if e.code >= 500:
                # failed to respond properly, wait and try again
                if e.code != 599:
                    # we expect 599 for no connection,
                    # but 502 or other proxy error is conceivable
                    app_log.warning(
                        "Server at %s responded with error: %s", url, e.code)
                yield gen.sleep(0.1)
            else:
                app_log.debug("Server at %s responded with %s", url, e.code)
                return
        except (OSError, socket.error) as e:
            if e.errno not in {errno.ECONNABORTED, errno.ECONNREFUSED, errno.ECONNRESET}:
                app_log.warning("Failed to connect to %s (%s)", url, e)
            yield gen.sleep(0.1)
        else:
            return

    raise TimeoutError(
        "Server at {url} didn't respond in {timeout} seconds".format(**locals())
    )
开发者ID:rlugojr,项目名称:jupyterhub,代码行数:33,代码来源:utils.py


示例2: _api_request

    def _api_request(self, method, url, **kwargs):
        """Make an API request"""
        allow_404 = kwargs.pop('allow_404', False)
        headers = kwargs.setdefault('headers', {})
        headers.setdefault('Authorization', 'token %s' % self.api_token)
        try:
            r = requests.request(method, url, **kwargs)
        except requests.ConnectionError as e:
            app_log.error("Error connecting to %s: %s", self.api_url, e)
            msg = "Failed to connect to Hub API at %r." % self.api_url
            msg += "  Is the Hub accessible at this URL (from host: %s)?" % socket.gethostname()
            if '127.0.0.1' in self.api_url:
                msg += "  Make sure to set c.JupyterHub.hub_ip to an IP accessible to" + \
                       " single-user servers if the servers are not on the same host as the Hub."
            raise HTTPError(500, msg)

        data = None
        if r.status_code == 404 and allow_404:
            pass
        elif r.status_code == 403:
            app_log.error("I don't have permission to check authorization with JupyterHub, my auth token may have expired: [%i] %s", r.status_code, r.reason)
            app_log.error(r.text)
            raise HTTPError(500, "Permission failure checking authorization, I may need a new token")
        elif r.status_code >= 500:
            app_log.error("Upstream failure verifying auth token: [%i] %s", r.status_code, r.reason)
            app_log.error(r.text)
            raise HTTPError(502, "Failed to check authorization (upstream problem)")
        elif r.status_code >= 400:
            app_log.warning("Failed to check authorization: [%i] %s", r.status_code, r.reason)
            app_log.warning(r.text)
            raise HTTPError(500, "Failed to check authorization")
        else:
            data = r.json()

        return data
开发者ID:angelapper,项目名称:jupyterhub,代码行数:35,代码来源:auth.py


示例3: get

    def get(self, path=None):
        '''Spawns a brand new server'''

        try:
            if path is None:
                # No path. Assign a prelaunched container from the pool and redirect to it.
                # Append self.redirect_uri to the redirect target.
                container_path = self.pool.acquire().path
                app_log.info("Allocated [%s] from the pool.", container_path)

                url = "/{}/{}".format(container_path, self.redirect_uri)
            else:
                path_parts = path.lstrip('/').split('/', 1)
                container_path = path_parts[0]

                # Scrap a container from the pool and replace it with an ad-hoc replacement.
                # This takes longer, but is necessary to support ad-hoc containers
                yield self.pool.adhoc(container_path)

                app_log.info("Allocated ad-hoc container at [%s].", container_path)
                url = path

            app_log.debug("Redirecting [%s] -> [%s].", self.request.path, url)
            self.redirect(url, permanent=False)
        except spawnpool.EmptyPoolError:
            app_log.warning("The container pool is empty!")
            self.render("full.html", cull_period=self.cull_period)
开发者ID:Carreau,项目名称:tmpnb,代码行数:27,代码来源:orchestrate.py


示例4: _check_hub_authorization

    def _check_hub_authorization(self, url, cache_key=None, use_cache=True):
        """Identify a user with the Hub
        
        Args:
            url (str): The API URL to check the Hub for authorization
                       (e.g. http://127.0.0.1:8081/hub/api/authorizations/token/abc-def)
            cache_key (str): The key for checking the cache
            use_cache (bool): Specify use_cache=False to skip cached cookie values (default: True)

        Returns:
            user_model (dict): The user model, if a user is identified, None if authentication fails.

        Raises an HTTPError if the request failed for a reason other than no such user.
        """
        if use_cache:
            if cache_key is None:
                raise ValueError("cache_key is required when using cache")
            # check for a cached reply, so we don't check with the Hub if we don't have to
            try:
                return self.cache[cache_key]
            except KeyError:
                app_log.debug("HubAuth cache miss: %s", cache_key)

        data = self._api_request('GET', url, allow_404=True)
        if data is None:
            app_log.warning("No Hub user identified for request")
        else:
            app_log.debug("Received request from Hub user %s", data)
        if use_cache:
            # cache result
            self.cache[cache_key] = data
        return data
开发者ID:vilhelmen,项目名称:jupyterhub,代码行数:32,代码来源:auth.py


示例5: get

    def get(self):
        error = self.get_argument("error", False)
        if error:
            msg = self.get_argument("error_description", error)
            raise HTTPError(400, "Error in oauth: %s" % msg)

        code = self.get_argument("code", False)
        if not code:
            raise HTTPError(400, "oauth callback made without a token")

        # validate OAuth state
        arg_state = self.get_argument("state", None)
        if arg_state is None:
            raise HTTPError("oauth state is missing. Try logging in again.")
        cookie_name = self.hub_auth.get_state_cookie_name(arg_state)
        cookie_state = self.get_secure_cookie(cookie_name)
        # clear cookie state now that we've consumed it
        self.clear_cookie(cookie_name, path=self.hub_auth.base_url)
        if isinstance(cookie_state, bytes):
            cookie_state = cookie_state.decode('ascii', 'replace')
        # check that state matches
        if arg_state != cookie_state:
            app_log.warning("oauth state %r != %r", arg_state, cookie_state)
            raise HTTPError(403, "oauth state does not match. Try logging in again.")
        next_url = self.hub_auth.get_next_url(cookie_state)
        # TODO: make async (in a Thread?)
        token = self.hub_auth.token_for_code(code)
        session_id = self.hub_auth.get_session_id(self)
        user_model = self.hub_auth.user_for_token(token, session_id=session_id)
        if user_model is None:
            raise HTTPError(500, "oauth callback failed to identify a user")
        app_log.info("Logged-in user %s", user_model)
        self.hub_auth.set_cookie(self, token)
        self.redirect(next_url or self.hub_auth.base_url)
开发者ID:vilhelmen,项目名称:jupyterhub,代码行数:34,代码来源:auth.py


示例6: get

    def get(self, path=None):
        '''Spawns a brand new server'''
        if self.allow_origin:
            self.set_header("Access-Control-Allow-Origin", self.allow_origin)
        try:
            if path is None:
                # No path. Assign a prelaunched container from the pool and redirect to it.
                # Append self.redirect_uri to the redirect target.
                container_path = self.pool.acquire().path
                app_log.info("Allocated [%s] from the pool.", container_path)

                url = "/{}/{}".format(container_path, self.redirect_uri)
            else:
                # Split /user/{some_user}/long/url/path and acquire {some_user}
                path_parts = path.lstrip('/').split('/', 2)
                app_log.info("path parts: %s", path_parts)
                user = path_parts[1]

                # Scrap a container from the pool and replace it with an ad-hoc replacement.
                # This takes longer, but is necessary to support ad-hoc containers
                yield self.pool.adhoc(user, path_parts[-1])

                url = "/" + "/".join(path_parts[:2])
                app_log.info("new url: %s", url)

            app_log.debug("Redirecting [%s] -> [%s].", self.request.path, url)
            self.redirect(url, permanent=False)
        except spawnpool.EmptyPoolError:
            app_log.warning("The container pool is empty!")
            self.render("full.html", cull_period=self.cull_period)
开发者ID:betatim,项目名称:tmpnb,代码行数:30,代码来源:orchestrate.py


示例7: add_error_message_to_slug

	def add_error_message_to_slug(self, error_string, args_to_delete=[], msg_categ="error" ) : 
		""" add an "error" arg to url slug """

		slug_ = self.request.arguments
		app_log.info("... add_error_message_to_slug / slug_ : \n %s ", pformat( slug_ ) )

		# create a complete clean slug if no slug
		if slug_ == {} :
			error_slug = u"?" + u"error=" + tornado.escape.url_escape(error_string)
		
		# add error arg to existing slug
		else : 

			slug_without_error = deepcopy(slug_)			

			### clean existing slug from existing error arg if any
			# for arg_to_delete in args_to_delete + DEFAULT_ERROR_ARGS_TO_DELETE : 
			# 	try : 
			# 		del slug_without_error[arg_to_delete]
			# 	except :
			# 		pass
			slug_without_error = self.clean_slug(slug_without_error, args_to_delete + DEFAULT_ERROR_ARGS_TO_DELETE )

			app_log.warning("... add_error_message_to_slug / slug_without_error : \n %s ", pformat(slug_without_error) )

			# recreate slug
			error_dict	= { "error" : error_string }
			error_dict.update( slug_without_error )
			error_slug = u"?" + urllib.urlencode( error_dict, doseq=True)		

		app_log.info("... add_error_message_to_slug / error_slug : \n %s ", pformat(error_slug) )

		return error_slug
开发者ID:artem090587,项目名称:OpenScraper,代码行数:33,代码来源:base_handler.py


示例8: check

    def check(self, handler):
        """Check the rate limit for a handler.
        
        Identifies the source by ip and user-agent.
        
        If the rate limit is exceeded, raise HTTPError(429)
        """
        if not self.limit:
            return
        key = self.key_for_handler(handler)
        added = yield self.cache.add(key, 1, self.interval)
        if not added:
            # it's been seen before, use incr
            try:
                count = yield self.cache.incr(key)
            except Exception as e:
                app_log.warning("Failed to increment rate limit for %s", key)
                return

            app_log.debug("Rate limit remaining for %r: %s/%s", key, self.limit - count, self.limit)

            if count and count >= self.limit:
                minutes = self.interval // 60
                raise HTTPError(429,
                    "Rate limit exceeded for {ip} ({limit} req / {minutes} min)."
                    " Try again later.".format(
                        ip=handler.request.remote_ip,
                        limit=self.limit,
                        minutes=minutes,
                    )
                )
开发者ID:dalejung,项目名称:nbviewer,代码行数:31,代码来源:ratelimit.py


示例9: check_hub_user

    def check_hub_user(self, user_model):
        """Check whether Hub-authenticated user should be allowed.

        Returns the input if the user should be allowed, None otherwise.

        Override if you want to check anything other than the username's presence in hub_users list.

        Args:
            user_model (dict): the user model returned from :class:`HubAuth`
        Returns:
            user_model (dict): The user model if the user should be allowed, None otherwise.
        """
        if self.hub_users is None and self.hub_groups is None:
            # no whitelist specified, allow any authenticated Hub user
            return user_model
        name = user_model['name']
        if self.hub_users and name in self.hub_users:
            # user in whitelist
            return user_model
        elif self.hub_groups and set(user_model['groups']).union(self.hub_groups):
            # group in whitelist
            return user_model
        else:
            app_log.warning("Not allowing Hub user %s" % name)
            return None
开发者ID:Amerterasu,项目名称:jupyterhub,代码行数:25,代码来源:auth.py


示例10: get_company_exports_summary

    def get_company_exports_summary(self, org_id):
        db_ce = self.application.mysql_db_name("company-exports")
        if not db_ce:
            app_log.warning(
                "Cannot add '%s' data. Database `%s` not online.",
                "influence", db_ce)
            return

        data = {}

        sql = """
select
    {db_ce}.company.company_id,
    count(distinct({db_ce}.action.destination_id))
  from {db_ce}.action
    join {db_ce}.company using (company_id)
  where {db_ce}.company.caat_id = {caat_id}
;
""".format(**{
    "db_ce": db_ce,
    "caat_id": org_id
})

        try:
            result = self.orm.execute(sql).fetchone()
        except InternalError as e:
            print(e)
            return

        if result:
            (company_id, n_dest, ) = result
            data["companyExportsId"] = company_id
            data["destinationCount"] = n_dest

        sql = """
select
    count(distinct({db_ce}.rating.description))
  from {db_ce}.action
    join {db_ce}.company using (company_id)
    join {db_ce}.rating using (rating_id)
  where {db_ce}.company.caat_id = {caat_id}
    and {db_ce}.rating.description is not null
;
""".format(**{
    "db_ce": db_ce,
    "caat_id": org_id
})

        try:
            result = self.orm.execute(sql).fetchone()
        except InternalError as e:
            print(e)
            return

        if result:
            (n_rating, ) = result
            data["ratingCount"] = n_rating

        return data
开发者ID:ianmackinnon,项目名称:mango,代码行数:59,代码来源:org.py


示例11: _get_user_cookie

 def _get_user_cookie(self, handler):
     token = handler.get_secure_cookie(self.cookie_name)
     if token:
         user_model = self.user_for_token(token)
         if user_model is None:
             app_log.warning("Token stored in cookie may have expired")
             handler.clear_cookie(self.cookie_name)
         return user_model
开发者ID:angelapper,项目名称:jupyterhub,代码行数:8,代码来源:auth.py


示例12: observe

    def observe(self):
        '''Collect Ground Truth of what's actually running from Docker and the proxy.'''

        results = yield {
            "docker": self.spawner.list_notebook_servers(self.name_pattern, all=True),
            "proxy": self._proxy_routes()
        }

        self.container_ids = set()
        self.living_container_ids = []
        self.stopped_container_ids = []
        self.zombie_container_ids = []

        self.routes = set()
        self.live_routes = []
        self.stale_routes = []
        self.zombie_routes = []

        # Sort Docker results into living and dead containers.
        for container in results["docker"]:
            id = container['Id']
            self.container_ids.add(id)
            if container['Status'].startswith('Up'):
                self.living_container_ids.append(id)
            else:
                self.stopped_container_ids.append(id)

        now = datetime.utcnow()
        idle_cutoff = now - self.cull_idle
        started_cutoff = now - self.cull_max_age

        # Sort proxy routes into living, stale, and zombie routes.
        living_set = set(self.living_container_ids)
        for path, route in results["proxy"].items():
            last_activity_s = route.get('last_activity', None)
            container_id = route.get('container_id', None)
            if container_id:
                result = (path, container_id)
                if container_id in living_set:
                    try:
                        last_activity = datetime.strptime(last_activity_s, _date_fmt)
                        started = self.started.get(container_id, None)
                        self.routes.add(result)
                        if started and last_activity < idle_cutoff:
                            app_log.info("Culling %s, idle since %s", path, last_activity)
                            self.stale_routes.append(result)
                        elif started and started < started_cutoff:
                            app_log.info("Culling %s, up since %s", path, started)
                            self.stale_routes.append(result)
                        else:
                            app_log.debug("Container %s up since %s, idle since %s",
                                          path, started, last_activity)
                            self.live_routes.append(result)
                    except ValueError as e:
                        app_log.warning("Ignoring a proxy route with an unparsable activity date: %s", e)
                else:
                    # The container doesn't correspond to a living container.
                    self.zombie_routes.append(result)
开发者ID:apurva3000,项目名称:tmpnb,代码行数:58,代码来源:spawnpool.py


示例13: _parse_json_arguments

 def _parse_json_arguments(self):
     
     content_type = self.content_type
     
     if(content_type and content_type.find(r'application/json') >= 0):
         try:
             self.json_arguments = json_decode(self.request.body)
         except Exception as error:
             app_log.warning('Invalid application/json body: %s', error)
开发者ID:yxlwfds,项目名称:TornadoWeb,代码行数:9,代码来源:web.py


示例14: catch_error_message

	def catch_error_message (self):
		""" get and log error message if any """
		
		try:
			self.error_msg = self.get_argument("error")
			app_log.warning("\n... get_error_message / self.error_msg : %s ", self.error_msg )
		
		except:
			self.error_msg = ""
开发者ID:artem090587,项目名称:OpenScraper,代码行数:9,代码来源:base_handler.py


示例15: _get_user_cookie

 def _get_user_cookie(self, handler):
     token = handler.get_secure_cookie(self.cookie_name)
     session_id = self.get_session_id(handler)
     if token:
         token = token.decode('ascii', 'replace')
         user_model = self.user_for_token(token, session_id=session_id)
         if user_model is None:
             app_log.warning("Token stored in cookie may have expired")
             handler.clear_cookie(self.cookie_name)
         return user_model
开发者ID:vilhelmen,项目名称:jupyterhub,代码行数:10,代码来源:auth.py


示例16: post

 def post(self):
     '''Spawns a brand new server programatically'''
     try:
         url = self.pool.acquire().path
         app_log.info("Allocated [%s] from the pool.", url)
         app_log.debug("Responding with container url [%s].", url)
         self.write({'url': url})
     except spawnpool.EmptyPoolError:
         app_log.warning("The container pool is empty!")
         self.write({'status': 'full'})
开发者ID:jorgemarsal,项目名称:tmpnb,代码行数:10,代码来源:orchestrate.py


示例17: _register_handlers

    def _register_handlers(self, spec, handlers):
        """
        """

        handlers.append(spec)
        if spec.name:
            if spec.name in self.named_handlers:
                app_log.warning(
                    "Multiple handlers named %s; replacing previous value",
                    spec.name)
            self.named_handlers[spec.name] = spec
开发者ID:HankeyEngineering,项目名称:Zeus,代码行数:11,代码来源:application.py


示例18: process_rule

    def process_rule(self, rule: "Rule") -> "Rule":
        rule = super(ReversibleRuleRouter, self).process_rule(rule)

        if rule.name:
            if rule.name in self.named_rules:
                app_log.warning(
                    "Multiple handlers named %s; replacing previous value", rule.name
                )
            self.named_rules[rule.name] = rule

        return rule
开发者ID:bdarnell,项目名称:tornado,代码行数:11,代码来源:routing.py


示例19: find

 def find(cls, db, token):
     orm_token = super().find(db, token)
     if orm_token and not orm_token.client_id:
         app_log.warning(
             "Deleting stale oauth token for %s with no client",
             orm_token.user and orm_token.user.name,
         )
         db.delete(orm_token)
         db.commit()
         return
     return orm_token
开发者ID:vilhelmen,项目名称:jupyterhub,代码行数:11,代码来源:orm.py


示例20: emit

 async def emit(self, data):
     if type(data) is not str:
         serialized_data = json.dumps(data)
     else:
         serialized_data = data
     try:
         self.write('data: {}\n\n'.format(serialized_data))
         await self.flush()
     except StreamClosedError:
         app_log.warning("Stream closed while handling %s", self.request.uri)
         # raise Finish to halt the handler
         raise web.Finish()
开发者ID:gnestor,项目名称:binderhub,代码行数:12,代码来源:builder.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gen_log.debug函数代码示例发布时间:2022-05-27
下一篇:
Python app_log.warn函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap