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

Python app_log.info函数代码示例

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

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



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

示例1: show

def show(handlers, url_width, handler_width):
    app_log.info("=" * int(url_width + handler_width))
    app_log.info("%-*s%-*s" % (url_width, "URL", handler_width, "HANDLER"))
    app_log.info("=" * int(url_width + handler_width))
    for url, _ in handlers:
        app_log.info("%-*s%-*s" % (url_width, url, handler_width, _))
    app_log.info("=" * int(url_width + handler_width))
开发者ID:wujuguang,项目名称:discuzx-tools,代码行数:7,代码来源:tornado_proxy.py


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


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


示例4: cull_idle

def cull_idle(url, api_token, timeout):
    """cull idle single-user servers"""
    auth_header = {
            'Authorization': 'token %s' % api_token
        }
    req = HTTPRequest(url=url + '/api/users',
        headers=auth_header,
    )
    now = datetime.datetime.utcnow()
    cull_limit = now - datetime.timedelta(seconds=timeout)
    client = AsyncHTTPClient()
    resp = yield client.fetch(req)
    users = json.loads(resp.body.decode('utf8', 'replace'))
    futures = []
    for user in users:
        last_activity = parse_date(user['last_activity'])
        if user['server'] and last_activity < cull_limit:
            app_log.info("Culling %s (inactive since %s)", user['name'], last_activity)
            req = HTTPRequest(url=url + '/api/users/%s/server' % user['name'],
                method='DELETE',
                headers=auth_header,
            )
            futures.append((user['name'], client.fetch(req)))
        elif user['server'] and last_activity > cull_limit:
            app_log.debug("Not culling %s (active since %s)", user['name'], last_activity)

    for (name, f) in futures:
        yield f
        app_log.debug("Finished culling %s", name)
开发者ID:ctapobep,项目名称:docker-images,代码行数:29,代码来源:cull_idle_servers.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: main

def main():
    options.define('port', default=9005,
        help="Port for the REST API"
    )
    options.define('ip', default='127.0.0.1',
        help="IP address for the REST API"
    )
    options.define('host_mount', default='',
        help='Path where the host root is mounted in this container'
    )
    options.define('pool_prefix', default='',
        help='Prefix assigned by tmpnb to its pooled containers'
    )
    options.define('registration_key', default='',
        help='Registration key required to create new volumes'
    )

    options.parse_command_line()
    opts = options.options

    # regex from docker volume create
    api_handlers = [
        (r'/api/mounts(/([a-zA-Z0-9][a-zA-Z0-9_.-])+)?', MountsHandler),
        (r'/api/volumes', VolumesHander),
    ]

    api_app = web.Application(api_handlers)
    api_app.listen(opts.port, opts.ip, xheaders=True)
    app_log.info("Listening on {}:{}".format(opts.ip, opts.port))

    ioloop.IOLoop.instance().start()
开发者ID:data-exp-lab,项目名称:mostly-tmpnb,代码行数:31,代码来源:main.py


示例7: get

 def get(self, user, repo, ref, path):
     raw_url = u"https://raw.github.com/{user}/{repo}/{ref}/{path}".format(
         user=user, repo=repo, ref=ref, path=quote(path)
     )
     blob_url = u"https://github.com/{user}/{repo}/blob/{ref}/{path}".format(
         user=user, repo=repo, ref=ref, path=quote(path),
     )
     with self.catch_client_error():
         response = yield self.client.fetch(raw_url)
     
     if response.effective_url.startswith("https://github.com/{user}/{repo}/tree".format(
         user=user, repo=repo
     )):
         tree_url = "/github/{user}/{repo}/tree/{ref}/{path}/".format(
             user=user, repo=repo, ref=ref, path=quote(path),
         )
         app_log.info("%s is a directory, redirecting to %s", raw_url, tree_url)
         self.redirect(tree_url)
         return
     
     filedata = response.body
     
     if path.endswith('.ipynb'):
         try:
             nbjson = response_text(response)
         except Exception as e:
             app_log.error("Failed to decode notebook: %s", raw_url, exc_info=True)
             raise web.HTTPError(400)
         yield self.finish_notebook(nbjson, raw_url,
             home_url=blob_url,
             msg="file from GitHub: %s" % raw_url,
         )
     else:
         self.set_header("Content-Type", "text/plain")
         self.cache_and_finish(filedata)
开发者ID:DanGitOreilly,项目名称:nbviewer,代码行数:35,代码来源:handlers.py


示例8: _start_control

 def _start_control(self):
     app_log.info("Starting EE Control on port {port}".format(port=config.Control.Rest.PORT))
     self._control_process = _start_remote_rest_server(config.Control.Rest.BIN, config.Control.Rest.PORT,
                                                       config.Control.Rest.DEBUG)
     if self._control_process.is_running() and self._rest_server_listening(config.Control.Rest.BASE_URI):
         app_log.info("EEControl REST Server running")
     else:
         app_log.error("EEControl REST Server not running")
         exit(1)
     if self._is_engine_supported(
             _get_full_uri(config.Control.Rest.BASE_URI, config.Control.Rest.Endpoints.ENGINES)):
         app_log.info("{engine} supported by EE Control".format(engine=config.Engine.NAME))
     else:
         app_log.error("{engine} is not supported by EE Control".format(engine=config.Engine.NAME))
         exit(1)
     if self._set_engine(_get_full_uri(config.Control.Rest.BASE_URI, config.Control.Rest.Endpoints.ENGINES)):
         app_log.info("{engine} set by EE Control".format(engine=config.Engine.NAME))
     else:
         app_log.error("{engine} not set by EE Control".format(engine=config.Engine.NAME))
         exit(1)
     if self._connect_control():
         app_log.info("EE Control client connected to engine")
     else:
         app_log.error("EE Control client couldn't connect to engine")
         exit(1)
开发者ID:yotamhc,项目名称:obsi,代码行数:25,代码来源:manager.py


示例9: get

    def get(self, file_name, *args, **kwargs):

        if not file_name:
            return self.send_error(status_code=404)

        root_dir = os.path.dirname(os.path.dirname(__file__))
        file_path = os.path.join(root_dir, "../static/download/" + file_name)

        buf_size = 4096
        self.set_header("Content-Type", "application/octet-stream")
        self.set_header("Content-Disposition", "attachment; filename=" + file_name)

        try:
            download_file = open(file_path, "r")

            while True:
                data = download_file.read(buf_size)
                if not data:
                    break
                self.write(data)

            download_file.close()

            app_log.info("[{ip}] download file success: {name}".format(
                ip=self.request.remote_ip, name=file_path
            ))
        except IOError:
            app_log.info("[{ip}] download file fail: {name}".format(
                ip=self.request.remote_ip, name=file_path
            ))
            return self.send_error(status_code=404)

        self.finish()
开发者ID:Handsome2734,项目名称:PhoneManage,代码行数:33,代码来源:DownloadHandler.py


示例10: start

    def start(self):
        # reset all connections
        try:
            app_log.info("Starting Connection Manager!")
            if self.idl is not None:
                self.idl.close()

            # set up the schema and register all tables
            self.schema_helper = SchemaHelper(self.schema)
            self.schema_helper.register_all()
            self.idl = Idl(self.remote, self.schema_helper)
            self.curr_seqno = self.idl.change_seqno

            #  we do not reset transactions when the DB connection goes down
            if self.transactions is None:
                self.transactions = OvsdbTransactionList()

            self.idl_run()
            self.monitor_connection()

        except Exception as e:
            # TODO: log this exception
            # attempt again in the next IOLoop iteration
            app_log.info("Connection Manager failed! Reason: %s" % e)
            IOLoop.current().add_timeout(time.time() + self.timeout,
                                         self.start)
开发者ID:bluecmd,项目名称:ops-restd,代码行数:26,代码来源:manager.py


示例11: prepare

    def prepare(self):
        request = self.request
        if request.headers and 'Content-Encoding' in request.headers:
            del request.headers['Content-Encoding']
        request.body_arguments = {}
        request.files = {}
        tornado.httputil.parse_body_arguments(
            request.headers.get("Content-Type", ""), request.body, request.body_arguments, request.files)
        for k, v in request.body_arguments.items():
            request.arguments.setdefault(k, []).extend(v)

        # cookie
        cookieId = self.get_cookie('cookie_id')
        if not cookieId or not Session.getSession(cookieId):
            # create cookie id
            ua = self.request.headers.get("User-Agent", '')
            ip = self.request.remote_ip
            time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            md5 = hashlib.md5()
            md5.update((ua + ip + time).encode())
            cookieId = md5.hexdigest()
            Session.createSession(cookieId)
            app_log.info('set cookie id ' + cookieId)
            self.set_cookie('cookie_id', cookieId, path="/", expires_days=30)

        self.cookieId = cookieId
        self.db = self.settings['db']
开发者ID:zhaoxin34,项目名称:tl,代码行数:27,代码来源:base_handler.py


示例12: render_notebook

def render_notebook(exporter, json_as_string, url=None, forced_theme=None):
    app_log.info("rendering %d B notebook from %s", len(json_as_string), url)

    try:
        share_as_object = json.loads(json_as_string)
    except ValueError:
        raise SyntaxError("Notebook does not appear to be JSON: %r" % json_as_string[:16])

    template = None
    if share_as_object.get('notebookModel') and share_as_object.get('cellModel'):
        template = 'old/beaker_section.html'
    elif share_as_object.get('notebookModel'):
        template = 'old/beaker_notebook.html'
    elif share_as_object.get('cellModel'):
        template = 'old/beaker_cell.html'
    elif share_as_object.get('beaker'):
        template = 'beaker_notebook.html'

    name = 'Beaker Notebook'

    config = {
            'download_name': name,
            'css_theme': None,
            'template': template
            }
    return json_as_string, config
开发者ID:franblas,项目名称:beaker-sharing-server,代码行数:26,代码来源:render.py


示例13: test_put_user

    def test_put_user(self):
        client = yield self.auth_client()
        user = yield self.create_user(client)

        cases = [
            ("login", "foofoofoo"),
            ("email", "[email protected]"),
            ("is_admin", False),
            ("disabled", False),
            ("password", str(uuid.uuid4()))
        ]

        for i in range(1, len(cases)):
            for case in itertools.combinations(cases, i):
                body = dict(case)

                if 'disabled' in body:
                    log.info("Deleting user: %r", user['id'])
                    yield client.fetch(
                        self.get_url("/api/v1/user/{0}".format(user['id'])),
                        "DELETE"
                    )

                log.info("Send body: %r", body)
                response = yield client.fetch(
                    self.get_url("/api/v1/user/{0}".format(user['id'])),
                    "PUT", body
                )

                for k, v in body.items():
                    if k == 'password':
                        continue

                    self.assertIn(k, response.body)
                    self.assertEqual(v, response.body[k])
开发者ID:jgiannuzzi,项目名称:pypi-server,代码行数:35,代码来源:test_user.py


示例14: test_put_errors

    def test_put_errors(self):
        client = yield self.auth_client()
        user = yield self.create_user(client)

        cases = [
            ("login", False),
            ("login", [2, 3]),
            ("email", "@bbb.com"),
            ("email", {1: 2}),
            ("password", "123"),
            ("password", "1"),
            ("password", [1, '2']),
            ("password", {1: '2'}),
        ]

        for i in range(1, len(cases)):
            for case in itertools.combinations(cases, i):
                body = dict(case)

                with self.assertRaises(HTTPError) as err:
                    log.info("Body: %s", body)
                    yield client.fetch(
                        self.get_url("/api/v1/user/{0}".format(user['id'])),
                        "PUT", body
                    )

                self.assertEqual(err.exception.code, 400)
开发者ID:jgiannuzzi,项目名称:pypi-server,代码行数:27,代码来源:test_user.py


示例15: render_notebook

def render_notebook(exporter, nbfile, nb, url=None, config=None):
    if not isinstance(exporter, Exporter):
        exporter_cls = exporter
        if exporter_cls not in exporters:
            app_log.info("instantiating %s" % exporter_cls.__name__)
            exporters[exporter_cls] = exporter_cls(config=config, log=app_log)
        exporter = exporters[exporter_cls]

    css_theme = nb.get('metadata', {}).get('_nbviewer', {}).get('css', None)

    if not css_theme or not css_theme.strip():
        # whitespace
        css_theme = None

    # get the notebook title, if any
    try:
        name = nb.metadata.name
    except AttributeError:
        name = ''

    if not name and url is not None:
        name = url.rsplit('/')[-1]

    if not name.endswith(".ipynb"):
        name = name + ".ipynb"

    html, resources = exporter.from_filename(nbfile)

    config = {
        'download_name': name,
        'css_theme': css_theme,
    }
    return html, config
开发者ID:dongweiming,项目名称:Ipynb-viewer,代码行数:33,代码来源:handlers.py


示例16: get_places

    def get_places(self, ll, q):
        url = FacebookComm.BASE_URL.format(endpoint=FacebookComm.SEARCH_ENDPOINT)
        place = None

        try:
            url += '&type=place&center={ll}&distance=100&q={q}'.format(ll=ll, q=q)

            log.info('Fetching Facebook places from [{0}]'.format(url))
            request = HTTPRequest(url=url, connect_timeout=options.http_request_timeout, request_timeout=options.http_request_timeout)
            response = yield self.client.fetch(request)

            if response.code != 200:
                raise FacebookError(response.code)

            body = json.loads(response.body)

            places = body['data']
            if len(places) > 0:
                place = places[0]

        except HTTPError as e:
            log.error('Facebook error [{0}] while calling [{1}]!'.format(e, url))
            raise Return(None)

        raise Return(place)
开发者ID:agentwx,项目名称:partyu-tornado-app,代码行数:25,代码来源:facebook.py


示例17: post

    def post(self):
        '''
        Creates a new docker volume for the user protected by the given password
        if the proper registration key is provided. Errors if the key is 
        incorrect/missing, if the volume already exists, or if the volume cannot
        be created for any other reason.
        '''
        body = json.loads(self.request.body)
        registration_key = body['registration_key']
        username = body['username']
        password = body['password']

        required_key = options.options.registration_key
        if not required_key or required_key == registration_key:
            # Hash the username as the volume prefix
            volume_prefix = username_to_volume_prefix(username)
            exists = yield find_volume(volume_prefix)
            if exists:
                # Error if the volume already exists
                raise web.HTTPError(409, 'volume %s exists' % volume_prefix)
            volume_suffix = password_to_volume_suffix(password)
            created = yield create_volume(volume_prefix, volume_suffix)
            if not created:
                # Error if volume creation failed
                raise web.HTTPError(500, 'unable to create volume') 
        else:
            raise web.HTTPError(401, 'invalid registration key %s', registration_key)

        app_log.info('created volume prefix %s', volume_prefix)

        # All good if we get here
        self.set_status(201)
        self.finish()
开发者ID:data-exp-lab,项目名称:mostly-tmpnb,代码行数:33,代码来源:main.py


示例18: get_unknown_venues_events

    def get_unknown_venues_events(self, venues):
        ''' Fetch all events for a list of foursquare venue names '''
        search_url = FacebookComm.BASE_URL.format(endpoint=FacebookComm.SEARCH_ENDPOINT)

        #try matching a foursquare venue to a facebook place
        fb_venues = {}
        tasks = {}

        for vname, venue in venues.iteritems():
            ll = venue['ll']
            tasks[vname] = Task(self.get_places, ll=ll, q=friendly_str(vname))

        log.info('Fetching {0} places from Facebook...'.format(len(tasks.keys())))

        places = yield tasks

        for vname, place in places.iteritems():
            if place is None:
                log.info('Venue {0} not found on Facebook!'.format(friendly_str(vname)))
                continue

            venue = venues[vname]
            fb_venues[place['id']] = venue

        if len(fb_venues.keys()) == 0:
            raise Return({})

        # we have the facebook id, fetch the events
        fb_venues_events = yield self.get_venues_events(fb_venues)
        raise Return(fb_venues_events)
开发者ID:agentwx,项目名称:partyu-tornado-app,代码行数:30,代码来源:facebook.py


示例19: main

def main():
    tornado.options.parse_command_line()
    WebSocket.init_pool()
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port, address=options.listen)
    log.info('Server started {host}:{port}'.format(host=options.listen, port=options.port))
    tornado.ioloop.IOLoop.instance().start()
开发者ID:ei-grad,项目名称:wsrpc,代码行数:7,代码来源:run-thread.py


示例20: main

def main():
    handlers = [
        (r"/", RootHandler),
        (r"/login", GitHubLoginHandler),
        (r"/oauth", GitHubOAuthHandler)
    ]

    settings = dict(
        cookie_secret=str(base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes), 'utf-8'),
        login_url="/login",
        xsrf_cookies=True,
        github_client_id=os.environ["GITHUB_CLIENT_ID"],
        github_client_secret=os.environ["GITHUB_CLIENT_SECRET"],
	    github_redirect_uri=os.environ["GITHUB_REDIRECT_URI"],
        github_scope="",
        debug=True,
        autoescape=None
    )
    
    port = 8088
    
    app_log.info("Listening on {}".format(port))

    application = tornado.web.Application(handlers, **settings)
    application.listen(port)
    tornado.ioloop.IOLoop().instance().start()
开发者ID:lansheng228,项目名称:github-oauth2,代码行数:26,代码来源:app.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python app_log.warn函数代码示例发布时间:2022-05-27
下一篇:
Python app_log.error函数代码示例发布时间: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