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


Python SettingsBase.get_setting方法代码示例

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


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

示例1: repeat

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
 def repeat(self):
     
     if self.started == False:
         time.sleep(60)
         
     
     interval = SettingsBase.get_setting(self, "interval")
     
     
     if self.__event_timer is not None:
         try:
             self.__xbee_manager.xbee_device_schedule_cancel(
                 self.__event_timer)
         except:
             pass
         
     self.__event_timer = self.__xbee_manager.xbee_device_schedule_after(
             SettingsBase.get_setting(self, "interval"),
             self.repeat)
     
     
     
     
     
     
     try:
         self.__upload_data()
         self.connected = 0
     except:
         self.connected += 1
         print "error in sending from repeat function"
开发者ID:Lewiswight,项目名称:MistAway-Gateway,代码行数:33,代码来源:MistAwayUploadSocket.py

示例2: running_indication

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def running_indication(self):
        # request initial status here.
        self.__tracer.info("Running indication")
        extended_address = SettingsBase.get_setting(self, "extended_address")
        humidity_present = SettingsBase.get_setting(self, "humidity_present")

        # this is a flawed design - if the gateway has just rebooted,
        # and the Xbee sensor sleeps (which it should), then an actual
        # GET_DDO will be issued, which causes Dia to freeze here and
        # almost certainly throw exception and put the device off line.
        try:
            dd_value = self.__xbee_manager.xbee_device_ddo_get_param(
                    extended_address, 'DD', use_cache=True)
        except:
            self.__tracer.warning('Using default DD')
            dd_value = 0x0003000E

        module_id, product_id = parse_dd(dd_value)
        self.__tracer.info('DD info (module_id, product_id) = ' +
                           '(0x%04x, 0x%04x)"', module_id, product_id)

        if product_id == PROD_DIGI_XB_SENSOR_LTH or humidity_present == True:
            self.__tracer.info("Sensor is a '%s' adding humidity channel",
                               product_name(product_id))

            self.add_property(
                ChannelSourceDeviceProperty(name="humidity", type=float,
                    initial=Sample(timestamp=0, value=0.0, unit="%"),
                    perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP)) 
        else:
            self.__tracer.info("Sensor is a '%s' no humidity capability.",
                               product_name(product_id))
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:34,代码来源:digi_temp.py

示例3: start

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def start(self):

        self._tracer.calls("XBeeXBIB.start()")

        # init self._xbee_manager and self._extended_address
        # then register ourself with our Xbee manager
        XBeeBase.pre_start(self)

        # Create a callback specification for our device address, endpoint
        # Digi XBee profile and sample cluster id:
        self._xbee_manager.register_sample_listener(self, self._extended_address,
                                                     self.sample_indication)

        # Configure node sleep behavior:
        sleep_ms = SettingsBase.get_setting(self, "sleep_ms")
        awake_time_ms = SettingsBase.get_setting(self, "awake_time_ms")
        # The original sample rate is used as the sleep rate:

        xbee_sleep_cfg = self._xbee_manager.get_sleep_block(
            self._extended_address,
            sleep=sleep_ms > 0,
            sleep_rate_ms=sleep_ms,
            awake_time_ms=awake_time_ms)

        self._xbee_manager.xbee_device_config_block_add(self, xbee_sleep_cfg)

        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(self._extended_address)

        # Configure pins DIO0 .. DIO3 for digital input:
        for io_pin in ['D0', 'D1', 'D2', 'D3']:
            xbee_ddo_cfg.add_parameter(io_pin, 3)

        # Turn off LEDs:
        for led in LED_IO_MAP:
            xbee_ddo_cfg.add_parameter(LED_IO_MAP[led], 0)

        # Assert that all pin pull-ups are enabled:
        xbee_ddo_cfg.add_parameter('PR', 0x1fff)

        # Enable I/O line monitoring on pins DIO0 .. DIO3:
        xbee_ddo_cfg.add_parameter('IC', 0xf)

        # Register this configuration block with the XBee Device Manager:
        self._xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)

        # Handle channels subscribed to output their data to our led
        # properties:
        cm = self._core.get_service("channel_manager")
        cp = cm.channel_publisher_get()
        for i in range(1, 4):
            setting_name = "led%d_source" % i
            channel_name = SettingsBase.get_setting(self, setting_name)
            if channel_name is not None:
                cp.subscribe(channel_name,
                    (lambda prop: lambda cn: self.update_property(prop, cn))(
                        "led%d" % i))

        # we've no more to config, indicate we're ready to configure.
        return XBeeBase.start(self)
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:62,代码来源:xbee_xbib.py

示例4: run

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
 def run(self):
     """run when our device driver thread is started"""
     
     ip = SettingsBase.get_setting(self, "server_ip")
     port = int(SettingsBase.get_setting(self, "server_port"))
     server = 'wsgiref'
     run_itty(server, ip, port)
开发者ID:nikolaijivkov,项目名称:Cndep_Rest_Service__iDigi_Dia,代码行数:9,代码来源:cndep_rest.py

示例5: make_request

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def make_request(self):
        success = True
        self._tracer.debug("make_request")

        extended_address = SettingsBase.get_setting(self, "extended_address")

        try:
            sample = self.__xbee_manager.xbee_device_ddo_get_param(extended_address, '1S')
            self.__decode_sample(sample)
            self._tracer.debug("Successfully retrieved and decoded sample.")
        except TypeError:
            success = False
            self._tracer.error("Device driver does not match with connected hardware.")
            pass
        except:
            success = False
            self._tracer.warning("Xmission failure, will retry.")
            pass

        # Schedule another heart beat poll, but only if we aren't in sleep mode.
        will_sleep = SettingsBase.get_setting(self, "sleep")
        if will_sleep != True:
            self.__schedule_request()
            self.__reschedule_retry_watchdog()

        return success
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:28,代码来源:xbee_watchport.py

示例6: pre_start

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def pre_start(self):
        """\
            Do initial base class set up required before start, such as
            initialize self._xbee_manager and self._extended_address
        """
        
        if self._xbee_manager is None:
            # then initialize things
            
            self._tracer.calls("XBeeBase.pre_start()")

            # Fetch the XBee Manager name from the Settings Manager:
            dm = self._core.get_service("device_driver_manager")
            self._xbee_manager = dm.instance_get(
                    SettingsBase.get_setting(self, "xbee_device_manager"))

            # Register ourselves with the XBee Device Manager instance:
            self._xbee_manager.xbee_device_register(self)

            # Get the extended address of the device:
            self._extended_address = SettingsBase.get_setting(self, "extended_address")

            # Create a callback specification that calls back this driver when
            # our device has left the configuring state and has transitioned
            # to the running state:
            xbdm_running_event_spec = XBeeDeviceManagerRunningEventSpec()
            xbdm_running_event_spec.cb_set(self.running_indication)
            self._xbee_manager.xbee_device_event_spec_add(self,
                                                    xbdm_running_event_spec)

        # else do nothing
        
        return
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:35,代码来源:xbee_base.py

示例7: run

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def run(self):
        type = SettingsBase.get_setting(self, "type")
        if type == "serial":
            from presentations.console.console_serial_server import \
                 ConsoleSerialServer
            server = ConsoleSerialServer(
                                    SettingsBase.get_setting(self, "device"),
                                    SettingsBase.get_setting(self, "baudrate"),
                                    self.__core,
                                    self.__stopevent
                )
        else:
            server = ConsoleTcpServer(('', 
                                    SettingsBase.get_setting(self, "port")),
                                    ConsoleTcpRequestHandler, self.__core,
                                    self.__stopevent)
        while 1:
            if self.__stopevent.isSet():
                break

            if isinstance(server, ConsoleTcpServer):
                r, w, e = select([server.socket], [], [], 1.0)
            else:
                r = True # Serial ports are always ready

            if r:
                # Spawns a thread for TCP, blocks for Serial
                server.handle_request()

        while hasattr(server, "handlers") and len(server.handlers):
            # Wait for handlers to exit
            time.sleep(1.0)
开发者ID:nikolaijivkov,项目名称:Cndep_Rest_Service__iDigi_Dia,代码行数:34,代码来源:console.py

示例8: run

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def run(self):
        
        #Get the device properties
        time_sleep = SettingsBase.get_setting(self,"update_rate")

        self.input_gpios = SettingsBase.get_setting(self,"input_gpios")
        self.output_gpios = SettingsBase.get_setting(self,"output_gpios")
        
        #Call the GPIOs initializer method
        self.initialize_gpios()
        
        #Start the refresh thread
        while 1:
            if self.__stopevent.isSet():
                self.__stopevent.clear()
                break

            try:
                while self.setting_gpio:
                    pass
                self.get_GPIOs()
            except Exception, e:
                self.__tracer.error("Unable to update values: %s", str(e))
            
            #Sleep the time configured in settings (in seconds)
            digitime.sleep(time_sleep)
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:28,代码来源:ccwi9p9215_gpio.py

示例9: __send_to_idigi

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def __send_to_idigi(self, data):
        """
        Sends data to iDigi

        Keyword arguments:

        data - the XML string to send
        """

        filename = SettingsBase.get_setting(self, "filename")
        filename_format = SettingsBase.get_setting(self, "filename_format")
        filename = filename_format % (filename, self.__current_file_number)
        collection = SettingsBase.get_setting(self, "collection")
        secure = SettingsBase.get_setting(self, "secure")

        print "idigi_upload: Uploading %s to iDigi" % filename

        success, err, errmsg = idigi_data.send_idigi_data(data, filename, collection, secure)
        if not success:
            # if successful, delete upload list else try again next time
            print "idigi_db: Uploading ERROR %s (%s)" % (err,errmsg)

        self.__current_file_number += 1

        max_files = SettingsBase.get_setting(self, "file_count")

        if self.__current_file_number >= max_files + 1:
            self.__current_file_number = 1

        return success
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:32,代码来源:idigi_upload.py

示例10: start

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def start(self):

        # Fetch the XBee Manager name from the Settings Manager:
        xbee_manager_name = SettingsBase.get_setting(self, "xbee_device_manager")
        dm = self.__core.get_service("device_driver_manager")
        self.__xbee_manager = dm.instance_get(xbee_manager_name)

        # Register ourselves with the XBee Device Manager instance:
        self.__xbee_manager.xbee_device_register(self)

        # Get the extended address of the device:
        extended_address = SettingsBase.get_setting(self, "extended_address")

        #register a callback for when the config is done
        xb_rdy_state_spec = XBeeDeviceManagerRunningEventSpec()
        xb_rdy_state_spec.cb_set(self._config_done_cb)
        self.__xbee_manager.xbee_device_event_spec_add(self, xb_rdy_state_spec)
        
        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(extended_address)

        # Call the XBeeSerial function to add the initial set up of our device.
        # This will set up the destination address of the devidce, and also set
        # the default baud rate, parity, stop bits and flow control.
        XBeeSerial.initialize_xbee_serial(self, xbee_ddo_cfg)

        # Register this configuration block with the XBee Device Manager:
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)

        # Indicate that we have no more configuration to add:
        self.__xbee_manager.xbee_device_configure(self)

        return True
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:35,代码来源:MistAway_Controller_update+(lewis+wight's+conflicted+copy+2012-02-06).py

示例11: run

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def run(self):
        """Worker thread for the TCPCSV client.""" 

        state = STATE_NOTCONNECTED
        sd = None

        while not self.__stopevent.isSet():
            if state == STATE_NOTCONNECTED:
                server = SettingsBase.get_setting(self, "server")
                port = SettingsBase.get_setting(self, "port")
                sd = socket(AF_INET, SOCK_STREAM)
                try:
                    sd.connect((server, port))
                except Exception, e:
                    print "TCPCSV(%s): error connecting to %s:%d: %s" % \
                        (self.__name, server, port, str(e))
                    time.sleep(RECONNECT_DELAY)
                    continue
                state = STATE_CONNECTED

            if state == STATE_CONNECTED:
                sio = StringIO()
                self._write_channels(sio)
                try:
                        sd.sendall(sio.getvalue())
                except:
                        try:
                                sd.close()
                        except:
                                pass
                        state = STATE_NOTCONNECTED
                        continue
                del(sio)
                time.sleep(SettingsBase.get_setting(self, "interval"))
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:36,代码来源:tcpcsv.py

示例12: receive

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def receive(self, channel):
        """
        Called whenever there is a new sample

        Keyword arguments:

        channel -- the channel with the new sample
        """

        # we always cache
        if SettingsBase.get_setting(self, "compact_xml"):
            sam = self.__make_compact_xml(channel.name(),channel.get())
        else:
            sam = self.__make_xml(channel.name(),channel.get())
        self.__cache.append(sam)

        self.__sample_count += 1
        print '%s:%d cache:%s' % (self.__name, self.__sample_count, sam)

        # If we have exceeded the sample threshold, notify the thread
        # responsible for pushing up data
        if self.__sample_count >= SettingsBase.get_setting(self, "sample_threshold"):
#             print "idigi_db: Reached threshold of %i, setting event flag" % sample_threshold
            self.__threshold_event.set()

        return
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:28,代码来源:idigi_upload.py

示例13: start

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def start(self):
        """Start the device driver. Returns bool."""

        cm = self.__core.get_service("channel_manager")
        cp = cm.channel_publisher_get()
        # cdb = cm.channel_database_get()

        # get the totalizer source, fault is bad/missing
        x = SettingsBase.get_setting(self, self.DIGITAL_SOURCE)
        try:
            cp.subscribe( x, self.prop_new_total )
            bTimeSource = True
            print '%s: digital source channel is %s' % (self.show_name, x)
        except:
            traceback.print_exc()
            print '%s: no %s Channel (is bad!)' % (self.show_name,x)
            # return False

        # see if we want the delta channel
        try:
            x = eval( SettingsBase.get_setting(self, self.LATCH_OUT))
            print '%s: latch channel is %s' % (self.show_name,x)

            self.latch_out = x
            if self.latch_out:
                # then create them
                self.add_property(
                    ChannelSourceDeviceProperty(
                        name='latch', type=bool,
                        initial=Sample(0, False, 'bool' ),
                        perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP)
                    )

        except:
            traceback.print_exc()
            print '%s: latch channel failed' % self.show_name

        # see if we want the hourly channel
       # try:
       #     x = eval( SettingsBase.get_setting(self, self.HOURLY_OUT))
       #     print '%s: hourly channel is %s' % (self.show_name,x)

        #    if x:
                # then create the channels
        #        self.hourly = [-1,0]
        #        self.add_property(
         #           ChannelSourceDeviceProperty(
         #               name='hourly_last', type=int,
         #               initial=Sample(0, -1, '' ),
         #               perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP)
          #          )

        #except:
        #    traceback.print_exc()
        #    print '%s: hourly channel failed' % self.show_name

            # Setting( name=self., type=str, required=False,
            # Setting( name=self.DAILY_OUT, type=str, required=False,

        return True
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:62,代码来源:digitallatch.py

示例14: run

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def run(self):

        interval = SettingsBase.get_setting(self, "initial_upload")
        if interval is None:
            interval = SettingsBase.get_setting(self, "interval")
        self.__last_upload_clock = 0
        self.__last_upload_time = 0
        while not self.__stopevent.isSet():
            try:
                # 32 bit modulo math to account for an NDS bug :-(
                now = int(digitime.real_clock()) & 0xffffffff
                time_passed = (now - self.__last_upload_clock) & 0xffffffff
                interval_met = (interval > 0 and
                                time_passed > interval)
                threshold_met = self.__threshold_event.isSet()
                if interval_met:
                    interval = SettingsBase.get_setting(self, "interval")
                    self.__sample_count = 0
                    self.__threshold_event.clear()
                    self.__upload_data()
                elif threshold_met:
                    interval = SettingsBase.get_setting(self, "interval")
                    self.__threshold_event.clear()
                    self.__upload_data()
                digitime.sleep(1)
            except Exception, e:
                self.__tracer.error("exception while uploading: %s", str(e))
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:29,代码来源:idigi_db.py

示例15: start

# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import get_setting [as 别名]
    def start(self):
        """
        Starts the web presentation module.
        If the use_default_httpserver setting is specified it starts own http server on the specified port.
        """
        isDefault = SettingsBase.get_setting(self, 'use_default_httpserver')
        if not globals().has_key('Callback'):
            isDefault = False

        if isDefault:
            self._cb_handle = Callback(self.cb)
            print "Web2 (%s): using web page %s" % (self.__name,
                self.get_page())
            print "... using digiweb"
        else:
            self._cb_handle = self.get_channels
            try:
                port = SettingsBase.get_setting(self, 'port')
                print "Web Presentation (%s): using port %d" % (self.__name, port)
                print "... using BaseHTTPServer"
                HTTPServer.__init__(self, ('', port), WebRequestHandler)
            except Exception:
                traceback.print_exc()
                self.socket.close()
            # Only start a thread if the Python web-server is
            # used:
            threading.Thread.start(self)
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:29,代码来源:web2.py


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