當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。