• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pub.sendMessage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pubsub.pub.sendMessage函数的典型用法代码示例。如果您正苦于以下问题:Python sendMessage函数的具体用法?Python sendMessage怎么用?Python sendMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sendMessage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: addStory

 def addStory(self, story, save_extracted_text=False, save_raw_download=True, save_story_sentences=False):
     """ 
     Save a story (python object) to the database.  Return success or failure boolean.
     """
     if self.storyExists(str(story["stories_id"])):
         return False
     story_attributes = {
         "_id": str(story["stories_id"]),
         "title": story["title"],
         "url": story["url"],
         "media_id": story["media_id"],
         "collect_date": story["collect_date"],
         "publish_date": story["publish_date"],
         "description": story["description"],
         "guid": story["guid"],
         "fully_extracted": story["fully_extracted"],  # TODO: look at this instead?
         "stories_id": story["stories_id"],
         "text": story["story_text"],
     }
     if (save_extracted_text == True) and ("story_text" in story):
         story_attributes["story_text"] = story["story_text"]
     if (save_raw_download == True) and ("first_raw_download_file" in story):
         story_attributes["first_raw_download_file"] = story["first_raw_download_file"]
     if "story_sentences" in story:
         story_attributes["story_sentences_count"] = len(story["story_sentences"])
         if save_story_sentences == True:
             story_attributes["story_sentences"] = story["story_sentences"]
     pub.sendMessage(self.EVENT_PRE_STORY_SAVE, db_story=story_attributes, raw_story=story)
     self._db.save(story_attributes)
     saved_story = self.getStory(str(story["stories_id"]))
     pub.sendMessage(self.EVENT_POST_STORY_SAVE, db_story=story_attributes, raw_story=story)
     return True
开发者ID:dydt,项目名称:MediaCloud-API-Client,代码行数:32,代码来源:storage.py


示例2: on_message

    def on_message(self, message_string):
        # Only the first connected client can execute commands
        if not WebServer.clients or not self == WebServer.clients[0]:
            return

        if message_string:
            try:
                message = json.loads(message_string)
            except ValueError, e:
                print "Message is not in json format"
                return

            if "command" in message:
                if message["command"] == "set_frequency":
                    frequency = message["args"]["frequency"]
                    if isinstance(frequency, int):
                        pub.sendMessage("set_frequency", frequency=frequency)

                elif message["command"] == "set_demodulation":
                    demodulation = message["args"]["demodulation"]
                    if demodulation:
                        pub.sendMessage("set_demodulation", demodulation=demodulation)
            elif "notification" in message:
                if message["notification"] == "alive":
                    WebServer.last_connectivity = time.time()
开发者ID:martinleolehner,项目名称:StreamSDR,代码行数:25,代码来源:server.py


示例3: input_handler

	def input_handler(self, fd, event):
		for ln in self.s:
			try:
				(key,val) = ln.split(':', 1)
				
				if (not self.last_values.has_key(key)):
					 self.last_values[key] = 0;
				#if (val == self.last_values[key]):
				#	continue # nevermind
				
				if (key == 'photo'):
					pub.sendMessage(key, level=int(val))
				if (key == 'RH'):
					rounded = round(float(val),1)
					pub.sendMessage(key, humidity=rounded)
				if (key.startswith('temp.')):
					if (float(val) > 50):
						pub.sendMessage('debug', msg=ln)
					pub.sendMessage(key, \
						tempC=float(val),
						tempF=float(val)*(9.0/5.0)+32
						)

				self.last_values[key] = val
			except ValueError:
				pub.sendMessage('debug', msg=ln)
				continue
开发者ID:crackmonkey,项目名称:Rosie,代码行数:27,代码来源:arduino.py


示例4: read

def read(bot):
    global Bot
    Bot = bot
    
    if bot.remote['nick'] and bot.remote['nick'] != bot.nick:
        if bot.remote['message'].startswith(bot.prefix):
            bot._debug("Command received: %s" % bot.remote['message'])
            args = bot.remote['message'][1:].rstrip().split(" ")
            command = args[0].lower()
            
            if bot.remote['nick'].lower() not in bot.inv['banned']:
                if command in library['admin']:
                    bot._debug('This is an admin-only command.')
                    can_do = bot.remote['host'] in [host.strip() for host in bot.config.get(bot.network, 'admin_hostnames').split(',')]
                    #can_do = can_do or bot.remote['nick'] in [nick.strip() for nick in bot.config.get(bot.network, 'admin').split(',')]
                    if can_do:
                        bot.previous['user'] = bot.remote['sendee']
                        pub.sendMessage("func.admin.%s" % library['admin'][command], bot=bot, args=args)
                    else:
                        if bot.voice:
                            reply(bot.remote['sendee'], "%s: Can't do that, noob." % bot.remote['nick'])
                elif bot.voice and command in library['common']:
                    bot._debug('This is a common command.')
                    pub.sendMessage("func.common.%s" % library['common'][command], bot=bot, args=args)
                    bot.previous['user'] = bot.remote['sendee']
        
        elif bot.remote['message'].startswith("\x01") and bot.remote['message'].endswith("\x01"):
            type = bot.remote['message'][1:-1].split()[0]
            args = bot.remote['message'][1:-1].split()[1:]
            if type != "ACTION":
                ctcp(type, args)
        
        elif bot.remote['mid'] == "INVITE" and bot.remote['nick'].lower() not in bot.inv['banned']:
            join([bot.remote['mid'], bot.remote['message']])
        
        else:
            if bot.init['registered'] and not bot.init['identified']:
                if bot.remote['nick'] == "NickServ":
                    if "registered" in bot.remote['message']:
                        bot._login()
                    elif re.search("(accepted|identified)", bot.remote['message']):
                        bot.init['identified'] = True
                        __import__('time').sleep(3)
                        autojoin()
            
            if bot.voice:
                #start scanning messages for certain data
                try: scanner.scan(bot)
                except (__import__('urllib2').URLError, __import__('socket').timeout): util.answer(bot, "fetch: response timeout exceeded.")

    else:
        if (bot.remote['mid'].startswith("4") or bot.remote['mid'].startswith("5")) and bot.remote['mid'] != "462":
            if bot.config.get(bot.network, 'traceback_notice_channel') == "yes" or bot.previous['user'][0] != "#":
                sendto = bot.previous['user'] or self.admin
            else:
                sendto = bot.admin

            reply(sendto, "Message from %s: Error #%s: %s" % (bot.remote['server'], bot.remote['mid'], bot.remote['message']))
        if not bot.init['joined'] and not bot.init['registered']:
            autojoin()
开发者ID:txanatan,项目名称:xbot,代码行数:60,代码来源:_io.py


示例5: next_action

    def next_action(self):
        """The core of the guiding"""

        if not self.babble.finished or len(self.goalexplorer) < self.cfg.guide.min_orderbabble:
            babbling = self.babble.babble(self.t)
            action = Action(type = 'order', payload = babbling)
            path = 0
        else:
            if random.random() < self.cfg.guide.ratio_orderbabble:
                babbling = self.babble.babble(self.t)
                action = Action(type = 'order', payload = babbling)
                path = 1
            else:
                goal = self.goalexplorer.next_goal()
                if goal is None:
                    babbling = self.babble.babble(self.t)
                    action = Action(type = 'order', payload = babbling)
                    path = 2
                else:
                    action = Action(type = 'goal', payload = goal)
                    path = 3

        pub.sendMessage('guide.next_action', guide = self, action = action, path = path)
        self.latest = action
        return action
开发者ID:humm,项目名称:goals,代码行数:25,代码来源:guide.py


示例6: save_settings

    def save_settings(self, evt=None):
        """
        Store the changes to the widgets to the settings.ini file
        This function should probably do some validation
        """
        settings_dict = settings.settings.read_settings()
        for key, old_value in settings_dict.iteritems():
            # This will help skip settings we don't change anyway
            group, item = key.split("/")

            if hasattr(self, item):
                if hasattr(getattr(self, item), "text"):
                    new_value = getattr(self, item).text()
                else:
                    new_value = getattr(self, item).currentText()

                if type(old_value) == int:
                    new_value = int(new_value)
                if type(old_value) == float:
                    new_value = float(new_value)
                if type(old_value) == QtGui.QKeySequence:
                    new_value = QtGui.QKeySequence.fromString(new_value)
                if type(old_value) == bool:
                    new_value = bool(new_value)
                if type(old_value) == unicode:
                    new_value = str(new_value)
                if old_value != new_value:
                    settings_dict[key] = new_value

        settings.settings.save_settings(settings_dict)

        # Notify the rest of the application that the settings have changed
        # TODO: changes here should propagate to the rest of the application (like the database screen)
        pub.sendMessage("changed_settings")
开发者ID:ivoflipse,项目名称:Pawlabeling,代码行数:34,代码来源:settingswidget.py


示例7: changeTimer

 def changeTimer(self, amount):
   print "Model:changeTimer  amount: " + str(amount)
   self.timerValue = self.timerValue - amount
   #if self.timerValue > 0:
   #    pub.sendMessage("timer_counting", amount=1)
       #pub.sendMessage("timer_counting", amount=1) # timer value is not zero, set another interrupt for 1s duration
   pub.sendMessage("timer_changed", money=self.timerValue)
开发者ID:flg8r96,项目名称:pytesting,代码行数:7,代码来源:wx_main.py


示例8: process_dm

 def process_dm(self, data):
  if self.session.db["user_name"] == data["direct_message"]["sender"]["screen_name"]:
   self.put_data("sent_direct_messages", data["direct_message"])
   pub.sendMessage("sent-dm", data=data["direct_message"], user=self.get_user())
  else:
   self.put_data("direct_messages", data["direct_message"])
   pub.sendMessage("direct-message", data=data["direct_message"], user=self.get_user())
开发者ID:codeofdusk,项目名称:ProjectMagenta,代码行数:7,代码来源:stream.py


示例9: testNotifyByPrint

def testNotifyByPrint():
    capture = captureStdout()

    def listener1(arg1):
        pass
    pub.subscribe(listener1, 'baz')
    pub.sendMessage('baz', arg1=123)
    pub.unsubscribe(listener1, 'baz')

    def doa():
        def listener2():
            pass
        pub.subscribe(listener2, 'bar')
    doa() # listener2 should be gc'd
    gc.collect() # for pypy: the gc doesn't work the same as cpython's

    topicMgr.delTopic('baz')

    expect = """\
PUBSUB: New topic "baz" created
PUBSUB: Subscribed listener "listener1" to topic "baz"
PUBSUB: Start sending message of topic "baz"
PUBSUB: Sending message of topic "baz" to listener listener1
PUBSUB: Done sending message of topic "baz"
PUBSUB: Unsubscribed listener "listener1" from topic "baz"
PUBSUB: New topic "bar" created
PUBSUB: Subscribed listener "listener2" to topic "bar"
PUBSUB: Listener "listener2" of Topic "bar" has died
PUBSUB: Topic "baz" destroyed
"""
    captured = capture.getvalue()
    #print captured
    #print repr(expect)
    assert captured == expect, \
        '\n'.join( unified_diff(expect.splitlines(), captured.splitlines(), n=0) )
开发者ID:schollii,项目名称:pypubsub,代码行数:35,代码来源:test2c_notify.py


示例10: openCalFrame

 def openCalFrame(self):
     cv2.destroyAllWindows()
     self.hide()
     global iteration
     iteration = 0
     Publisher.sendMessage("userFrameClosed", arg1="data")
     subFrame = CalibrationFrame()
开发者ID:Qwertycal,项目名称:19520-Eye-Tracker,代码行数:7,代码来源:eyeTrackingMainGUI.py


示例11: test_commands_created

 def test_commands_created(self):
     w = BaseMainWindow(None, None)
         
     cmd1 = Command(1, 'Name1', 'Desc1', lambda: 1, [])
     cmd2 = Command(2, 'Name2', 'Desc2', lambda: 1, [])
     cat1 = CommandCategory('Cat1')
     cat2 = CommandCategory('Cat2')
     
     cat1.append(cmd1)
     cat1.append(cat2)
     cat2.append(cmd2)
     
     tree = [cat1]
     
     pub.sendMessage('commands.created', command_tree=tree)
     
     self.assertEqual(1, w.main_menu.MenuCount)
     self.assertEqual(2, w.main_menu.GetMenu(0).MenuItemCount)
     self.assertEqual(1, w.main_menu.GetMenu(0).FindItemByPosition(1).SubMenu.MenuItemCount)
     
     cmd1.name = 'Nome1'
     cmd1.description = 'Descricao1'
     cmd2.name = 'Nome2'
     cmd2.description = 'Descricao2'
     cat1.name = 'Categoria1'
     cat2.name = 'Categoria2'
     
     pub.sendMessage('commands.changed', command_tree=tree, accel_table=wx.AcceleratorTable([]))
     
     self.assertEqual(cat1.name, w.main_menu.GetMenuLabel(0))
     self.assertEqual(cmd1.name, w.main_menu.GetMenu(0).FindItemByPosition(0).ItemLabel)
     self.assertEqual(cat2.name, w.main_menu.GetMenu(0).FindItemByPosition(1).ItemLabel)
     self.assertEqual(cmd2.name, w.main_menu.GetMenu(0).FindItemByPosition(1).SubMenu.FindItemByPosition(0).ItemLabel)
开发者ID:conradoplg,项目名称:navi,代码行数:33,代码来源:main_test.py


示例12: __init__

    def __init__(self):
        # Values and symbols of the card which will be created
        self.values      = ['1','2','3','4','5','6','7','8','9','10','J','Q','K']
        self.symbols     = ['H', 'S', 'C', 'D']

        # Generate the stock
        self.stock = []
        for symbol in self.symbols:
            for value in self.values:
                self.stock.append(Card(symbol, value))
        shuffle(self.stock)

        # Generate the waste
        self.waste = []

        # generate empty piles for each color
        self.H = []
        self.C = []
        self.S = []
        self.D = []

        # generate empty waste
        self.waste = []

        # generate tableau piles used to play
        self.PlayingStacks = [[], [], [], [], [], [], []]
        for stack in range (0, 7):
            for index in range (-1, stack):
                card = self.stock.pop()
                self.PlayingStacks[stack].append(card)

            self.PlayingStacks[stack][-1].setFaceDown(False)

        # Update GUI
        pub.sendMessage('refreshGUITopic')
开发者ID:statox,项目名称:pylitaire,代码行数:35,代码来源:board.py


示例13: set_to_full

 def set_to_full(self):
     data = self.merge_blocks()
     if self.hash_is_correct(data):
         self.is_full = True
         self.raw_data = data
         self.write_piece_on_disk()
         pub.sendMessage('PiecesManager.PieceCompleted', piece_index=self.piece_index)
开发者ID:gallexis,项目名称:pytorrent,代码行数:7,代码来源:piece.py


示例14: connection_handler

	def connection_handler(self, fd, event):
		if fd == self.listener:
			(con,addr) = self.listener.accept()
			pub.sendMessage('TRACE.TCPSocket', msg=("Accepting connection from:" ,addr))
			con.setblocking(0)
			self.rosie.add_io_handler(con,
					self.request_handler)
开发者ID:crackmonkey,项目名称:Rosie,代码行数:7,代码来源:tcpsocket.py


示例15: save_configuration

 def save_configuration(self):
  if self.codes[self.dialog.general.language.GetSelection()] != config.app["app-settings"]["language"]:
   config.app["app-settings"]["language"] = self.codes[self.dialog.general.language.GetSelection()]
   languageHandler.setLanguage(config.app["app-settings"]["language"])
   self.needs_restart = True
  if self.kmnames[self.dialog.general.km.GetSelection()] != config.app["app-settings"]["load_keymap"]:
   config.app["app-settings"]["load_keymap"] =self.kmnames[self.dialog.general.km.GetSelection()]
   kmFile = open(paths.config_path("keymap.keymap"), "w")
   kmFile.close()
   self.needs_restart = True

  if config.app["app-settings"]["use_invisible_keyboard_shorcuts"] != self.dialog.get_value("general", "use_invisible_shorcuts"):
   config.app["app-settings"]["use_invisible_keyboard_shorcuts"] = self.dialog.get_value("general", "use_invisible_shorcuts")
   pub.sendMessage("invisible-shorcuts-changed", registered=self.dialog.get_value("general", "use_invisible_shorcuts"))
  config.app["app-settings"]["voice_enabled"] = self.dialog.get_value("general", "disable_sapi5")
  config.app["app-settings"]["hide_gui"] = self.dialog.get_value("general", "hide_gui")
  config.app["app-settings"]["ask_at_exit"] = self.dialog.get_value("general", "ask_at_exit")
  config.app["app-settings"]["handle_longtweets"] = self.dialog.get_value("general", "handle_longtweets")
  config.app["app-settings"]["play_ready_sound"] = self.dialog.get_value("general", "play_ready_sound")
  config.app["app-settings"]["speak_ready_msg"] = self.dialog.get_value("general", "speak_ready_msg")
  if config.app["proxy"]["server"] != self.dialog.get_value("proxy", "server") or config.app["proxy"]["port"] != self.dialog.get_value("proxy", "port") or config.app["proxy"]["user"] != self.dialog.get_value("proxy", "user") or config.app["proxy"]["password"] != self.dialog.get_value("proxy", "password"):
   if self.is_started == True:
    self.needs_restart = True
   config.app["proxy"]["server"] = self.dialog.get_value("proxy", "server")
   config.app["proxy"]["port"] = self.dialog.get_value("proxy", "port")
   config.app["proxy"]["user"] = self.dialog.get_value("proxy", "user")
   config.app["proxy"]["password"] = self.dialog.get_value("proxy", "password")
  config.app.write()
开发者ID:codeofdusk,项目名称:ProjectMagenta,代码行数:28,代码来源:settings.py


示例16: variable_selected

    def variable_selected(self,event):
        
        # Find selected variable
        item = self.var_list.selection()
        
        if len(item) == 0:
            return

        # Get associated var_id       
        var_id = self.var_dict[item[0]][0]

        self.displayed_var_id = var_id

        # If selected variable is writeable
        if self.var_dict[item[0]][4] == 1:
            self.variable.set(self.var_dict[item[0]][1])
            
            # First, tell MCU to stop logging former variable ?
            # !!! Warning, if variable was requested by a plot, this is going to shut it down for the plot as well
            
            # Tell MCU to start logging new variable

            # Or other approach is to request the value a single time
                      
        else:
            self.variable.set("** Variable not writeable **")
                      
        pub.sendMessage("new_var_selected",varid=var_id,varname=self.var_dict[item[0]][1])
开发者ID:DanFaudemer,项目名称:TFC,代码行数:28,代码来源:Logger_Frame.py


示例17: send_file

    def send_file(self, file_path):
        self.pauseState = False

        pub.sendMessage('programme-progress', progress=0)
        pub.sendMessage('queue-size', size=0)

        content = ''
        with open(file_path) as f:
            content = f.read()

        if bool(conf.get('common.filter_file_commands')):
            content = self.filter_file(content)
            # self.logger.debug('filtered file:' + content)

        if content is not None and content != '':
            self.commands_executed = 0
            self.queue_size = 0
            self.number_of_commands = 0
            self.clear_command_queue()

            # wait for the sender to become ready
            while self.sender_thread is not None and \
                    self.sender_thread.isRunning():
                time.sleep(0.3)

            self.tracking_progress = True
            self.timer()
            self.echo_back('start-of-file')
            self.sender(content)
            self.echo_back('end-of-file')
开发者ID:dougle,项目名称:Cender,代码行数:30,代码来源:controller_board.py


示例18: zabbix_push

	def zabbix_push(self, key, val):
		# The Zabbix JSON parser is picky, so we have to build the
		# JSON by hand instead of letting the JSON module do it
		injson = '{"request":"sender data",\
	"data":[\
		{\
			"host":"silentbob",\
			"key":"%s",\
			"value":"%s"}]}' % (key, val)

		#pub.sendMessage('zabbix', msg=injson)
	
		try:	
			s = socket(AF_INET, SOCK_STREAM)
			s.settimeout(10)
			s.connect(('hmcgregor01.biggeeks.org', 10051))
			s.send("ZBXD\x01")
			datalen = '%08x' % len(injson)
			datalen = datalen[6:8] + datalen[4:6] + datalen[2:4] + datalen[0:2]
			s.send(datalen)
			s.send(injson)
			#pub.sendMessage('zabbix', msg=s.recv(1024))
			s.close()
		except Exception as e:
			pub.sendMessage('zabbix', msg='Zabbix push failed:'+str(e))
			#nevermind
			pass
开发者ID:crackmonkey,项目名称:Rosie,代码行数:27,代码来源:zabbixpush.py


示例19: block_user

 def block_user(self, data):
  id = data["target"]["id"]
  if id in self.friends:
   self.friends.remove(id)
  if "blocks" in self.session.settings["general"]["buffer_order"]:
   self.session.db["blocked"]["items"].append(data["target"])
   pub.sendMessage("blocked-user", data=data["target"], user=self.get_user())
开发者ID:TWBlueQS,项目名称:TWBlueQS,代码行数:7,代码来源:stream.py


示例20: OnPaletteRequest

    def OnPaletteRequest(self, msg):
	"""
	Used to request the palette when a canvas is first drawn
	"""
	print 'Got palette request!'
	virtualPalette = self._updateVirtualPalette()
	pub.sendMessage('paletteResponse', msg=virtualPalette)
开发者ID:beisserm,项目名称:tilem,代码行数:7,代码来源:palette.py



注:本文中的pubsub.pub.sendMessage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pub.subscribe函数代码示例发布时间:2022-05-25
下一篇:
Python pubsub.subscribe函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap