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


Python dispatcher.Any方法代码示例

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


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

示例1: connect_error_dispatcher

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def connect_error_dispatcher():
    clazz = 'aggregator'
    method = 'connect_error_dispatcher'
    # Load dispatchers for communicating error messages to slack (or somewhere else)

    # noinspection PyPep8Naming
    SIGNAL = 'publish-error-signal'
    if 'slack' in BuildConfig.json_config:
        commons.print_msg(clazz, method, 'Detected slack in buildConfig. Connecting error dispatcher to slack.')
        dispatcher.connect(Slack.publish_error, signal=SIGNAL, sender=dispatcher.Any)
    elif BuildConfig.settings.has_section('slack'):
        commons.print_msg(clazz, method, 'Detected slack in global settings.ini.  Connecting error dispatcher to slack.')
        dispatcher.connect(Slack.publish_error, signal=SIGNAL, sender=dispatcher.Any)
    else:
        commons.print_msg(clazz, method, 'No event dispatcher detected. The only place errors will show up is in this '
                                         'log.', 'WARN') 
开发者ID:homedepot,项目名称:flow,代码行数:18,代码来源:aggregator.py

示例2: send

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def send(self, signal=dispatcher.Any, sender=dispatcher.Anonymous,
             *args, **kwargs):
        """
        Send signal/event to registered receivers.

        :param args:
        :param kwargs:
        :return:
        """
        if signal is None:
            signal = dispatcher.Any
        if sender is None:
            sender = dispatcher.Anonymous

        self._dispatcher.send(signal, sender, *args, **kwargs)

        # dispatch this signal to the shell.

        logger.info("sending signal: %s", signal)

        if self._outbox:
            self._outbox.put_nowait((signal, kwargs)) 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:24,代码来源:agent.py

示例3: disconnect

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def disconnect(self, receiver, signal=dispatcher.Any,
                   sender=dispatcher.Any):
        """
        Disconnect the specified receiver.

        :param receiver
        :param signal:
        :param sender:
        """
        if signal is None:
            signal = dispatcher.Any

        if sender is None:
            sender = dispatcher.Anonymous

        self._dispatcher.disconnect(receiver, signal, sender) 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:18,代码来源:agent.py

示例4: dispatch_signal

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def dispatch_signal(signal=dispatcher.Any, sender=dispatcher.Anonymous,
                    *arguments, **named):
    '''
    Dispatch signal with exception proof
    '''
    LOGGER.debug('Dispatch %s', signal)
    try:
        dispatcher.send(signal, sender, *arguments, **named)
    except Exception:
        LOGGER.error('Exception dispatching signal %s', signal)
        LOGGER.error(traceback.format_exc()) 
开发者ID:doudz,项目名称:zigate,代码行数:13,代码来源:core.py

示例5: connect

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def connect(self, receiver, signal=dispatcher.Any, sender=dispatcher.Any):
        """
        Connect the receiver to listen for signals/events.

        :param receiver
        :param signal:
        :param sender:
        """
        if signal is None:
            signal = dispatcher.Any

        if sender is None:
            sender = dispatcher.Anonymous

        self._dispatcher.connect(receiver, signal, sender) 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:17,代码来源:agent.py

示例6: send

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def send(self, signal=dispatcher.Any, sender=dispatcher.Anonymous, *args, **kwargs):
        if signal is None:
            signal = dispatcher.Any
        if sender is None:
            sender = dispatcher.Anonymous

        self._dispatcher.send(signal, sender, *args, **kwargs) 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:9,代码来源:test_core_context.py

示例7: connect

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def connect(self, receiver, signal=dispatcher.Any, sender=dispatcher.Any):
        if signal is None:
            signal = dispatcher.Any

        if sender is None:
            sender = dispatcher.Anonymous

        self._dispatcher.connect(receiver, signal, sender) 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:10,代码来源:test_core_context.py

示例8: __init__

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def __init__(self, mainMenu, sessionID):

        cmd.Cmd.__init__(self)

        self.mainMenu = mainMenu

        self.sessionID = sessionID

        self.doc_header = 'Agent Commands'

        # try to resolve the sessionID to a name
        name = self.mainMenu.agents.get_agent_name(sessionID)

        # set the text prompt
        self.prompt = '(EmPyre: '+helpers.color(name, 'red')+') > '

        # listen for messages from this specific agent
        dispatcher.connect(self.handle_agent_event, sender=dispatcher.Any)

        # display any results from the database that were stored
        # while we weren't interacting with the agent
        results = self.mainMenu.agents.get_agent_results(self.sessionID)
        if results:
            print "\n" + results.rstrip('\r\n')

    # def preloop(self):
    #     traceback.print_stack() 
开发者ID:EmpireProject,项目名称:EmPyre,代码行数:29,代码来源:empyre.py

示例9: _debug_send

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def _debug_send(signal=dispatcher.Any, sender=dispatcher.Anonymous,
                *arguments, **named):
    print("send %s from %s: %s" % (
          nice_repr(signal), nice_repr(sender),
          fmt_args(*arguments, **named)))
    return _real_dispatcher_send(signal, sender, *arguments, **named) 
开发者ID:sqlobject,项目名称:sqlobject,代码行数:8,代码来源:events.py

示例10: _debug_sendExact

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def _debug_sendExact(signal=dispatcher.Any, sender=dispatcher.Anonymous,
                     *arguments, **named):
    print("sendExact %s from %s: %s" % (
          nice_repr(signal), nice_repr(sender), fmt_args(*arguments, **name)))
    return _real_dispatcher_sendExact(signal, sender, *arguments, **named) 
开发者ID:sqlobject,项目名称:sqlobject,代码行数:7,代码来源:events.py

示例11: _debug_connect

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def _debug_connect(receiver, signal=dispatcher.Any, sender=dispatcher.Any,
                   weak=True):
    print("connect %s to %s signal %s" % (
          nice_repr(receiver), nice_repr(signal), nice_repr(sender)))
    return _real_dispatcher_connect(receiver, signal, sender, weak) 
开发者ID:sqlobject,项目名称:sqlobject,代码行数:7,代码来源:events.py

示例12: _debug_disconnect

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def _debug_disconnect(receiver, signal=dispatcher.Any, sender=dispatcher.Any,
                      weak=True):
    print("disconnecting %s from %s signal %s" % (
          nice_repr(receiver), nice_repr(signal), nice_repr(sender)))
    return _real_dispatcher_disconnect(receiver, signal, sender, weak) 
开发者ID:sqlobject,项目名称:sqlobject,代码行数:7,代码来源:events.py

示例13: sendRobust

# 需要导入模块: from pydispatch import dispatcher [as 别名]
# 或者: from pydispatch.dispatcher import Any [as 别名]
def sendRobust(
    signal=Any, 
    sender=Anonymous, 
    *arguments, **named
):
    """Send signal from sender to all connected receivers catching errors
    
    signal -- (hashable) signal value, see connect for details

    sender -- the sender of the signal
    
        if Any, only receivers registered for Any will receive
        the message.

        if Anonymous, only receivers registered to receive
        messages from Anonymous or Any will receive the message

        Otherwise can be any python object (normally one
        registered with a connect if you actually want
        something to occur).

    arguments -- positional arguments which will be passed to
        *all* receivers. Note that this may raise TypeErrors
        if the receivers do not allow the particular arguments.
        Note also that arguments are applied before named
        arguments, so they should be used with care.

    named -- named arguments which will be filtered according
        to the parameters of the receivers to only provide those
        acceptable to the receiver.

    Return a list of tuple pairs [(receiver, response), ... ]

    if any receiver raises an error (specifically any subclass of Exception),
    the error instance is returned as the result for that receiver.
    """
    # Call each receiver with whatever arguments it can accept.
    # Return a list of tuple pairs [(receiver, response), ... ].
    responses = []
    for receiver in liveReceivers(getAllReceivers(sender, signal)):
        try:
            response = robustApply(
                receiver,
                signal=signal,
                sender=sender,
                *arguments,
                **named
            )
        except Exception as err:
            responses.append((receiver, err))
        else:
            responses.append((receiver, response))
    return responses 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:55,代码来源:robust.py


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