本文整理汇总了Python中smokesignal.emit函数的典型用法代码示例。如果您正苦于以下问题:Python emit函数的具体用法?Python emit怎么用?Python emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了emit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_emit_with_callback_args
def test_emit_with_callback_args(self):
# Register first
smokesignal.on('foo', self.mock_callback)
assert smokesignal.responds_to(self.mock_callback, 'foo')
smokesignal.emit('foo', 1, 2, 3, foo='bar')
assert self.mock_callback.called_with(1, 2, 3, foo='bar')
示例2: signedOn
def signedOn(self):
for channel in settings.CHANNELS:
if len(channel) > 1:
self.join(channel[0], channel[1])
else:
self.join(channel[0])
smokesignal.emit('signon', self)
示例3: _tick
def _tick(self):
raw = '0,0,0,0,0'
if (self._ser != None):
try:
raw = self._ser.readline()
except SerialException as e:
logging.error('Serial - unable to read data')
pass
parsed = raw.split(',')
x,y,z = 0,0,0
if (self._config['sensor'] == 'phone'):
x = self.x = float(parsed[2])
y = self.y = float(parsed[3])
z = self.z = float(parsed[4])
else: #shoe
#YPRMfssT=,1.67,-53.00,12.33,1.08,0.01,0.11,-0.99,8.00,0,1,
x = self.x = float(parsed[1])
y = self.y = float(parsed[2])
z = self.z = float(parsed[3])
# logging.info(x,y,z)
self.intensity = (x**2 +y**2 + z**2)**0.5
smokesignal.emit('onData', self.x, self.y, self.z, self.intensity)
示例4: test_once_decorator
def test_once_decorator(self):
# Register and call twice
smokesignal.once('foo')(self.fn)
smokesignal.emit('foo')
smokesignal.emit('foo')
assert self.fn.call_count == 1
示例5: handlePrint
def handlePrint(self, logDict):
'''
All printing objects return their messages. These messages are routed
to this method for handling.
Send the messages to the printer. Optionally display the messages.
Decorate the print messages with metadata.
:param logDict: a dictionary representing this log item. Must contain keys
message and type.
:type logDict: dict.
'''
# If the logger returns None, assume we dont want the output
if logDict is None:
return
# write out the log message to file
if self.queue is not None:
self.queue.put(logDict)
res = self.messageToString(logDict)
# Write out the human-readable version to out if needed (but always print out
# exceptions for testing purposes)
if self.printLogs or logDict['type'] == 'ERR':
self.redirectOut.trueWrite(res)
# Broadcast the log to interested parties
smokesignal.emit('logs', logDict)
示例6: tag_seen_callback
def tag_seen_callback(llrpMsg):
"""Function to run each time the reader reports seeing tags."""
tags = llrpMsg.msgdict['RO_ACCESS_REPORT']['TagReportData']
if tags:
smokesignal.emit('rfid', {
'tags': tags,
})
示例7: test_instance_method
def test_instance_method(self):
class Foo(object):
def __init__(self):
# Preferred way
smokesignal.on('foo', self.foo)
# Old way
@smokesignal.on('foo')
def _bar():
self.bar()
self.foo_count = 0
self.bar_count = 0
def foo(self):
self.foo_count += 1
def bar(self):
self.bar_count += 1
foo = Foo()
smokesignal.emit('foo')
smokesignal.emit('bar')
assert foo.foo_count == 1
assert foo.bar_count == 1
示例8: userRenamed
def userRenamed(self, oldname, newname):
"""
:param oldname: the nick of the user before the rename
:param newname: the nick of the user after the rename
"""
smokesignal.emit('user_rename', self, oldname, newname)
示例9: test_once
def test_once(self):
# Register and call twice
smokesignal.once('foo', self.fn)
smokesignal.emit('foo')
smokesignal.emit('foo')
assert self.fn.call_count == 1
assert smokesignal.receivers['foo'] == set()
示例10: slack_hello
def slack_hello(self, data):
"""
Called when the client has successfully signed on to Slack. Sends the
``signon`` signal (see :ref:`plugins.signals`)
:param data: dict from JSON received in WebSocket message
"""
smokesignal.emit('signon', self)
示例11: signedOn
def signedOn(self):
for channel in settings.CHANNELS:
# If channel is more than one item tuple, second value is password
if len(channel) > 1:
self.join(encodings.from_unicode(channel[0]),
encodings.from_unicode(channel[1]))
else:
self.join(encodings.from_unicode(channel[0]))
smokesignal.emit('signon', self)
示例12: test_on_decorator_max_calls_as_arg
def test_on_decorator_max_calls_as_arg(self):
# Register first - like a decorator
smokesignal.on('foo', 3)(self.fn)
# Call a bunch of times
for x in range(10):
smokesignal.emit('foo')
assert self.fn.call_count == 3
示例13: test_on_max_calls
def test_on_max_calls(self):
# Register first
smokesignal.on('foo', self.fn, max_calls=3)
# Call a bunch of times
for x in range(10):
smokesignal.emit('foo')
assert self.fn.call_count == 3
assert smokesignal.receivers['foo'] == set()
示例14: joined
def joined(self, channel):
"""
Called when the client successfully joins a new channel. Adds the channel to the known
channel list and sends the ``join`` signal (see :ref:`plugins.signals`)
:param str channel: the channel that has been joined
"""
logger.info("Joined %s", channel)
self.channels.add(channel)
smokesignal.emit("join", self, channel)
示例15: left
def left(self, channel):
"""
Called when the client successfully leaves a channel. Removes the channel from the known
channel list and sends the ``left`` signal (see :ref:`plugins.signals`)
:param channel: the channel that has been left
"""
logger.info('Left %s', channel)
self.channels.discard(channel)
smokesignal.emit('left', self, channel)