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


Python dispatcher.connect函数代码示例

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


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

示例1: connect

    def connect(self, receiver, sender=Any, weak=True):
        """
        Connect receiver to sender for this signal. Wrapper for
        :func:`connect`. Usage::

            from xyz import post_save

            def log_saving_event(**kwargs):
                ...
            # call log_saving_event each time a Note is saved
            post_save.connect(log_saving_event, Note)

        Publishes a debug log message via Python's `logging` module.
        """
        connect(receiver, signal=self, sender=sender, weak=weak)

        # Log readable representation of both signal and receiver.
        # This is cheap because signals are mostly connected on start.
        if hasattr(receiver, '__module__') and hasattr(receiver, '__name__'):
            rcvr_repr = u'{0}.{1}'.format(receiver.__module__,
                                          receiver.__name__)
        else:
            rcvr_repr = unicode(repr(receiver))

        logger.debug('Subscribed {rcvr_repr} to "{self}"'.format(**locals()))
开发者ID:neithere,项目名称:tool,代码行数:25,代码来源:signals.py

示例2: test_910_controller_stats_poll

 def test_910_controller_stats_poll(self):
     self.stats_received = None
     dispatcher.connect(self.louie_controller_stats, ZWaveController.SIGNAL_CONTROLLER_STATS)
     self.network.controller.poll_stats = 8
     for i in range(0,10):
         #print("self.ctrl_command_result = %s" % self.ctrl_command_result)
         if self.stats_received is not None:
             break
         else:
             time.sleep(1.0)
     self.assertEqual(type(self.stats_received), type({}))
     self.assertTrue('SOFCnt' in self.stats_received)
     self.stats_received = None
     for i in range(0,10):
         #print("self.ctrl_command_result = %s" % self.ctrl_command_result)
         if self.stats_received is not None:
             break
         else:
             time.sleep(1.0)
     self.assertEqual(type(self.stats_received), type({}))
     self.network.controller.poll_stats = 0
     self.stats_received = None
     for i in range(0,12):
         #print("self.ctrl_command_result = %s" % self.ctrl_command_result)
         if self.stats_received is not None:
             break
         else:
             time.sleep(1.0)
     self.assertEqual(self.stats_received, None)
开发者ID:CadConsultants,项目名称:python-openzwave,代码行数:29,代码来源:test_controller.py

示例3: __init__

 def __init__(self, jobs_root_path, jobs_loader):
     self.control_threads = {}
     self.jobs_loader = jobs_loader
     self.job_configs = jobs_loader.get_jobs()
     self.jobs_root_path = jobs_root_path
     dispatcher.connect(self.handle_job_signal, signal=JOB_COMMAND_SIGNAL, sender=dispatcher.Any)
     dispatcher.connect(self.handle_generic_signal, signal=COMMAND_SIGNAL, sender=dispatcher.Any)
开发者ID:DepaMarco,项目名称:pydio-sync,代码行数:7,代码来源:scheduler.py

示例4: from_crawler

    def from_crawler(cls, crawler, *args, **kwargs):
        spider = cls(*args, **kwargs)
        spider._set_crawler(crawler)
        
        spider._set_ref_object(Scraper, **kwargs)
        spider.scraper = spider.ref_object
        spider._set_config(**kwargs)
        
        if spider.scraper.checker_set.count() == 0:
            msg = "No checkers defined for scraper!"
            spider.dds_logger.error(msg)
            raise CloseSpider(msg)
        
        for checker in spider.scraper.checker_set.all():
            if checker.checker_type == '4':
                if not checker.checker_ref_url:
                    msg = "Please provide a reference url for your checker ({c}).".format(c=str(checker))
                    spider.dds_logger.error(msg)
                    raise CloseSpider(msg)
            
            if checker.checker_type == 'X':
                if not checker.checker_x_path or not checker.checker_ref_url:
                    msg = "Please provide the necessary x_path fields for your checker ({c}).".format(c=str(checker))
                    spider.dds_logger.error(msg)
                    raise CloseSpider(msg)

        spider._set_request_kwargs()
        spider._set_meta_splash_args()
        
        dispatcher.connect(spider.response_received, signal=signals.response_received)
        
        return spider
开发者ID:holgerd77,项目名称:django-dynamic-scraper,代码行数:32,代码来源:checker_test.py

示例5: test_000_network_start_stop

 def test_000_network_start_stop(self):
     self.driver_ready = False
     self.driver_removed = False
     self.options = ZWaveOption(device=self.device, user_path=self.userpath)
     self.options.set_log_file("OZW_Log.log")
     self.options.set_append_log_file(False)
     self.options.set_console_output(False)
     self.options.set_save_log_level("Debug")
     self.options.set_logging(True)
     self.options.lock()
     dispatcher.connect(self.driver_ready_message, ZWaveNetwork.SIGNAL_DRIVER_READY)
     dispatcher.connect(self.driver_removed_message, ZWaveNetwork.SIGNAL_DRIVER_REMOVED)
     self.network = ZWaveNetwork(self.options)
     for i in range(0, SLEEP):
         if self.network.state>=self.network.STATE_AWAKED:
             break
         else:
             time.sleep(1.0)
     self.assertTrue(self.driver_ready)
     self.network.stop()
     for i in range(0, SLEEP):
         if self.network.state==self.network.STATE_STOPPED:
             break
         else:
             time.sleep(1.0)
     self.assertEqual(self.network.state, self.network.STATE_STOPPED)
开发者ID:CadConsultants,项目名称:python-openzwave,代码行数:26,代码来源:test_network_start.py

示例6: configure

def configure():
    level = cbpos.config['app', 'log']
    level = getattr(logging, level if level in LEVELS else LEVELS[0])
    
    filename = cbpos.config['app', 'log_file']
    filepath = os.path.realpath(filename) if filename != '' else None
    
    use_colors = bool(cbpos.config['app', 'log_use_colors'])
    
    root = logging.getLogger() 
    root.setLevel(level)
    
    # The standard format used for file logging and console logging
    log_format = '%(name)s: %(message)s (%(filename)s:%(lineno)s)'
    long_log_format = '[%(levelname)8s]\t'+log_format
    
    console = logging.StreamHandler()
    
    # Format with colors
    if use_colors and ColoredFormatter is not None:
        console.setFormatter(ColoredFormatter(log_format))
    else:
        console.setFormatter(logging.Formatter(long_log_format))
    
    if filepath:
        # Set up logging to a file
        fh = logging.FileHandler(filepath, 'w')
        fh.setFormatter(logging.Formatter(long_log_format))
        root.addHandler(fh)
    else:
        root.addHandler(console)
    
    # Log any signal from any sender
    dispatcher.connect(log_signals, signal=dispatcher.Any, sender=dispatcher.Any)
开发者ID:coinbox,项目名称:coinbox-core,代码行数:34,代码来源:logger.py

示例7: run

def run(config_path=None):
        
    if config_path != None and not os.path.isfile(config_path):
        raise Exception('config_path does not exist! %s' % config_path)
    elif config_path is None:
        config_path = resource_filename("illiquids", "tornado.conf")
        if not os.path.isfile(config_path):
            raise Exception('no config_path!')
        
    tornado.options.parse_config_file(config_path)
    tornado.options.parse_command_line()
    logging.info("Loaded tornado config %s " % config_path)
    
    application = Application()

    logging.info('listening on port:%s' % options.port)
    
    #Native Tornado stuff
    application.listen(options.port)
    io_loop = tornado.ioloop.IOLoop.instance()
    
    def shutdown():
        logging.warning('Service request message to shut down')
        io_loop.stop()
    
    dispatcher.connect(shutdown, SHUTTING_DOWN)
    io_loop.start()
    
    return application
开发者ID:robertbetts,项目名称:Kew,代码行数:29,代码来源:run.py

示例8: __init__

 def __init__(self,signal,sender,notifCallback):
     
     # log
     log.debug("create instance")
     
     # store params
     self.notifCallback = notifCallback
     self.sender        = sender
     
     # initialize parent class
     threading.Thread.__init__(self)
     
     # give this thread a name
     self.name          = 'MoteConnectorConsumer'
     
     # local variables
     self.goOn          = True
     self.dataQueue     = Queue.Queue(self.QUEUESIZE)
     
     # connect to dispatcher
     dispatcher.connect(
         #notifCallback,
         self._eventBusNotification,
         signal = signal,
     )
开发者ID:GiuX,项目名称:giux-openwsn-sw,代码行数:25,代码来源:MoteConnectorConsumer.py

示例9: __init__

 def __init__(self):
     self.wm = pyinotify.WatchManager()
     # These two instance variables are assumed to be constant
     self.watch_channel    = getsig('watch')
     self.organize_channel = getsig('organize')
     self.watch_listener   = StoreWatchListener(signal = self.watch_channel)
     self.__timeout_thread = ManagerTimeout(self)
     self.__timeout_thread.daemon = True
     self.__timeout_thread.start()
     self.organize = {
         'organize_path'      : None,
         'imported_path'      : None,
         'recorded_path'      : None,
         'problem_files_path' : None,
         'organizer'          : None,
         'problem_handler'    : None,
         'organize_listener'  : OrganizeListener(signal=
             self.organize_channel),
     }
     def dummy(sender, event): self.watch_move( event.path, sender=sender )
     dispatcher.connect(dummy, signal=getsig('watch_move'), 
             sender=dispatcher.Any, weak=False)
     def subwatch_add(sender, directory):
         self.__add_watch(directory, self.watch_listener)
     dispatcher.connect(subwatch_add, signal=getsig('add_subwatch'),
             sender=dispatcher.Any, weak=False)
     # A private mapping path => watch_descriptor
     # we use the same dictionary for organize, watch, store wd events.
     # this is a little hacky because we are unable to have multiple wd's
     # on the same path.
     self.__wd_path = {}
     # The following set isn't really necessary anymore. Should be
     # removed...
     self.watched_directories = set([])
开发者ID:FutureMusicFM,项目名称:Airtime,代码行数:34,代码来源:manager.py

示例10: _fromXMLElement

 def _fromXMLElement(cls, xmlElement, network = None):
     frame = NeuroptikonFrame()
     
     # Restore any console history.
     commandHistoryElement = xmlElement.find('CommandHistory')
     if commandHistoryElement is not None:
         history = []
         for commandElement in commandHistoryElement.findall('Command'):
             history += [commandElement.text]
         frame._console.history = history
     
     # TODO: set frame position and size
     
     # Populate the display (can't use the _fromXMLElement pattern here because it doesn't seem possible to re-parent a wx.GLCanvas.
     displayElement = xmlElement.find('Display')
     if displayElement is None:
         raise ValueError, gettext('Display windows must contain a display')
     frame.display.autoVisualize = False
     frame.display.setNetwork(network)
     if network:
         dispatcher.connect(frame.networkDidChangeSavePath, ('set', 'savePath'), network)
     frame.display._fromXMLElement(displayElement)
     frame.networkDidChangeSavePath()
     frame.setModified(False)
     wx.GetApp().inspector.inspectDisplay(frame.display)
     
     return frame
开发者ID:mthunemann,项目名称:Neuroptikon,代码行数:27,代码来源:neuroptikon_frame.py

示例11: __init__

    def __init__(self, serialport):

        # log
        log.info("creating instance")

        # store params
        self.serialport = serialport

        # local variables
        self.parser = OpenParser.OpenParser()
        self.stateLock = threading.Lock()
        self.networkPrefix = None
        self._subcribedDataForDagRoot = False

        # give this thread a name
        self.name = "[email protected]{0}".format(self.serialport)

        eventBusClient.eventBusClient.__init__(
            self,
            name=self.name,
            registrations=[
                {"sender": self.WILDCARD, "signal": "infoDagRoot", "callback": self._infoDagRoot_handler},
                {"sender": self.WILDCARD, "signal": "cmdToMote", "callback": self._cmdToMote_handler},
            ],
        )

        # subscribe to dispatcher
        dispatcher.connect(self._sendToParser, signal="[email protected]" + self.serialport)
开发者ID:pedrohenriquegomes,项目名称:openwsn-sw-ewsn,代码行数:28,代码来源:moteConnector.py

示例12: depend_signal

 def depend_signal( self, signal, sender=dispatcher.Any ):
     """Depend on signal from sender"""
     dispatcher.connect(
         self.clear,#receiver
         signal,
         sender,
     )
开发者ID:mcfletch,项目名称:pyvrml97,代码行数:7,代码来源:cache.py

示例13: __init__

 def __init__(self, node, network):
     """Initialize node."""
     # pylint: disable=import-error
     super().__init__()
     from openzwave.network import ZWaveNetwork
     from pydispatch import dispatcher
     self._network = network
     self.node = node
     self.node_id = self.node.node_id
     self._name = node_name(self.node)
     self._product_name = node.product_name
     self._manufacturer_name = node.manufacturer_name
     self._unique_id = self._compute_unique_id()
     self._attributes = {}
     self.wakeup_interval = None
     self.location = None
     self.battery_level = None
     dispatcher.connect(
         self.network_node_changed, ZWaveNetwork.SIGNAL_VALUE_CHANGED)
     dispatcher.connect(self.network_node_changed, ZWaveNetwork.SIGNAL_NODE)
     dispatcher.connect(
         self.network_node_changed, ZWaveNetwork.SIGNAL_NOTIFICATION)
     dispatcher.connect(
         self.network_node_event, ZWaveNetwork.SIGNAL_NODE_EVENT)
     dispatcher.connect(
         self.network_scene_activated, ZWaveNetwork.SIGNAL_SCENE_EVENT)
开发者ID:ManHammer,项目名称:home-assistant,代码行数:26,代码来源:node_entity.py

示例14: inner

 def inner(receiver):
     if isinstance(signal, Signal):
         # preferable: involves proper logging
         signal.connect(receiver=receiver, sender=sender, weak=weak)
     else:
         connect(receiver, signal=signal, sender=sender, weak=weak)
     return receiver
开发者ID:neithere,项目名称:tool,代码行数:7,代码来源:signals.py

示例15: __init__

    def __init__(self, parent):
        mdc_gui.MultiPing.__init__(self, parent)

        self.ping_list = ObjectListView(self.olv_panel, wx.ID_ANY,
                                        style=wx.LC_REPORT |
                                        wx.SUNKEN_BORDER)
        self.ping_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,
                            self.MultiPingOnContextMenu)
        self.ping_list.SetColumns(
            [ColumnDefn("IP", "center", 100, "ip_address"),
             ColumnDefn("MAC", "center", 130, "mac_address"),
             ColumnDefn("Hostname", "center", 130, "hostname"),
             ColumnDefn("Serial", "center", 150, "serial"),
             ColumnDefn("Successful Pings", "center", 110, "success"),
             ColumnDefn("Failed Pings", "center", 80, "failed")])

        self.olv_sizer.Add(self.ping_list, 1, wx.ALL | wx.EXPAND, 0)
        self.olv_sizer.Layout()

        self.parent = parent
        self.log_link_txt.SetURL(os.path.join(self.parent.path, 'ping_logs'))

        self.SetTitle("Multiple Ping Monitor")
        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.redraw_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_refresh, self.redraw_timer)
        self.redraw_timer.Start(1000)

        dispatcher.connect(self.list_update,
                           signal='Ping Model Update',
                           sender=dispatcher.Any)
开发者ID:AMXAUNZ,项目名称:Magic-DXLink-Configurator,代码行数:32,代码来源:multi_ping.py


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