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

Python log.trace函数代码示例

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

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



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

示例1: get_event

 def get_event(self, event_id):
     """
     Returns the event object for given event_id or raises NotFound
     """
     log.trace("Retrieving persistent event for id=%s", event_id)
     event_obj = self.event_store.read(event_id)
     return event_obj
开发者ID:mkl-,项目名称:scioncc,代码行数:7,代码来源:event.py


示例2: __setitem__

    def __setitem__(self, name, vals):
        """
        Set a parameter
        """
        if name not in self._rd:
            raise KeyError(name)
        context = self._pdict.get_context(name)
        if self._shp is None: # Not initialized:
            if isinstance(vals, np.ndarray):
                self._shp = vals.shape
            elif isinstance(vals, list):
                self._shp = (len(vals),)
            else:
                raise BadRequest('No shape was defined')

            log.trace('Set shape to %s', self._shp)
        else:
            if isinstance(vals, np.ndarray):
                validate_equal(vals.shape, self._shp, 'Invalid shape on input')
            elif isinstance(vals, list):
                validate_equal(len(vals), self._shp[0], 'Invalid shape on input')

        dom = self.domain
        paramval = get_value_class(context.param_type, domain_set = dom)
        paramval[:] = vals
        paramval.storage._storage.flags.writeable = False
        self._rd[name] = paramval
开发者ID:kerfoot,项目名称:coi-services,代码行数:27,代码来源:record_dictionary.py


示例3: outgoing

    def outgoing(self, invocation):

        log.trace("PolicyInterceptor.outgoing: %s", invocation.get_arg_value('process', invocation))


        #Check for a field with the ResourceId decorator and if found, then set resource-id
        # in the header with that field's value or if the decorator specifies a field within an object,
        #then use the object's field value ( ie. _id)
        try:
            if isinstance(invocation.message, IonObjectBase):
                decorator = 'ResourceId'
                field = invocation.message.find_field_for_decorator(decorator)
                if field is not None and hasattr(invocation.message,field):
                    deco_value = invocation.message.get_decorator_value(field, decorator)
                    if deco_value:
                        #Assume that if there is a value, then it is specifying a field in the object
                        fld_value = getattr(invocation.message,field)
                        if getattr(fld_value, deco_value) is not None:
                            invocation.headers['resource-id'] = getattr(fld_value, deco_value)
                    else:
                        if getattr(invocation.message,field) is not None:
                            invocation.headers['resource-id'] = getattr(invocation.message,field)

        except Exception, ex:
            log.exception(ex)
开发者ID:ateranishi,项目名称:pyon,代码行数:25,代码来源:policy_interceptor.py


示例4: publish_event_object

    def publish_event_object(self, event_object):
        """
        Publishes an event of given type for the given origin. Event_type defaults to an
        event_type set when initializing the EventPublisher. Other kwargs fill out the fields
        of the event. This operation will fail with an exception.
        @param event_object     the event object to be published
        @retval event_object    the event object which was published
        """
        assert event_object

        topic = self._topic(event_object)
        to_name = (self._send_name.exchange, topic)
        log.trace("Publishing event message to %s", to_name)

        current_time = int(get_ion_ts())

        #Ensure valid created timestamp if supplied
        if event_object.ts_created:

            if not is_valid_ts(event_object.ts_created):
                raise BadRequest("The ts_created value is not a valid timestamp: '%s'" % (event_object.ts_created))

            #Reject events that are older than specified time
            if int(event_object.ts_created) > ( current_time + VALID_EVENT_TIME_PERIOD ):
                raise BadRequest("This ts_created value is too far in the future:'%s'" % (event_object.ts_created))

            #Reject events that are older than specified time
            if int(event_object.ts_created) < (current_time - VALID_EVENT_TIME_PERIOD) :
                raise BadRequest("This ts_created value is too old:'%s'" % (event_object.ts_created))

        else:
            event_object.ts_created = str(current_time)

        #Validate this object
        #TODO - enable this once the resource agent issue sending a dict is figured out
        #event_object._validate()

        #Ensure the event object has a unique id
        if '_id' in event_object:
            raise BadRequest("The event object cannot contain a _id field '%s'" % (event_object))

        #Generate a unique ID for this event
        event_object._id = create_unique_event_id()

        try:
            self.publish(event_object, to_name=to_name)
        except Exception as ex:
            log.exception("Failed to publish event (%s): '%s'" % (ex.message, event_object))
            raise

        try:
            # store published event but only if we specified an event_repo
            if PERSIST_ON_PUBLISH and self.event_repo:
                self.event_repo.put_event(event_object)
        except Exception as ex:
            log.exception("Failed to store published event (%s): '%s'" % (ex.message, event_object))
            raise

        return event_object
开发者ID:pkediyal,项目名称:pyon,代码行数:59,代码来源:event.py


示例5: put_event

 def put_event(self, event):
     """
     Places an event object into the event repository. Retains event_ids if existing.
     Returns event_id of new event.
     """
     log.trace("Store event persistently %s", event)
     if not isinstance(event, Event):
         raise BadRequest("event must be type Event, not %s" % type(event))
     event_id = event.__dict__.pop("_id", None)
     new_event_id, _ = self.event_store.create(event, event_id)
     return new_event_id
开发者ID:mkl-,项目名称:scioncc,代码行数:11,代码来源:event.py


示例6: incoming

    def incoming(self,invocation):

        if not self.enabled:
            return invocation

        log.trace("GovernanceInterceptor.incoming: %s", invocation.get_arg_value('process',invocation))

        if self.governance_controller is not None:
            self.governance_controller.process_incoming_message(invocation)

        return invocation
开发者ID:ateranishi,项目名称:pyon,代码行数:11,代码来源:governance_interceptor.py


示例7: publish

 def publish(self, msg, stream_id='', stream_route=None):
     '''
     Encapsulates and publishes a message; the message is sent to either the specified
     stream/route or the stream/route specified at instantiation
     '''
     xp = self.xp
     log.trace('Exchange: %s', xp.exchange)
     if stream_route:
         xp = self.container.ex_manager.create_xp(stream_route.exchange_point)
     else:
         stream_route = self.stream_route
     log.trace('Publishing (%s,%s)', xp.exchange, stream_route.routing_key)
     super(StreamPublisher,self).publish(msg, to_name=xp.create_route(stream_route.routing_key), headers={'exchange_point':stream_route.exchange_point, 'stream':stream_id or self.stream_id})
开发者ID:daf,项目名称:pyon,代码行数:13,代码来源:stream.py


示例8: close_impl

    def close_impl(self):
        """
        Closes the AMQP connection.
        """
        log.trace("BaseChannel.close_impl (%s)", self.get_channel_id())
        if self._transport:

            # the close destroys self._transport, so keep a ref here
            transport = self._transport
            with self._ensure_transport():
                transport.close()

            # set to None now so nothing else tries to use the channel during the callback
            self._transport = None
开发者ID:newbrough,项目名称:pyon,代码行数:14,代码来源:channel.py


示例9: find_events

    def find_events(self, event_type=None, origin=None, start_ts=None, end_ts=None, id_only=False, **kwargs):
        log.trace(
            "Retrieving persistent event for event_type=%s, origin=%s, start_ts=%s, end_ts=%s, descending=%s, limit=%s",
            event_type,
            origin,
            start_ts,
            end_ts,
            kwargs.get("descending", None),
            kwargs.get("limit", None),
        )
        events = None

        design_name = "event"
        view_name = None
        start_key = []
        end_key = []
        if origin and event_type:
            view_name = "by_origintype"
            start_key = [origin, event_type]
            end_key = [origin, event_type]
        elif origin:
            view_name = "by_origin"
            start_key = [origin]
            end_key = [origin]
        elif event_type:
            view_name = "by_type"
            start_key = [event_type]
            end_key = [event_type]
        elif start_ts or end_ts:
            view_name = "by_time"
            start_key = []
            end_key = []
        else:
            view_name = "by_time"
            if kwargs.get("limit", 0) < 1:
                kwargs["limit"] = 100
                log.warn("Querying all events, no limit given. Set limit to 100")

        if start_ts:
            start_key.append(start_ts)
        if end_ts:
            end_key.append(end_ts)

        events = self.event_store.find_by_view(
            design_name, view_name, start_key=start_key, end_key=end_key, id_only=id_only, **kwargs
        )
        return events
开发者ID:mmeisinger,项目名称:pyon,代码行数:47,代码来源:event.py


示例10: incoming

    def incoming(self, invocation):

        if invocation.args.has_key("process"):
            log.trace(
                "ConversationMonitorInterceptor.incoming: %s" % invocation.get_arg_value("process", invocation).name
            )
        else:
            log.trace("ConversationMonitorInterceptor.incoming: %s" % invocation)

        invocation.message_annotations[
            GovernanceDispatcher.CONVERSATION__STATUS_ANNOTATION
        ] = GovernanceDispatcher.STATUS_STARTED

        conv_msg_type = invocation.headers.get("conv-msg-type", None)
        self_principal = invocation.headers.get("receiver-role", None)
        target_principal = invocation.headers.get("sender-role", None)

        op_type = LocalType.RESV
        if conv_msg_type and self_principal and target_principal:
            # if self_principal:
            #    target_principal, sender_type = invocation.get_message_sender()
            #    target_principal_queue = invocation.get_message_sender_queue()
            #    op_type = LocalType.RESV;
            #
            #    if target_principal=='Unknown':
            #        target_principal = target_principal_queue
            #        self._check(invocation, op_type, self_principal, target_principal)
            #    else: self._check(invocation, op_type, self_principal, target_principal, target_principal_queue)

            self._check(invocation, op_type, self_principal, target_principal)

            if (
                invocation.message_annotations[GovernanceDispatcher.CONVERSATION__STATUS_ANNOTATION]
                == GovernanceDispatcher.STATUS_STARTED
            ):
                invocation.message_annotations[
                    GovernanceDispatcher.CONVERSATION__STATUS_ANNOTATION
                ] = GovernanceDispatcher.STATUS_COMPLETE
        else:
            self._report_error(
                invocation,
                GovernanceDispatcher.STATUS_SKIPPED,
                "The message cannot be monitored since the conversation roles are not in the headers",
            )

        return invocation
开发者ID:shenrie,项目名称:pyon,代码行数:46,代码来源:conversation_monitor_interceptor.py


示例11: check_content

    def check_content(self, key, value, content_types):
        split_content_types = []
        if ',' in content_types:
            split_content_types = content_types.split(',')
        else:
            split_content_types.append(content_types)
        log.trace("split_content_types: %s", split_content_types)

        for content_type in split_content_types:
            if type(value).__name__ == content_type.strip():
                return

            # Check for inheritance
            if self.check_inheritance_chain(type(value), content_type):
                return

        raise AttributeError('Invalid value type %s in field "%s.%s", should be one of "%s"' %
                (str(value), type(self).__name__, key, content_types))
开发者ID:ateranishi,项目名称:pyon,代码行数:18,代码来源:object.py


示例12: map_cov_rdt

 def map_cov_rdt(cls, coverage, rdt, field, slice_):
     log.trace( 'Slice is %s' , slice_)
     try:
         n = coverage.get_parameter_values(field,tdoa=slice_)
     except ParameterFunctionException:
         return
     if n is None:
         rdt[field] = [n]
     elif isinstance(n,np.ndarray):
         if coverage.get_data_extents(field)[0] < coverage.num_timesteps:
             log.error("Misformed coverage detected, padding with fill_value")
             arr_len = utils.slice_shape(slice_, (coverage.num_timesteps,))[0]
             fill_arr = np.empty(arr_len - n.shape[0] , dtype=n.dtype)
             fill_arr.fill(coverage.get_parameter_context(field).fill_value)
             n = np.append(n,fill_arr)
         elif coverage.get_data_extents(field)[0] > coverage.num_timesteps:
             raise CorruptionError('The coverage is corrupted:\n\tfield: %s\n\textents: %s\n\ttimesteps: %s' % (field, coverage.get_data_extents(field), coverage.num_timesteps))
         rdt[field] = np.atleast_1d(n)
     else:
         rdt[field] = [n]
开发者ID:MauriceManning,项目名称:coi-services,代码行数:20,代码来源:replay_process.py


示例13: _set

    def _set(self, name, vals):
        """
        Set a parameter
        """
        if name not in self.fields:
            raise KeyError(name)

        if vals is None:
            self._rd[name] = None
            return
        context = self._pdict.get_context(name)

        if self._shp is None and isinstance(context.param_type, (SparseConstantType, ConstantType, ConstantRangeType)):
            self._shp = (1,)
            self._dirty_shape = True

        elif self._shp is None or self._dirty_shape:
            if isinstance(vals, np.ndarray):
                self._shp = (vals.shape[0],)  # Only support 1-d right now
            elif isinstance(vals, list):
                self._shp = (len(vals),)
            else:
                raise BadRequest("No shape was defined")

            log.trace("Set shape to %s", self._shp)
            if self._dirty_shape:
                self._dirty_shape = False
                self._reshape_const()

        else:
            if isinstance(vals, np.ndarray):
                if not vals.shape:
                    raise BadRequest("Invalid shape on input (dimensionless)")
                validate_equal(
                    vals.shape[0], self._shp[0], "Invalid shape on input (%s expecting %s)" % (vals.shape, self._shp)
                )
            elif isinstance(vals, list):
                validate_equal(len(vals), self._shp[0], "Invalid shape on input")

        # paramval = self.get_paramval(context.param_type, dom, vals)
        self._rd[name] = vals
开发者ID:edwardhunter2,项目名称:coi-services,代码行数:41,代码来源:record_dictionary.py


示例14: _routing_call

    def _routing_call(self, call, context, *callargs, **callkwargs):
        """
        Endpoints call into here to synchronize across the entire IonProcess.

        Returns immediately with an AsyncResult that can be waited on. Calls
        are made by the loop in _control_flow. We pass in the calling greenlet so
        exceptions are raised in the correct context.

        @param  call        The call to be made within this ION processes' calling greenlet.
        @param  callargs    The keyword args to pass to the call.
        @param  context     Optional process-context (usually the headers of the incoming call) to be
                            set. Process-context is greenlet-local, and since we're crossing greenlet
                            boundaries, we must set it again in the ION process' calling greenlet.
        """
        ar = AsyncResult()

        if len(callargs) == 0 and len(callkwargs) == 0:
            log.trace("_routing_call got no arguments for the call %s, check your call's parameters", call)

        self._ctrl_queue.put((greenlet.getcurrent(), ar, call, callargs, callkwargs, context))
        return ar
开发者ID:jamie-cyber1,项目名称:pyon,代码行数:21,代码来源:process.py


示例15: _set

    def _set(self, name, vals):
        """
        Set a parameter
        """
        if name not in self.fields:
            raise KeyError(name)

        if vals is None:
            self._rd[name] = None
            return
        context = self._pdict.get_context(name)

        if self._shp is None and (isinstance(context.param_type, ConstantType) or isinstance(context.param_type, ConstantRangeType)):
            self._shp = (1,)
            self._dirty_shape = True
        
        elif self._shp is None or self._dirty_shape:
            if isinstance(vals, np.ndarray):
                self._shp = vals.shape
            elif isinstance(vals, list):
                self._shp = (len(vals),)
            else:
                raise BadRequest('No shape was defined')

            log.trace('Set shape to %s', self._shp)
            if self._dirty_shape:
                self._dirty_shape = False
                self._reshape_const()

        else:
            if isinstance(vals, np.ndarray):
                if not vals.shape:
                    raise BadRequest('Invalid shape on input (dimensionless)')
                validate_equal(vals.shape[0], self._shp[0], 'Invalid shape on input (%s expecting %s)' % (vals.shape, self._shp))
            elif isinstance(vals, list):
                validate_equal(len(vals), self._shp[0], 'Invalid shape on input')

        dom = self.domain
        paramval = self.get_paramval(context.param_type, dom, vals)
        self._rd[name] = paramval
开发者ID:mbarry02,项目名称:coi-services,代码行数:40,代码来源:record_dictionary.py


示例16: publish_event_object

    def publish_event_object(self, event_object):
        """
        Publishes an event of given type for the given origin. Event_type defaults to an
        event_type set when initializing the EventPublisher. Other kwargs fill out the fields
        of the event. This operation will fail with an exception.
        @param event_object     the event object to be published
        @retval event_object    the event object which was published
        """
        assert event_object

        topic = self._topic(event_object)
        to_name = (self._send_name.exchange, topic)
        log.trace("Publishing %s event message %s:%s -> %s", event_object.type_, event_object.origin_type, event_object.origin, to_name)

        current_time = int(get_ion_ts())

        #Ensure valid created timestamp if supplied
        if event_object.ts_created:

            if not is_valid_ts(event_object.ts_created):
                raise BadRequest("The ts_created value is not a valid timestamp: '%s'" % (event_object.ts_created))

            #Reject events that are older than specified time
            if int(event_object.ts_created) > ( current_time + VALID_EVENT_TIME_PERIOD ):
                raise BadRequest("This ts_created value is too far in the future:'%s'" % (event_object.ts_created))

            #Reject events that are older than specified time
            if int(event_object.ts_created) < (current_time - VALID_EVENT_TIME_PERIOD) :
                raise BadRequest("This ts_created value is too old:'%s'" % (event_object.ts_created))

        else:
            event_object.ts_created = str(current_time)

        #Validate this object - ideally the validator should pass on problems, but for now just log
        #any errors and keep going, since seeing invalid situations are better than skipping validation.
        try:
            event_object._validate()
        except Exception, e:
            log.exception(e)
开发者ID:jamie-cyber1,项目名称:pyon,代码行数:39,代码来源:event.py


示例17: _publish_event

    def _publish_event(self, event_msg, origin, event_type=None):
        event_type = event_type or self.event_type or event_msg._get_type()
        assert origin and event_type

        topic = self._topic(event_type, origin, base_types=event_msg.base_types,
            sub_type=event_msg.sub_type, origin_type=event_msg.origin_type)
        to_name = (self._send_name.exchange, topic)
        log.trace("Publishing event message to %s", to_name)

        try:
            self.publish(event_msg, to_name=to_name)
        except Exception as ex:
            log.exception("Failed to publish event '%s'" % (event_msg))
            return False

        try:
            # store published event but only if we specified an event_repo
            if PERSIST_ON_PUBLISH and self.event_repo:
                self.event_repo.put_event(event_msg)
        except Exception as ex:
            log.exception("Failed to store published event '%s'" % (event_msg))
            return False

        return True
开发者ID:daf,项目名称:pyon,代码行数:24,代码来源:event.py


示例18: outgoing

    def outgoing(self, invocation):

        if invocation.args.has_key("process"):
            log.trace(
                "ConversationMonitorInterceptor.outgoing: %s" % invocation.get_arg_value("process", invocation).name
            )
        else:
            log.trace("ConversationMonitorInterceptor.outgoing: %s" % invocation)

        invocation.message_annotations[
            GovernanceDispatcher.CONVERSATION__STATUS_ANNOTATION
        ] = GovernanceDispatcher.STATUS_STARTED

        conv_msg_type = invocation.headers.get("conv-msg-type", None)
        self_principal = invocation.headers.get("sender-role", None)  # TODO - should these be set to default values?
        target_principal = invocation.headers.get("receiver-role", None)
        op_type = LocalType.SEND

        if conv_msg_type and self_principal and target_principal:
            #    target_principal = invocation.get_message_receiver()
            #    op_type = LocalType.SEND;
            self._check(invocation, op_type, self_principal, target_principal)
            if (
                invocation.message_annotations[GovernanceDispatcher.CONVERSATION__STATUS_ANNOTATION]
                == GovernanceDispatcher.STATUS_STARTED
            ):
                invocation.message_annotations[
                    GovernanceDispatcher.CONVERSATION__STATUS_ANNOTATION
                ] = GovernanceDispatcher.STATUS_COMPLETE
        else:
            self._report_error(
                invocation,
                GovernanceDispatcher.STATUS_SKIPPED,
                "The message cannot be monitored since the conversation roles are not in the headers",
            )
        return invocation
开发者ID:shenrie,项目名称:pyon,代码行数:36,代码来源:conversation_monitor_interceptor.py


示例19: get_event

 def get_event(self, event_id):
     log.trace("Retrieving persistent event for id=%s", event_id)
     event_obj = self.event_store.read(event_id)
     return event_obj
开发者ID:daf,项目名称:pyon,代码行数:4,代码来源:event.py


示例20: put_event

 def put_event(self, event):
     log.trace("Store event persistently %s", event)
     if not isinstance(event, Event):
         raise BadRequest("event must be type Event, not %s" % type(event))
     return self.event_store.create(event)
开发者ID:daf,项目名称:pyon,代码行数:5,代码来源:event.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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