本文整理匯總了Python中pydispatch.dispatcher.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python dispatcher.connect方法的具體用法?Python dispatcher.connect怎麽用?Python dispatcher.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pydispatch.dispatcher
的用法示例。
在下文中一共展示了dispatcher.connect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: precmd
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def precmd(self, line):
cmd, args, remain = self.parseline(line)
if not cmd:
return line
if cmd in self.client_connected_commands:
if not self.client.isConnected():
print ""
print "Command '{0}' could only be called with a client connected.".format(cmd)
print "--------------------------------------------------------------"
print ""
print "Use 'SetKeyboardLanguage' to switch to your targtes keyboard"
print "layout and run 'FireStage1' to connect via HID covert channel."
print "--------------------------------------------------------------"
print ""
return ""
return line
示例2: connect
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def connect(self, receiver, signal, **kwargs):
"""
Connect a receiver function to a signal.
The signal can be any object, although Scrapy comes with some
predefined signals that are documented in the :ref:`topics-signals`
section.
:param receiver: the function to be connected
:type receiver: callable
:param signal: the signal to connect to
:type signal: object
"""
kwargs.setdefault('sender', self.sender)
return dispatcher.connect(receiver, signal, **kwargs)
示例3: connect_error_dispatcher
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [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')
示例4: __init__
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def __init__(self, devfile_in, devfile_out, on_connect_callback=None):
self.state={}
self.state["connectCallback"] = on_connect_callback # unused at the moment, callback mustn't be processed in LinkLayer threads
self.fin = devfile_in
self.fout = devfile_out
self.__resetState()
# receive mesage from transport layer
dispatcher.connect(self.__handle_transport_layer, sender=LinkLayer.TRANSPORTLAYER_SENDER_NAME)
示例5: __init__
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def __init__(self):
# create queue for incoming streams to decouple processing from link layer reader thread
self.stream_in_queue = Queue.Queue()
# register Listener for LinkLayer signals
dispatcher.connect(self.handle_link_layer, sender="LinkLayer")
示例6: onClientConnectStateChange
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def onClientConnectStateChange(self, state):
#print "Client connect state: {0}".format(state)
if state:
print "\nTarget connected through HID covert channel\n"
else:
print "\nTarget disconnected"
self.setPrompt(state)
示例7: disconnect
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def disconnect(self, receiver, signal, **kwargs):
"""
Disconnect a receiver function from a signal. This has the
opposite effect of the :meth:`connect` method, and the arguments
are the same.
"""
kwargs.setdefault('sender', self.sender)
return dispatcher.disconnect(receiver, signal, **kwargs)
示例8: send_catch_log
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def send_catch_log(self, signal, **kwargs):
"""
Send a signal, catch exceptions and log them.
The keyword arguments are passed to the signal handlers (connected
through the :meth:`connect` method).
"""
kwargs.setdefault('sender', self.sender)
return _signal.send_catch_log(signal, **kwargs)
示例9: send_catch_log_deferred
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def send_catch_log_deferred(self, signal, **kwargs):
"""
Like :meth:`send_catch_log` but supports returning `deferreds`_ from
signal handlers.
Returns a Deferred that gets fired once all signal handlers
deferreds were fired. Send a signal, catch exceptions and log them.
The keyword arguments are passed to the signal handlers (connected
through the :meth:`connect` method).
.. _deferreds: https://twistedmatrix.com/documents/current/core/howto/defer.html
"""
kwargs.setdefault('sender', self.sender)
return _signal.send_catch_log_deferred(signal, **kwargs)
示例10: __init__
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def __init__(self, zigate, mqtt_host='localhost:1883',
username=None, password=None):
self._mqtt_host = mqtt_host
self.zigate = zigate
self.client = mqtt.Client()
if username is not None:
self.client.username_pw_set(username, password)
dispatcher.connect(self.attribute_changed, ZIGATE_ATTRIBUTE_ADDED)
dispatcher.connect(self.attribute_changed, ZIGATE_ATTRIBUTE_UPDATED)
dispatcher.connect(self.device_changed, ZIGATE_DEVICE_ADDED)
dispatcher.connect(self.device_changed, ZIGATE_DEVICE_UPDATED)
dispatcher.connect(self.device_removed, ZIGATE_DEVICE_REMOVED)
self.client.on_connect = self.on_connect
self.client.on_message = self.on_message
示例11: connect
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def connect(self):
host = self._mqtt_host
port = 1883
if ':' in host:
host, port = host.split(':')
port = int(port)
self.client.connect(host, port)
示例12: start
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def start(self):
self.connect()
self.zigate.autoStart()
self.zigate.start_auto_save()
self.client.loop_forever()
示例13: database_connect
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def database_connect(self):
try:
# set the database connectiont to autocommit w/ isolation level
self.conn = sqlite3.connect('./data/empyre.db', check_same_thread=False)
self.conn.text_factory = str
self.conn.isolation_level = None
return self.conn
except Exception:
print helpers.color("[!] Could not connect to database")
print helpers.color("[!] Please run database_setup.py")
sys.exit()
# def preloop(self):
# traceback.print_stack()
示例14: __init__
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [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()
示例15: listen
# 需要導入模塊: from pydispatch import dispatcher [as 別名]
# 或者: from pydispatch.dispatcher import connect [as 別名]
def listen(receiver, soClass, signal, alsoSubclasses=True, weak=True):
"""
Listen for the given ``signal`` on the SQLObject subclass
``soClass``, calling ``receiver()`` when ``send(soClass, signal,
...)`` is called.
If ``alsoSubclasses`` is true, receiver will also be called when
an event is fired on any subclass.
"""
dispatcher.connect(receiver, signal=signal, sender=soClass, weak=weak)
weakReceiver = ref(receiver)
subclassClones.setdefault(soClass, []).append((weakReceiver, signal))
# We export this function: