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


Python app_log.info方法代码示例

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


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

示例1: manually_kill_server

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def manually_kill_server(user_name):
    # Get our AWS server db's instance for the user
    try:
        server = Server.get_server(user_name)
        app_log.debug("Checking server for %s manually..." % user_name)
    except Server.DoesNotExist:
        # it is not necessarily the case that a server will exist, we return early if that is the case.
        app_log.warn("There is no matching, allocated server for user %s" % user_name)
        return
    # get server instance information
    resource = yield retry(boto3.resource, "ec2", region_name=SERVER_PARAMS["REGION"])
    instance = yield retry(resource.Instance, server.server_id)
    # instance object is lazy, run this to get full info...
    yield retry(instance.load)
    
    #stop server if state is running (possible states are stopped, stopping, pending, shutting-down, terminated, and running)
    if instance.state["Name"] == "running":
        retry(instance.stop)
        app_log.info("manually killed server for user %s" % user_name)
    else:
        app_log.debug("server state for user %s is %s, no action taken" % (user_name, instance.state["Name"])) 
开发者ID:harvard,项目名称:cloudJHub,代码行数:23,代码来源:cull_idle_servers.py

示例2: _get_pods

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def _get_pods(self):
        """Get information about build and user pods"""
        app_log.info("Getting pod statistics")
        k8s = self.settings["kubernetes_client"]
        pool = self.settings["executor"]

        get_user_pods = asyncio.wrap_future(
            pool.submit(
                k8s.list_namespaced_pod,
                self.settings["build_namespace"],
                label_selector="app=jupyterhub,component=singleuser-server",
            )
        )

        get_build_pods = asyncio.wrap_future(
            pool.submit(
                k8s.list_namespaced_pod,
                self.settings["build_namespace"],
                label_selector="component=binderhub-build",
            )
        )

        return await asyncio.gather(get_user_pods, get_build_pods) 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:25,代码来源:health.py

示例3: reset_is_running_on_all_spider

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def reset_is_running_on_all_spider( coll_model ) :
	"""
	reset is_running on all spiders to avoid errors if app shut down while one spider was running 
	"""

	print ()

	app_log.warning('>>> reset_is_running_on_all_spider ... ')
	
	# find if any spider was running
	running_spiders = coll_model.find({"scraper_log.is_running" : True})
	app_log.info(">>> running_spiders : \n %s" , list(running_spiders) )

	coll_model.update_many({'scraper_log.is_running' : True }, {"$set": {'scraper_log.is_running' : False }})

	# if list(running_spiders) != [] : 

	# 	app_log.warning('>>> reset_is_running_on_all_spider / some spiders were blocked in is_running == True ... ')
	# 	app_log.warning('>>> spiders are : \n %s', pformat(list(running_spiders)) )

	# 	coll_model.update({"scraper_log.is_running":True}, {"$set" : {"scraper_log.is_running" : False }})
	
	# print 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:25,代码来源:main.py

示例4: partial_config_as_dict

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def partial_config_as_dict(self, previous_config=None ) : 
		""" """
		print 
		app_log.info("== SpiderConfig.partial_config_as_dict / previous_config : %s ", previous_config )
		# print "\n*** SpiderConfig.partial_config_as_dict / previous_config : "
		# print previous_config

		all_custom_fields = CONTRIBUTOR_CUSTOMAZIBLE_FIELDS + ["scraper_config_xpaths"]
		partial_config = { k : v for k,v in self.spider_config.iteritems() if k in all_custom_fields }
		# print "\n*** SpiderConfig.partial_config_as_dict / partial_config : "
		# print partial_config
		
		# reset scraper_log
		partial_config["scraper_log"] = deepcopy(CONTRIBUTOR_CORE_FIELDS["scraper_log"])
		partial_config["scraper_log"]["modified_by"]	= self.user
		partial_config["scraper_log"]["modified_at"]	= self.timestamp
		partial_config["scraper_log"]["added_by"] 		= previous_config["scraper_log"]["added_by"]

		return partial_config 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:21,代码来源:core_classes.py

示例5: post

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def post(self, *args):
		"""Example handle ajax post"""
		dic = tornado.escape.json_decode(self.request.body)
		app_log.info("ajax / dic : \n %s " , pformat(dic) )

		# useful code goes here
		
		self.write(json.dumps({'status': 'ok', 'sent': dic}))
		self.finish()




### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ###
### INFOS / DOC  ############################################################################
### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:18,代码来源:controller.py

示例6: get

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def get(self):

		app_log.info("InfosWhyHandler.get... ")

		self.site_section = "infos"

		self.render(
			"why.html",
			page_title 				= app_main_texts["main_title"],
			app_host				= self.request.host,
			site_section			= self.site_section,
			user					= self.current_user,
			is_user_connected 		= self.is_user_connected,
			user_email				= self.user_email,
			user_auth_level			= self.user_auth_level,
			user_auth_level_dict 	= self.user_auth_level_dict,
		) 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:19,代码来源:controller.py

示例7: test_put_user

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def test_put_user(self):
        client = yield self.auth_client()
        user = yield self.create_user(client)

        cases = [
            ("login", "foofoofoo"),
            ("email", "aaa@bbb.com"),
            ("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:mosquito,项目名称:pypi-server,代码行数:37,代码来源:test_user.py

示例8: test_put_errors

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
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:mosquito,项目名称:pypi-server,代码行数:29,代码来源:test_user.py

示例9: check_docker_registry

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def check_docker_registry(self):
        """Check docker registry health"""
        app_log.info("Checking registry status")
        registry = self.settings["registry"]
        # we are only interested in getting a response from the registry, we
        # don't care if the image actually exists or not
        image_name = self.settings["image_prefix"] + "some-image-name:12345"
        await registry.get_image_manifest(
            *'/'.join(image_name.split('/')[-2:]).split(':', 1)
        )
        return True 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:13,代码来源:health.py

示例10: stream_logs

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def stream_logs(self):
        """Stream a pod's logs"""
        app_log.info("Watching logs of %s", self.name)
        for line in self.api.read_namespaced_pod_log(
                self.name,
                self.namespace,
                follow=True,
                tail_lines=self.log_tail_lines,
                _preload_content=False):
            if self.stop_event.is_set():
                app_log.info("Stopping logs of %s", self.name)
                return
            # verify that the line is JSON
            line = line.decode('utf-8')
            try:
                json.loads(line)
            except ValueError:
                # log event wasn't JSON.
                # use the line itself as the message with unknown phase.
                # We don't know what the right phase is, use 'unknown'.
                # If it was a fatal error, presumably a 'failure'
                # message will arrive shortly.
                app_log.error("log event not json: %r", line)
                line = json.dumps({
                    'phase': 'unknown',
                    'message': line,
                })

            self.progress('log', line)
        else:
            app_log.info("Finished streaming logs of %s", self.name) 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:33,代码来源:build.py

示例11: cull_idle

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def cull_idle(url, api_token, timeout):
    """cull idle single-user servers"""
    auth_header = {
            'Authorization': 'token %s' % api_token
        }
    req = HTTPRequest(url=url + '/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 + '/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:jupyterhub,项目名称:jupyterhub-deploy-teaching,代码行数:31,代码来源:cull_idle_servers.py

示例12: authenticate

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def authenticate(self, handler, data=None):
        code = handler.get_argument("code")
        http_client = AsyncHTTPClient()

        params = dict(
            client_id=self.client_id,
            client_secret=self.client_secret,
            grant_type='authorization_code',
            code=code,
            redirect_uri=self.get_callback_url(handler))

        data = urllib.parse.urlencode(
            params, doseq=True, encoding='utf-8', safe='=')

        url = self.token_url

        headers = {
            'Content-Type':
            'application/x-www-form-urlencoded; charset=UTF-8'
        }
        req = HTTPRequest(
            url,
            method="POST",
            headers=headers,
            body=data  # Body is required for a POST...
        )

        resp = await http_client.fetch(req)
        resp_json = json.loads(resp.body.decode('utf8', 'replace'))

        # app_log.info("Response %s", resp_json)
        access_token = resp_json['access_token']

        id_token = resp_json['id_token']
        decoded = jwt.decode(id_token, verify=False)

        userdict = {"name": decoded[self.username_claim]}
        userdict["auth_state"] = auth_state = {}
        auth_state['access_token'] = access_token
        # results in a decoded JWT for the user data
        auth_state['user'] = decoded

        return userdict 
开发者ID:jupyterhub,项目名称:oauthenticator,代码行数:45,代码来源:azuread.py

示例13: cull_idle

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def cull_idle(url, api_token, timeout):
    #last valid activity timestame
    cull_limit = datetime.datetime.utcnow() - datetime.timedelta(seconds=timeout)
    
    #get user list
    hub_api_authorization_header = { 'Authorization': 'token %s' % api_token}
    users_request = HTTPRequest(url=url + '/users', headers=hub_api_authorization_header )
    
    #run request tornado-asynchronously, extract user list (contains more information)
    resp = yield AsyncHTTPClient().fetch(users_request)
    all_users = json.loads(resp.body.decode('utf8', 'replace'))
    
    #build a bunch of (asynchronous) HTTP request futures...
    stop_notebook_futures = []
    servers_to_check = []
    dont_cull_these = set()
    for user in all_users:

        #extract last activity time, determine cullability of the server.
        last_activity = parse_date(user['last_activity'])
        should_cull = last_activity.replace(tzinfo=None)  < cull_limit.replace(tzinfo=None)
        user_name = user['name']
        app_log.debug("checking %s, last activity: %s, server: %s" % (user_name, last_activity, user['server']) )
        
        if not should_cull:
            dont_cull_these.add(user_name)
        
        #server should be culled:
        if user['server'] and should_cull:
            app_log.info("Culling %s (inactive since %s)", user_name, last_activity)
            stop_user_request = HTTPRequest(url=url + '/users/%s/server' % user_name,
                                            method='DELETE',
                                            headers=hub_api_authorization_header )
            stop_notebook_futures.append( (user_name, AsyncHTTPClient().fetch(stop_user_request)) )

        #Server status is None, which means actual status needs to be checked.
        if not user['server'] and should_cull:
            servers_to_check.append(user_name)

        #server should not be culled, just a log statement
        if user['server'] and not should_cull:
            app_log.info("Not culling %s (active since %s)", user['name'], last_activity)
            
    # Cull notebooks using normal API.
    for (user_name, cull_request) in stop_notebook_futures:
        try:
            yield cull_request #this line actually runs the api call to kill a server
        except HTTPError:
            #Due to a bug in Jupyterhub
            app_log.error("Something went wrong culling %s, will be manually killing it.", user_name)
            servers_to_check.append( user_name )
            continue
        app_log.info("Finished culling %s", user_name)
        
    for user_name in servers_to_check:
        if user_name not in dont_cull_these:
            yield manually_kill_server(user_name) 
开发者ID:harvard,项目名称:cloudJHub,代码行数:59,代码来源:cull_idle_servers.py

示例14: cleanup_builds

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def cleanup_builds(cls, kube, namespace, max_age):
        """Delete stopped build pods and build pods that have aged out"""
        builds = kube.list_namespaced_pod(
            namespace=namespace,
            label_selector='component=binderhub-build',
        ).items
        phases = defaultdict(int)
        app_log.debug("%i build pods", len(builds))
        now = datetime.datetime.now(tz=datetime.timezone.utc)
        start_cutoff = now - datetime.timedelta(seconds=max_age)
        deleted = 0
        for build in builds:
            phase = build.status.phase
            phases[phase] += 1
            annotations = build.metadata.annotations or {}
            repo = annotations.get("binder-repo", "unknown")
            delete = False
            if build.status.phase in {'Failed', 'Succeeded', 'Evicted'}:
                # log Deleting Failed build build-image-...
                # print(build.metadata)
                app_log.info(
                    "Deleting %s build %s (repo=%s)",
                    build.status.phase,
                    build.metadata.name,
                    repo,
                )
                delete = True
            else:
                # check age
                started = build.status.start_time
                if max_age and started and started < start_cutoff:
                    app_log.info(
                        "Deleting long-running build %s (repo=%s)",
                        build.metadata.name,
                        repo,
                    )
                    delete = True

            if delete:
                deleted += 1
                try:
                    kube.delete_namespaced_pod(
                        name=build.metadata.name,
                        namespace=namespace,
                        body=client.V1DeleteOptions(grace_period_seconds=0))
                except client.rest.ApiException as e:
                    if e.status == 404:
                        # Is ok, someone else has already deleted it
                        pass
                    else:
                        raise

        if deleted:
            app_log.info("Deleted %i/%i build pods", deleted, len(builds))
        app_log.debug("Build phase summary: %s", json.dumps(phases, sort_keys=True, indent=1)) 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:57,代码来源:build.py

示例15: run_spider

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import info [as 别名]
def run_spider (	self, 
						datamodel,
						spider_id, 
						spider_oid,
						spider_config,
						current_user_id,
						test_limit=None,
						# callback=None,
						countdown=None
					) :
		
		print()
		app_log.info("SpiderHandler.run_spider --- " )
		

		### for debugging purposes...
		app_log.info("SpiderHandler.run_spider / testing the non-blocking decorator with a time.sleep... " )
		time.sleep(1)
		# app_log.info("SpiderHandler.run_spider ---\n--- start spider %s in %s" %( str(spider_id), countdown ) ) 
		for i in range( countdown ):
			time.sleep(1)
			app_log.info("SpiderHandler.run_spider ---\n--- start spider %s in %s" %( str(spider_id), countdown-i ) ) 
		time.sleep(1)


		### run spider --- check masterspider.py --> function run_generic_spider()
		app_log.info("SpiderHandler.run_spider / now let it run... ")
		result = run_generic_spider( 
									user_id				= current_user_id,
									spider_id			= str(spider_id), 
									# spider_oid		= spider_oid,
									datamodel			= datamodel, 
									run_spider_config	= spider_config, 
									test_limit 			= test_limit
									)


		### TO DO : keep track of error in spider configuration


		### update status in spider configuration
		self.update_spider_log(spider_id=spider_id, spider_oid=spider_oid, log_to_update="is_working", 		  value=True)
		self.update_spider_log(spider_id=spider_id, spider_oid=spider_oid, log_to_update="is_tested", 		  value=True)
		self.update_spider_log(spider_id=spider_id, spider_oid=spider_oid, log_to_update="is_running", 		  value=False)
		self.update_spider_log(spider_id=spider_id, spider_oid=spider_oid, log_to_update="is_data_available", value=True)


		### raise result to tell gen is ended
		raise gen.Return(result)
		# yield gen.Return(result)
		# callback(result) 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:53,代码来源:spider_handler.py


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