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


Python app_log.debug函数代码示例

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


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

示例1: update_stats

def update_stats(stats):
    """Get updated stats for each host
    
    If a host fails to reply,
    assume it is is down and assign it zero availability and capacity
    """

    http_client = AsyncHTTPClient()
    futures = {}
    for host in stats.keys():
        app_log.debug("Checking stats on %s" % host)
        req = HTTPRequest(host + '/stats')
        futures[host] = http_client.fetch(req)
    
    for host, f in futures.items():
        try:
            reply = yield f
            data = json.loads(reply.body.decode('utf8'))
        except Exception as e:
            app_log.error("Failed to get stats for %s: %s", host, e)
            if host in stats:
                stats[host] = {'available': 0, 'capacity': 0, 'down': True}
        else:
            app_log.debug("Got stats from %s: %s", host, data)
            if host in stats:
                stats[host] = data
开发者ID:thewtex,项目名称:tmpnb-redirector,代码行数:26,代码来源:redirector.py

示例2: get_app_status

    def get_app_status(self, webOTT):
        params = {
            'status':      "new",
            'statusCode':  0,
            'userId':      "",
            'redirectURL': "",
            'authOTT': ""
        }

        I = self.storage.find(stage="auth", webOTT=webOTT)
        if not I:
            log.debug("Cannot find webOTT: {0}".format(webOTT))
            params['status'] = 'expired'
            return params

        if I.mobile_status:
            params['status'] = I.mobile_status

        if I.mobile_status == 'user' and I.userId:
            params['userId'] = I.userId

        authOTT = I.authOTT
        if authOTT and (str(I.status) == "200"):
            params['status'] = 'authenticate'
            params['authOTT'] = authOTT

        return params
开发者ID:apache,项目名称:incubator-milagro-mfa-server,代码行数:27,代码来源:mobile_flow.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: finish_notebook

 def finish_notebook(self, nbjson, download_url, home_url=None, msg=None, breadcrumbs=None):
     """render a notebook from its JSON body.
     
     download_url is required, home_url is not.
     
     msg is extra information for the log message when rendering fails.
     """
     if msg is None:
         msg = download_url
     try:
         app_log.debug("Requesting render of %s", download_url)
         with self.time_block("Rendered %s" % download_url):
             nbhtml, config = yield self.pool.submit(
                 render_notebook, self.exporter, nbjson, download_url,
                 config=self.config,
             )
     except NbFormatError as e:
         app_log.error("Invalid notebook %s: %s", msg, e)
         raise web.HTTPError(400, str(e))
     except Exception as e:
         app_log.error("Failed to render %s", msg, exc_info=True)
         raise web.HTTPError(400, str(e))
     else:
         app_log.debug("Finished render of %s", download_url)
     
     html = self.render_template('notebook.html',
         body=nbhtml,
         download_url=download_url,
         home_url=home_url,
         date=datetime.utcnow().strftime(date_fmt),
         breadcrumbs=breadcrumbs,
         **config)
     yield self.cache_and_finish(html)
开发者ID:mariusvniekerk,项目名称:nbviewer,代码行数:33,代码来源:handlers.py

示例5: get

    def get(self):
        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)
        cookie_state = self.get_secure_cookie(self.hub_auth.state_cookie_name)
        next_url = None
        if arg_state or cookie_state:
            # clear cookie state now that we've consumed it
            self.clear_cookie(self.hub_auth.state_cookie_name)
            if isinstance(cookie_state, bytes):
                cookie_state = cookie_state.decode('ascii', 'replace')
            # check that state matches
            if arg_state != cookie_state:
                app_log.debug("oauth state %r != %r", arg_state, cookie_state)
                raise HTTPError(403, "oauth state does not match")
            next_url = self.hub_auth.get_next_url(cookie_state)
        # TODO: make async (in a Thread?)
        token = self.hub_auth.token_for_code(code)
        user_model = self.hub_auth.user_for_token(token)
        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:angelapper,项目名称:jupyterhub,代码行数:27,代码来源:auth.py

示例6: remove_client

 def remove_client(cls, email):
     """
     移除client
     @param email:
     """
     app_log.debug("remove client[{0}]".format(email))
     del cls._CLIENTS_MAP[email]
开发者ID:cls1997,项目名称:chat,代码行数:7,代码来源:manager.py

示例7: delete_all_references

def delete_all_references(resource, schema, idl):
    """
    Delete all occurrences of reference for resource
    Parameters:
        resource - resource whose references are to be
                   deleted from the entire DB
        schema - ovsdb schema object
        idl = ovs.db.idl.Idl instance
    """
    row = get_row_from_resource(resource, idl)
    #We get the tables that reference the row to delete table
    tables_reference = schema.references_table_map[resource.table]
    #Get the table name and column list we is referenced
    for table_name, columns_list in tables_reference.iteritems():
        app_log.debug("Table %s" % table_name)
        app_log.debug("Column list %s" % columns_list)
        #Iterate each row to see wich tuple has the reference
        for uuid, row_ref in idl.tables[table_name].rows.iteritems():
            #Iterate over each reference column and check if has the reference
            for column_name in columns_list:
                #get the referenced values
                reflist = get_column_data_from_row(row_ref, column_name)
                if reflist is not None:
                    #delete the reference on that row and column
                    delete_row_reference(reflist, row, row_ref, column_name)
开发者ID:bluecmd,项目名称:ops-restd,代码行数:25,代码来源:utils.py

示例8: get

    def get(self, path=None):
        '''Spawns a brand new server'''
        if path is None:
            # no path, use random prefix
            prefix = "user-" + sample_with_replacement(string.ascii_letters +
                                                       string.digits)
        else:
            prefix = path.lstrip('/').split('/', 1)[0]

        self.write("Initializing {}".format(prefix))

        container_id, ip, port = yield self.spawner.create_notebook_server(prefix,
                image=self.image, ipython_executable=self.ipython_executable,
                mem_limit=self.mem_limit, cpu_shares=self.cpu_shares,
                container_ip=self.container_ip,
                container_port=self.container_port)

        app_log.debug(ip, port, prefix, container_id)
        yield self.proxy(ip, port, prefix, container_id)

        # Wait for the notebook server to come up.
        yield self.wait_for_server(ip, port, prefix)

        if path is None:
            # Redirect the user to the configured redirect location
            
            # Take out a leading slash
            redirect_uri = self.redirect_uri.lstrip("/")
            url = "/".join(("/{}".format(prefix), redirect_uri))
        else:
            url = path
            if not url.startswith('/'):
                url = '/' + url
        app_log.debug("redirecting %s -> %s", self.request.path, url)
        self.redirect(url, permanent=False)
开发者ID:gitter-badger,项目名称:tmpnb,代码行数:35,代码来源:orchestrate.py

示例9: prepare

    def prepare(self):

        app_log.debug("Incoming request from %s: %s",
                      self.request.remote_ip,
                      self.request)

        if settings['auth_enabled'] and self.request.method != "OPTIONS":
            is_authenticated = userauth.is_user_authenticated(self)
        else:
            is_authenticated = True

        if not is_authenticated:
            self.set_status(httplib.UNAUTHORIZED)
            self.set_header("Link", "/login")
            self.finish()
        else:
            self.resource_path = parse_url_path(self.request.path,
                                                self.schema,
                                                self.idl,
                                                self.request.method)

            if self.resource_path is None:
                self.set_status(httplib.NOT_FOUND)
                self.finish()
            else:
                #If Match support
                match = self.process_if_match()
                if not match:
                    self.finish()
开发者ID:bluecmd,项目名称:ops-restd,代码行数:29,代码来源:base.py

示例10: main

def main():
    """ entry """
    try:
        conf = __import__('conf')
    except ImportError as e:
        app_log.critical("Unable to load site config. ({})".format(e))
        raise SystemExit()
    parse_command_line()

    if options.debug:
        app_log.setLevel(logging.DEBUG)

    if not options.debug:
        fork_processes(None)
    options.port += task_id() or 0

    if not os.path.isdir(conf.app_path):
        app_log.critical("{p} isn't accessible, maybe "
                         "create it?".format(p=conf.app_path))
        raise SystemExit()
    app_log.debug("Starting {name} on port {port}".format(name=conf.name,
                                                          port=options.port))
    # initialize the application
    tornado.httpserver.HTTPServer(Application(options,
                                              conf)).listen(options.port,
                                                            '0.0.0.0')
    ioloop = tornado.ioloop.IOLoop.instance()
    if options.debug:
        tornado.autoreload.start(ioloop)
    # enter the Tornado IO loop
    ioloop.start()
开发者ID:sarahjanesllc-labs,项目名称:brutus,代码行数:31,代码来源:cli.py

示例11: load_by_name

 def load_by_name(self, name):
     try:
         return load_by_name('app.system.cmf.%s' % (name.lower(),),
                             name.capitalize())()
     except ImportError as e:
         app_log.debug(e)
         return False
开发者ID:battlemidget,项目名称:cage-cmf,代码行数:7,代码来源:handler.py

示例12: 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

示例13: __init__

    def __init__(self, commons):
        self.commons = commons
        app_log.debug("Application path (%s)" % (self.commons['script_location'],))

        urls = [
            (r"/(.*)", tornado.web.StaticFileHandler,
             {"path" : os.path.join(self.commons['script_location'],
                                    'app',
                                    'index.html')}),
            (r"/partials/(.*)", tornado.web.StaticFileHandler,
             {"path" : os.path.join(self.commons['script_location'],
                                    'app',
                                    'partials')}),

        ]

        settings = dict(
            template_path=None,
            static_path=os.path.join(self.commons['script_location'],
                                     'app'),
            xsrf_cookies=False if options.debug else True,
            cookie_secret='i love my dog!',
            debug=options.debug,
            )
        tornado.web.Application.__init__(self, urls, **settings)
开发者ID:battlemidget,项目名称:tornado-angularjs-skel,代码行数:25,代码来源:app.py

示例14: cache_and_finish

    def cache_and_finish(self, content=""):
        """finish a request and cache the result
        
        does not actually call finish - if used in @web.asynchronous,
        finish must be called separately. But we never use @web.asynchronous,
        because we are using gen.coroutine for async.
        
        currently only works if:
        
        - result is not written in multiple chunks
        - custom headers are not used
        """
        self.write(content)
        short_url = self.truncate(self.request.path)
        cache_data = pickle.dumps({"headers": self.cache_headers, "body": content}, pickle.HIGHEST_PROTOCOL)
        request_time = self.request.request_time()
        # set cache expiry to 120x request time
        # bounded by cache_expiry_min,max
        # a 30 second render will be cached for an hour
        expiry = max(min(120 * request_time, self.cache_expiry_max), self.cache_expiry_min)

        if self.request.uri in self.max_cache_uris:
            # if it's a link from the front page, cache for a long time
            expiry = self.cache_expiry_max

        log = app_log.info if expiry > self.cache_expiry_min else app_log.debug
        log("caching (expiry=%is) %s", expiry, short_url)
        try:
            with self.time_block("cache set %s" % short_url):
                yield self.cache.set(self.cache_key, cache_data, int(time.time() + expiry))
        except Exception:
            app_log.error("cache set for %s failed", short_url, exc_info=True)
        else:
            app_log.debug("cache set finished %s", short_url)
开发者ID:B-Rich,项目名称:nbviewer,代码行数:34,代码来源:handlers.py

示例15: prepare

    def prepare(self):
        self._boundary = None
        self._boundary_length = None
        self._boundary_padding = 2
        self._sep = b'\r\n\r\n'
        self._disp_header = None
        self._disp_params = None
        self._disp_name = None
        self._disp_buffer = None
        self._buffer = None

        content_type = self.request.headers.get('content-type', '')
        if not content_type.startswith('multipart/form-data'):
            raise HTTPError(400)

        fields = content_type.split(';')
        for field in fields:
            k, sep, v = field.strip().partition('=')
            if k == 'boundary' and v:
                if v.startswith('"') and v.endswith('"'):
                    v = v[1:-1]
                self._boundary = b'--' + utf8(v)
                self._boundary_length = len(self._boundary) + self._boundary_padding
                break

        if self._boundary is None:
            raise HTTPError(400)

        app_log.debug('boundary: %s', self._boundary)
开发者ID:hurie,项目名称:Tornado-PyPi-Proxy,代码行数:29,代码来源:streaming_upload.py


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