本文整理汇总了Python中smokesignal.emit函数的典型用法代码示例。如果您正苦于以下问题:Python emit函数的具体用法?Python emit怎么用?Python emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了emit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:7,代码来源:tests.py
示例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)
开发者ID:carymrobbins,项目名称:helga,代码行数:7,代码来源:comm.py
示例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)
开发者ID:easyNav,项目名称:easyNav-snapper-ui,代码行数:25,代码来源:SerialDaemon.py
示例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
开发者ID:Brightmd,项目名称:smokesignal,代码行数:7,代码来源:tests.py
示例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)
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:30,代码来源:output.py
示例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,
})
开发者ID:ZigmundRat,项目名称:sllurp,代码行数:7,代码来源:main.py
示例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
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:25,代码来源:tests.py
示例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)
开发者ID:bigjust,项目名称:helga,代码行数:7,代码来源:irc.py
示例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()
开发者ID:Brightmd,项目名称:smokesignal,代码行数:8,代码来源:tests.py
示例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)
开发者ID:bigjust,项目名称:helga,代码行数:8,代码来源:slack.py
示例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)
开发者ID:michaelorr,项目名称:helga,代码行数:9,代码来源:comm.py
示例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
开发者ID:Brightmd,项目名称:smokesignal,代码行数:9,代码来源:tests.py
示例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()
开发者ID:Brightmd,项目名称:smokesignal,代码行数:10,代码来源:tests.py
示例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)
开发者ID:carriercomm,项目名称:helga,代码行数:10,代码来源:comm.py
示例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)
开发者ID:bigjust,项目名称:helga,代码行数:10,代码来源:irc.py
示例16: test_CacheEvaluationListener
def test_CacheEvaluationListener():
l = CacheEvaluationListener()
scores = BaseScoresheet({1: 10, 2: 5})
ev = EvaluationSheet(scores, {1})
smokesignal.emit('evaluation_finished', ev, 'd', 'p')
ev2 = EvaluationSheet.from_file(l.fname)
assert_array_equal(ev.data, ev2.data)
smokesignal.clear_all()
os.unlink(l.fname)
开发者ID:TythonLee,项目名称:linkpred,代码行数:10,代码来源:test_listeners.py
示例17: userLeft
def userLeft(self, user, channel):
"""
Called when a user leaves a channel in which the bot resides. Responsible for sending
the ``user_left`` signal (see :ref:`plugins.signals`)
:param user: IRC user string of the form ``{nick}!~{user}@{host}``
:param channel: the channel in which the event occurred
"""
nick = self.parse_nick(user)
smokesignal.emit('user_left', self, nick, channel)
开发者ID:bigjust,项目名称:helga,代码行数:10,代码来源:irc.py
示例18: test_CachePredictionListener
def test_CachePredictionListener():
l = CachePredictionListener()
scoresheet = BaseScoresheet({1: 10, 2: 5, 3: 2, 4: 1})
smokesignal.emit('prediction_finished', scoresheet, 'd', 'p')
with open(l.fname) as fh:
# Line endings may be different across platforms
assert_equal(fh.read().replace("\r\n", "\n"),
"1\t10\n2\t5\n3\t2\n4\t1\n")
smokesignal.clear_all()
os.unlink(l.fname)
开发者ID:TythonLee,项目名称:linkpred,代码行数:11,代码来源:test_listeners.py
示例19: 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 channel: the channel that has been joined
"""
logger.info('Joined %s', channel)
self.channels.add(channel)
self.sendLine("NAMES %s" % (channel,))
smokesignal.emit('join', self, channel)
开发者ID:bigjust,项目名称:helga,代码行数:11,代码来源:irc.py
示例20: on_user_left
def on_user_left(self, element):
"""
Handler called when a user leaves a public room. Responsible for sending
the ``user_left`` signal (see :ref:`plugins.signals`)
:param element: A <presence/> element, instance of `twisted.words.xish.domish.Element`
"""
nick = self.parse_nick(element)
channel = self.parse_channel(element)
logger.debug('User %s left channel %s', nick, channel)
smokesignal.emit('user_left', self, nick, channel)
开发者ID:bigjust,项目名称:helga,代码行数:11,代码来源:xmpp.py
注:本文中的smokesignal.emit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论