def send_message(self, topic=None, msg=None, modname=None): if not topic: warnings.warn("Attempted to send message with no topic. Bailing.") return if not msg: warnings.warn("Attempted to send message with no msg. Bailing.") return # If no modname is supplied, then guess it from the call stack. modname = modname or self.guess_calling_module() topic = '.'.join([modname, topic]) if topic[:len(self.c['topic_prefix'])] != self.c['topic_prefix']: topic = '.'.join([ self.c['topic_prefix'], self.c['environment'], topic, ]) if type(topic) == unicode: topic = to_utf8(topic) msg = dict(topic=topic, msg=msg, timestamp=time.time()) self.publisher.send_multipart([topic, fedmsg.json.dumps(msg)])
def test_to_utf8(self): tools.eq_(converters.to_utf8(self.u_japanese), self.utf8_japanese) tools.eq_(converters.to_utf8(self.utf8_spanish), self.utf8_spanish)
def test_to_utf8(self): tools.ok_(converters.to_utf8(self.u_japanese) == self.utf8_japanese) tools.ok_(converters.to_utf8(self.utf8_spanish) == self.utf8_spanish)