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


Python log.debug函数代码示例

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


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

示例1: set_overcurrent_limit

    def set_overcurrent_limit(self,port_id, milliamps, microseconds,src):
        """
        """
        if self._rsn_oms is None:
            raise PlatformConnectionException("Cannot set_overcurrent_limit: _rsn_oms object required (created via connect() call)")

        if port_id not in self.nodeCfg.node_port_info :
               raise PlatformConnectionException("Cannot set_overcurrent_limit: Invalid Port ID")

        oms_port_cntl_id = self.nodeCfg.node_port_info[port_id]['port_oms_port_cntl_id']

      
        # ok, now make the request to RSN OMS:
        try:
            retval = self._rsn_oms.port.set_over_current(self._platform_id,oms_port_cntl_id,int(milliamps),int(microseconds),src)
                                                                     
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot set_overcurrent_limit: %s" % str(e))

        log.debug("set_overcurrent_limit = %s", retval)

        dic_plat = self._verify_platform_id_in_response(response)
        self._verify_port_id_in_response(oms_port_id, dic_plat)

        return dic_plat  # note: return the dic for the platform
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:25,代码来源:rsn_platform_driver.py

示例2: turn_off_port

    def turn_off_port(self, port_id,src):

        if self._rsn_oms is None:
            raise PlatformConnectionException("Cannot turn_off_port: _rsn_oms object required (created via connect() call)")

        if port_id not in self.nodeCfg.node_port_info :
               raise PlatformConnectionException("Cannot turn_off_port: Invalid Port ID")

       
        oms_port_cntl_id = self.nodeCfg.node_port_info[port_id]['port_oms_port_cntl_id']
 

        log.debug("%r: turning off port: port_id=%s oms port_id = %s",
                  self._platform_id, port_id,oms_port_cntl_id)


        if self._rsn_oms is None:
            raise PlatformConnectionException("Cannot turn_off_platform_port: _rsn_oms object required (created via connect() call)")

        try:
            response = self._rsn_oms.port.turn_off_platform_port(self._platform_id,
                                                                 oms_port_cntl_id,src)
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot turn_off_platform_port: %s" % str(e))

        log.debug("%r: turn_off_platform_port response: %s",
                  self._platform_id, response)

        dic_plat = self._verify_platform_id_in_response(response)

        return dic_plat  # note: return the dic for the platform
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:31,代码来源:rsn_platform_driver.py

示例3: get_attribute_values_from_oms

    def get_attribute_values_from_oms(self,attrs):
        """
        """
        if not isinstance(attrs, (list, tuple)):
            raise PlatformException('get_attribute_values: attrs argument must be a '
                                    'list [(attrName, from_time), ...]. Given: %s', attrs)

        if self._rsn_oms is None:
            raise PlatformConnectionException("Cannot get_platform_attribute_values: _rsn_oms object required (created via connect() call)")
        
        log.debug("get_attribute_values: attrs=%s", self._platform_id)
        log.debug("get_attribute_values: attrs=%s", attrs)

        try:
            retval = self._rsn_oms.attr.get_platform_attribute_values(self._platform_id,
                                                                      attrs)
        except Exception as e:
            raise PlatformConnectionException(msg="get_attribute_values_from_oms Cannot get_platform_attribute_values: %s" % str(e))

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response get_attribute_values_from_oms does not include "
                                    "requested platform '%s'" % self._platform_id)

        attr_values = retval[self._platform_id]
    
        if isinstance(attr_values,str):
            raise PlatformException("Unexpected: response get_attribute_values_from_oms "
                                    "'%s'" % attr_values ) 
   
            
    
        # reported timestamps are already in NTP. Just return the dict:
        return attr_values
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:33,代码来源:rsn_platform_driver.py

示例4: _disconnect

    def _disconnect(self, recursion=None):
        CIOMSClientFactory.destroy_instance(self._rsn_oms)
        self._rsn_oms = None
        log.debug("%r: CIOMSClient instance destroyed", self._platform_id)

        self._delete_scheduler()
        self._scheduler = None
开发者ID:cwingard,项目名称:mi-instrument,代码行数:7,代码来源:rsn_platform_driver.py

示例5: _construct_fsm

    def _construct_fsm(self, states=PlatformDriverState,
                       events=PlatformDriverEvent,
                       enter_event=PlatformDriverEvent.ENTER,
                       exit_event=PlatformDriverEvent.EXIT):
        """
        Constructs the FSM for the driver. The preparations here are mostly
        related with the UNCONFIGURED, DISCONNECTED, and CONNECTED state
        transitions, with some common handlers for the CONNECTED state.
        Subclasses can override to indicate specific parameters and add new
        handlers (typically for the CONNECTED state).
        """
        log.debug("constructing base platform driver FSM")

        self._fsm = ThreadSafeFSM(states, events, enter_event, exit_event)

        for state in PlatformDriverState.list():
            self._fsm.add_handler(state, enter_event, self._common_state_enter)
            self._fsm.add_handler(state, exit_event, self._common_state_exit)

        # UNCONFIGURED state event handlers:
        self._fsm.add_handler(PlatformDriverState.UNCONFIGURED, PlatformDriverEvent.CONFIGURE, self._handler_unconfigured_configure)

        # DISCONNECTED state event handlers:
        self._fsm.add_handler(PlatformDriverState.DISCONNECTED, PlatformDriverEvent.CONNECT, self._handler_disconnected_connect)
        self._fsm.add_handler(PlatformDriverState.DISCONNECTED, PlatformDriverEvent.DISCONNECT, self._handler_disconnected_disconnect)

        # CONNECTED state event handlers:
        self._fsm.add_handler(PlatformDriverState.CONNECTED, PlatformDriverEvent.DISCONNECT, self._handler_connected_disconnect)
        self._fsm.add_handler(PlatformDriverState.CONNECTED, PlatformDriverEvent.CONNECTION_LOST, self._handler_connected_connection_lost)

        self._fsm.add_handler(PlatformDriverState.CONNECTED, PlatformDriverEvent.PING, self._handler_connected_ping)
        self._fsm.add_handler(PlatformDriverState.CONNECTED, PlatformDriverEvent.GET, self._handler_connected_get)
        self._fsm.add_handler(PlatformDriverState.CONNECTED, PlatformDriverEvent.SET, self._handler_connected_set)
        self._fsm.add_handler(PlatformDriverState.CONNECTED, PlatformDriverEvent.EXECUTE, self._handler_connected_execute)
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:34,代码来源:platform_driver.py

示例6: _build_scheduler

    def _build_scheduler(self):
        """
        Remove any previously scheduled event, then generate an absolute trigger to schedule the next
        scan in case we lose some data and the next scan isn't triggered by got_chunk.
        """
        try:
            self._remove_scheduler(ScheduledJob.TAKE_SCAN)
            log.debug('Successfully removed existing scheduled event TAKE_SCAN.')
        except KeyError as ke:
            log.debug('KeyError: %s', ke)

        # this formula was derived from testing, should yield a slightly higher time than the actual
        # time required to collect a single scan.
        delay = self._param_dict.get(Parameter.AP) / 9 / self._param_dict.get(Parameter.NF) + 5

        if delay > 0:
            dt = datetime.datetime.now() + datetime.timedelta(seconds=delay)

            job_name = ScheduledJob.TAKE_SCAN
            config = {
                DriverConfigKey.SCHEDULER: {
                    job_name: {
                        DriverSchedulerConfigKey.TRIGGER: {
                            DriverSchedulerConfigKey.TRIGGER_TYPE: TriggerType.ABSOLUTE,
                            DriverSchedulerConfigKey.DATE: dt
                        },
                    }
                }
            }

            self.set_init_params(config)
            self._add_scheduler_event(ScheduledJob.TAKE_SCAN, ProtocolEvent.TIMEOUT)
开发者ID:cwingard,项目名称:mi-instrument,代码行数:32,代码来源:driver.py

示例7: start_profiler_mission

    def start_profiler_mission(self, mission_name, src):
        def _verify_response(rsp):
            try:
                message = rsp[mission_name]

                if not message.startswith('OK'):
                    raise PlatformException(msg="Error in starting mission %s: %s" % (mission_name, message))
            except KeyError:
                raise PlatformException(msg="Error in starting mission response: %s" % rsp)

        self._verify_rsn_oms('start_profiler_mission')

        try:
            response = self._rsn_oms.profiler.start_mission(self._platform_id,
                                                            mission_name, src)
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot start_profiler_mission: %s" % str(e))

        log.debug("%r: start_profiler_mission response: %s",
                  self._platform_id, response)

        dic_plat = self._verify_platform_id_in_response(response)
        _verify_response(dic_plat)

        return dic_plat  # note: return the dic for the platform
开发者ID:cwingard,项目名称:mi-instrument,代码行数:25,代码来源:rsn_platform_driver.py

示例8: _verify_set_values

    def _verify_set_values(self, params):
        """
        Verify supplied values are in range, if applicable
        @param params: Dictionary of Parameter:value pairs to be verified
        @throws InstrumentParameterException
        """
        constraints = ParameterConstraint.dict()
        parameters = Parameter.reverse_dict()

        # step through the list of parameters
        for key, val in params.iteritems():
            # verify this parameter exists
            if not Parameter.has(key):
                raise InstrumentParameterException('Received invalid parameter in SET: %s' % key)
            # if constraint exists, verify we have not violated it
            constraint_key = parameters.get(key)
            if constraint_key in constraints:
                var_type, minimum, maximum = constraints[constraint_key]
                constraint_string = 'Parameter: %s Value: %s Type: %s Minimum: %s Maximum: %s' % \
                                    (key, val, var_type, minimum, maximum)
                log.debug('SET CONSTRAINT: %s', constraint_string)
                # check bool values are actual booleans
                if var_type == bool:
                    if val not in [True, False]:
                        raise InstrumentParameterException('Non-boolean value!: %s' % constraint_string)
                # else, check if we can cast to the correct type
                else:
                    try:
                        var_type(val)
                    except ValueError:
                        raise InstrumentParameterException('Type mismatch: %s' % constraint_string)
                    # now, verify we are within min/max
                    if val < minimum or val > maximum:
                        raise InstrumentParameterException('Out of range: %s' % constraint_string)
开发者ID:renegelinas,项目名称:mi-instrument,代码行数:34,代码来源:driver.py

示例9: get_nms_eng_data

    def get_nms_eng_data(self):
        
        log.debug("%r: get_nms_eng_data...", self._platform_id)
       
        ntp_time = ntplib.system_to_ntp_time(time.time())      
        
        
        attrs=list();
        
        for streamKey,stream in sorted(self.nodeCfg.node_streams.iteritems()):
 #           log.debug("%r Stream(%s)", self._platform_id,streamKey)
            
            for streamAttrKey,streamAttr in sorted(stream.iteritems()):
 #               log.debug("%r     %r = %r", self._platform_id, streamAttrKey,streamAttr)
 
 
                if 'lastRcvSampleTime' not in streamAttr :   # first time this is called set this to a reasonable value
                    streamAttr['lastRcvSampleTime'] = ntp_time - streamAttr['monitor_cycle_seconds']*2  
                
                lastRcvSampleTime = streamAttr['lastRcvSampleTime']
                
                if (lastRcvSampleTime+streamAttr['monitor_cycle_seconds'])<ntp_time : # if we think that the OMS will have data from us add it to the list
                    if (ntp_time-lastRcvSampleTime)>(streamAttr['monitor_cycle_seconds']*10) : #make sure we dont reach too far back by accident or will 
                        lastRcvSampleTime=ntp_time-(streamAttr['monitor_cycle_seconds']*10)    #clog up the OMS DB search
                        
                    attrs.append((streamAttrKey,lastRcvSampleTime+0.1)) # add a little bit of time to the last recieved so we don't get one we alread have again
            
        if len(attrs)>0 :
                
            
            returnDict = self.get_attribute_values_from_oms(attrs) #go get the data from the OMS
            
            
            for attr_id, attr_vals in returnDict.iteritems(): # go through the returned list of attributes

                for streamKey,stream in sorted(self.nodeCfg.node_streams.iteritems()): #go through all the streams for this platform
                    if attr_id in stream :  # see if this attribute is in this stream
                        for v, ts in attr_vals:
                            stream[attr_id]['lastRcvSampleTime']=ts
                            ionAttrs = self.convertAttrsToIon(stream,[(attr_id,v)]) #scale the attrs and convert the names to ion
              
                    
                            pad_particle = Platform_Particle(ionAttrs,port_timestamp=ts)
              
                            pad_particle.set_internal_timestamp(timestamp=ts)
                  
                            pad_particle._data_particle_type = streamKey  # stream name
                  
                            json_message = pad_particle.generate() # this cals parse values above to go from raw to values dict
           
                            event = {
                                      'type': DriverAsyncEvent.SAMPLE,
                                      'value': json_message,
                                      'time': time.time()
                                      }
                
                            self._send_event(event)
                 
     
        return 1
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:60,代码来源:rsn_platform_driver.py

示例10: disconnect_instrument

    def disconnect_instrument(self, port_id, instrument_id):
        if self._rsn_oms is None:
            raise PlatformConnectionException("Cannot disconnect_instrument: _rsn_oms object required (created via connect() call)")

        try:
            response = self._rsn_oms.instr.disconnect_instrument(self._platform_id,
                                                                 port_id,
                                                                 instrument_id)
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot disconnect_instrument: %s" % str(e))

        log.debug("%r: disconnect_instrument response: %s",
                  self._platform_id, response)

        dic_plat = self._verify_platform_id_in_response(response)
        port_dic = self._verify_port_id_in_response(port_id, dic_plat)
        instr_res = self._verify_instrument_id_in_response(port_id, instrument_id, port_dic)

        # update local image if instrument was actually disconnected in this call:
        if instr_res == NormalResponse.INSTRUMENT_DISCONNECTED:
            # TODO(OOIION-1495) review. This line was commented out, but the
            # PortNode.add_instrument/remove_instrument functionality is
            # being used to keep track of the connected instruments in a port.
            self._pnode.ports[port_id].remove_instrument(instrument_id)
            log.debug("%r: port_id=%s disconnect_instrument: local image updated: %s",
                      self._platform_id, port_id, instrument_id)

        return dic_plat  # note: return the dic for the platform
开发者ID:n1ywb,项目名称:mi-instrument,代码行数:28,代码来源:rsn_platform_driver.py

示例11: turn_off_port

    def turn_off_port(self, port_id):

        try: 
            oms_port_id = self.nodeCfgFile.GetOMSPortId(port_id);
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot turn_off_platform_port: %s" % str(e))
  
        log.debug("%r: turning off port: port_id=%s oms port_id = %s",
                  self._platform_id, port_id,oms_port_id)

 

        if self._rsn_oms is None:
            raise PlatformConnectionException("Cannot turn_off_platform_port: _rsn_oms object required (created via connect() call)")

        try:
            response = self._rsn_oms.port.turn_off_platform_port(self._platform_id,
                                                                 oms_port_id,'CI - User')
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot turn_off_platform_port: %s" % str(e))

        log.debug("%r: turn_off_platform_port response: %s",
                  self._platform_id, response)

        dic_plat = self._verify_platform_id_in_response(response)
        self._verify_port_id_in_response(oms_port_id, dic_plat)

        return dic_plat  # note: return the dic for the platform
开发者ID:n1ywb,项目名称:mi-instrument,代码行数:28,代码来源:rsn_platform_driver.py

示例12: callback_for_alert

    def callback_for_alert(self, event, *args, **kwargs):
        log.debug("caught an OMSDeviceStatusEvent: %s", event)       
        
#        self._notify_driver_event(OMSEventDriverEvent(event['description']))
     
        log.info('Platform agent %r published OMSDeviceStatusEvent : %s, time: %s',
                 self._platform_id, event, time.time())
开发者ID:n1ywb,项目名称:mi-instrument,代码行数:7,代码来源:rsn_platform_driver.py

示例13: _connect

    def _connect(self, recursion=None):
        """
        Creates an CIOMSClient instance, does a ping to verify connection,
        and starts event dispatch.
        """
        # create CIOMSClient:
        oms_uri = self._driver_config['oms_uri']
        log.debug("%r: creating CIOMSClient instance with oms_uri=%r",
                  self._platform_id, oms_uri)
        self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri)
        log.debug("%r: CIOMSClient instance created: %s",
                  self._platform_id, self._rsn_oms)

        # ping to verify connection:
        self._ping()

        # start event dispatch:
        self._start_event_dispatch()
        

        # TODO - commented out
        # self.event_subscriber = EventSubscriber(event_type='OMSDeviceStatusEvent',
        #     callback=self.callback_for_alert)
        #
        # self.event_subscriber.start()

        # TODO(OOIION-1495) review the following. Commented out for the moment.
        # Note, per the CI-OMS spec ports need to be turned OFF to then proceed
        # with connecting instruments. So we need to determine whether we
        # want to turn all ports ON in this "connect driver" operation,
        # and then add the logic to turn a port OFF before connecting
        # instruments, and then ON again; or, just do the OFF/ON logic in the
        # connect_instrument and disconnect_instrument operations,
        # but not here.
        """
开发者ID:n1ywb,项目名称:mi-instrument,代码行数:35,代码来源:rsn_platform_driver.py

示例14: _set_params

    def _set_params(self, *args, **kwargs):
        """
        Issue commands to the instrument to set various parameters
        @param args: arglist, should contain a dictionary of parameters/values to be set
        """
        try:
            params = args[0]
        except IndexError:
            raise InstrumentParameterException('Set command requires a parameter dict.')

        self._verify_set_values(params)
        self._verify_not_readonly(*args, **kwargs)

        # if setting the output rate, get the current rate from the instrument first...
        if Parameter.OUTPUT_RATE in params:
            self._update_params()

        old_config = self._param_dict.get_config()

        # all constraints met or no constraints exist, set the values
        for key, value in params.iteritems():
            self._param_dict.set_value(key, value)

        new_config = self._param_dict.get_config()

        if not old_config == new_config:
            log.debug('Config change: %r %r', old_config, new_config)
            if old_config[Parameter.OUTPUT_RATE] is not None:
                if int(old_config[Parameter.OUTPUT_RATE]) != int(new_config[Parameter.OUTPUT_RATE]):
                    self._do_cmd_no_resp(InstrumentCommand.NANO_SET_RATE, int(new_config[Parameter.OUTPUT_RATE]))
            self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)
开发者ID:renegelinas,项目名称:mi-instrument,代码行数:31,代码来源:driver.py

示例15: _got_data

        def _got_data(port_agent_packet):
            if isinstance(port_agent_packet, Exception):
                return self._got_exception(port_agent_packet)

            if isinstance(port_agent_packet, PortAgentPacket):
                packet_type = port_agent_packet.get_header_type()
                data = port_agent_packet.get_data()

                if packet_type == PortAgentPacket.PORT_AGENT_CONFIG:
                    try:
                        paconfig = json.loads(data)
                        self._port_agent_config[name] = paconfig
                        self._driver_event(DriverAsyncEvent.DRIVER_CONFIG, paconfig)
                    except ValueError as e:
                        log.exception('Unable to parse port agent config: %r %r', data, e)

                elif packet_type == PortAgentPacket.PORT_AGENT_STATUS:
                    log.debug('Received PORT AGENT STATUS: %r', data)
                    current_state = self._connection_fsm.get_current_state()
                    if data == 'DISCONNECTED':
                        self._slave_connection_status[name] = 0
                        self._async_raise_event(DriverEvent.PA_CONNECTION_LOST)
                    elif data == 'CONNECTED':
                        self._slave_connection_status[name] = 1
                        if all(self._slave_connection_status.values()):
                            if current_state == DriverConnectionState.INST_DISCONNECTED:
                                self._async_raise_event(DriverEvent.CONNECT)

                else:
                    protocol = self._slave_protocols.get(name)
                    if protocol:
                        protocol.got_data(port_agent_packet)
开发者ID:danmergens,项目名称:mi-instrument,代码行数:32,代码来源:driver.py


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