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

Python mbus.Bus类代码示例

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

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



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

示例1: _onError

 def _onError(self, e):
     try:
         details=self._getDeviceDetails(e.device)
         self._q.put(["%device-error", details], block=True)
         Bus.publish(self, "%log", "warning", "Device error: %s" % details)
     except Exception,e:
         Bus.publish(self, "%log", "error", "exception whilst attempting to report Phidgets.onError (%s)" % e)        
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:7,代码来源:manager.py


示例2: activate

    def activate (self, shell):
        """
        Called by Rhythmbox when the plugin is activated
        """
        self.active=True
        self.shell = shell
        self.sp = shell.get_player()
        self.db=self.shell.props.db
        self.sl=shell.props.sourcelist
        self.plm=shell.get_playlist_manager()
        
        ## We might have other signals to connect to in the future
        self.dbcb = (
                     #self.db.connect("entry-added",    self.on_entry_added),
                     #self.db.connect("entry-deleted",  self.on_entry_deleted),
                     #self.db.connect("entry-changed",  self.on_entry_changed),
                     self.db.connect("load-complete",  self.on_load_complete),
                     )
        
        self.slcb = (
                     self.sl.connect("drop-received",  self.on_drop_received),
                     #self.sl.connect("selected",       self.on_selected),
                     )

        self.plcb = (
                     self.plm.connect("playlist-added",   self.on_playlist_added),
                     self.plm.connect("playlist-created", self.on_playlist_created),
                     #self.plm.connect("status-changed",   self.on_status_changed),
                     )
        
        ## Distribute the vital RB objects around
        Bus.publish("__pluging__", "rb_shell", self.shell, self.db, self.sp)
        
        self.type_song=self.db.entry_type_get_by_name("song")
开发者ID:jldupont,项目名称:rb_playlists_auto_export,代码行数:34,代码来源:__init__.py


示例3: _hDin

 def _hDin(self, serial, pin, value):
     pname, mval=self.domap(serial, pin, value)
     #print "_hDin, %s, %s, %s, %s" % (serial, pin, value, pname)        
     if mval is not None:
         Bus.publish(self, "%state-changed", serial, pname, mval)
     else:
         Bus.publish(self, "%state-changed", serial, "din:%s" % pin, mval)
开发者ID:jldupont,项目名称:phidgets-dbus,代码行数:7,代码来源:sensors.py


示例4: __init__

 def __init__(self):
     self.config={}
     self.conn=None
     self.chan=None
     self.cpoll=0
     self.cLastConnAttempt=0
     Bus.publish(self,"%llconfig", self.LCONFIG)
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:7,代码来源:manager_handler.py


示例5: validateConfig

 def validateConfig(self, config):
     """ Validates (as much as possible) the configuration information
         before handing it off
         
         Categories: "States", "Devices"
         Pins: integer
     """
     pinmap={}
     
     try:    devices=config.get("Devices", None) or config["devices"] 
     except:
         self.log("warning", "Configuration file missing 'Devices' section")
         return
     
     try:    states=config.get("States", None) or config["states"] 
     except:
         self.log("warning", "Configuration file missing 'States' section")
         return
         
     pinnames=[]
         
     try:
         for device_name in devices:
             device=devices[device_name]
             
             try: pins = device.get("Pins", None) or device["pins"]
             except:
                 self.log("warning", "Expecting 'pins' entry for Device(%s) in 'Devices' section" % device_name)
                 return
             
             for pin in pins:
                 pname=pins[pin]
                 pinnames.extend([pname])
                 try:    _ipin=int(pin)
                 except:
                     self.log("warning", "Expecting 'integer' value for pin entry, device(%s)" % device)
                     return
                 
                 ## stringify for less headache: normalize type
                 m="%s.%s" % (device_name, pin)
                 pinmap[m] = pname
     except:
         self.log("warning", "Error whilst validating 'Devices' section of configuration file")
         return
     
     #print "pinnames: ",pinnames
     
     try:
         for pinname in states:
             if not pinname in pinnames:
                 self.log("warning", "Pin name(%s) not found in any 'Device' definition" % pinname)
     except:
         self.log("warning", "Error whilst validating 'States' section of configuration file")
         return
         
     self.config=config
     self.log("info", "Successfully validated configuration file(%s)" % self.cpath)
     Bus.publish(self, "%config-sensors", self.config)
     Bus.publish(self, "%pin-map", pinmap)
开发者ID:jldupont,项目名称:phidgets-dbus,代码行数:59,代码来源:config.py


示例6: Devices

 def Devices(self, devices):
     """ Signal Handler
     
         Signal normally issued by Phidgets-Manager
     """
     for device in devices:
         ddetails=deviceHelper(device)
         Bus.publish(self, "%device", ddetails)
开发者ID:jldupont,项目名称:phidgets-dbus,代码行数:8,代码来源:ifk_handler.py


示例7: processChange

 def processChange(self, iotype, dic):
     serial=dic["serial"]
     pin=dic["pin"]
     value=dic["value"]
     pname, mval=self.domap(serial, iotype, pin, value)
     dic.update({"sensor_name": pname, "sensor_state": mval})
     if mval is not None:
         Bus.publish(self, "%state-changed", iotype, dic)
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:8,代码来源:sensors.py


示例8: _doUpdateInfo

 def _doUpdateInfo(self):
     """ Sends an update on the discovered devices """
     devices=self._mng.getAttachedDevices()
     result=[]
     for device in devices:
         details=self._getDeviceDetails(device)
         result.extend([details])
     Bus.publish(self, "%devices", result)
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:8,代码来源:manager.py


示例9: processMsg

 def processMsg(self, data):
     
     try:   
         devices=json.loads(data)
     except Exception,e:
         Bus.publish(self, "%llog", "%json-decode", 
                     "warning", "Error(%s) decoding json object: %s" % (e, data))
         return
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:8,代码来源:ifk_manager.py


示例10: on_load_complete

 def on_load_complete(self, *_):
     """
     'load-complete' signal handler
     
     Publishes the filtered list of db entries
     """
     self.load_complete=True
     Bus.publish("pluging", "load_complete")
     Bus.publish("pluging", "song_entries", self.song_entries)
开发者ID:jldupont,项目名称:rb_synclastfm,代码行数:9,代码来源:__init__.py


示例11: __init__

 def __init__(self):
     self._q=Queue()
     self._mng=None
     self._info_publish_counter=0
     try:
         self._mng=Manager()
         self._setup()
     except Exception,e:
         Bus.publish(self, "%log", "error", "Can't instantiate Phidgets.Manager (%s)" % e)
         raise RuntimeError("can't instantiate Phidgets.Manager")
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:10,代码来源:manager.py


示例12: _setup

 def _setup(self):
     self._mng.setOnAttachHandler(self._onAttach)
     self._mng.setOnDetachHandler(self._onDetach)
     self._mng.setOnErrorHandler(self._onError)
     
     try:
         self._mng.openManager()
     except Exception,e:
         Bus.publish(self, "%log", "error", "Can't open Phidgets.Manager (%s)" % e)
         raise RuntimeError("Can't open Phidgets.Manager")
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:10,代码来源:manager.py


示例13: _hPoll

 def _hPoll(self, pc):
     if not self.config:
         Bus.publish(self, "%config-amqp?")
     
     if not self.comm:
         self.comm=AMQPCommTx(self.config, self.EXCH)
         self.comm.connect()
         
     if not self.comm.isOk():
         del self.comm
         self.comm=None
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:11,代码来源:sensors_handler.py


示例14: on_entry_added

 def on_entry_added(self, _tree, entry):
     """
     'entry-added' signal handler
     
     Filters the db entries based on the 'song' entry type
     """
     type=entry.get_entry_type()
     if type==self.type_song:
         if not self.load_complete:
             id=self.db.entry_get(entry, rhythmdb.PROP_ENTRY_ID)
             self.song_entries.append(int(id))
             Bus.publish("pluging", "entry_added", id, entry)
开发者ID:jldupont,项目名称:rb_synclastfm,代码行数:12,代码来源:__init__.py


示例15: setup

 def setup(self):
     """ Setup the connection & channel """
     Bus.publish(self, "%config-amqp?")
     
     try:
         self.conn=amqp.Connection(insist=True, **self.config)
     except Exception,e:
         self.conn=None
         Bus.publish(self, "%conn-error")
         self.log("%conn-error", "error", 
                  "Failed to connect to AMQP broker. Exception(%s)" % e)
         return
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:12,代码来源:manager_handler.py


示例16: _hpoll

    def _hpoll(self, pc):
        if self.config is None:
            Bus.publish(self, "%config-amqp?")

        if self.comm is not None:
            if not self.comm.isOk():
                del self.comm
                self.comm=None
            
        if self.comm is None:
            self.comm=AMQPCommTx(self.config, self.EXCH)
            self.comm.connect()
开发者ID:jldupont,项目名称:phidgets-amqp,代码行数:12,代码来源:ifk_handler.py


示例17: on_playing_song_changed

 def on_playing_song_changed (self, sp, entry):
     """
     The event that starts the whole "sync" process
     """
     ## unfortunately, I don't have a better process
     ## for keeping the "user parameters" synced just yet...
     Bus.publish("pluging", "config?")
     
     self.current_entry = sp.get_playing_entry()
     details=EntryHelper.track_details(self.shell, entry)
     if details:
         track=Track(details=details, entry=self.current_entry)
         Bus.publish("pluging", "track?", track)
开发者ID:jldupont,项目名称:rb_synclastfm,代码行数:13,代码来源:__init__.py


示例18: processMsgQueue

    def processMsgQueue(self):
        while True:
            msg=self.currentWorker.rxFromWorker()
            if msg is None:
                break
            try:
                mtype=msg.pop(0)
                mdata=msg.pop(0)
            except:
                Bus.publish(self, "%llog", "%msg-error", "error", "Error whilst decoding message from AMQP exchange 'org.sensors' ")
                continue

            ## e.g. "state.io.din"
            Bus.publish(self, mtype, mdata)
开发者ID:jldupont,项目名称:sensors-apps,代码行数:14,代码来源:event_logger.py


示例19: create_configure_dialog

 def create_configure_dialog(self, dialog=None):
     """
     This method is called by RB when "configure" button
     is pressed in the "Edit->Plugins" menu.
     
     Note that the dialog *shouldn't* be destroyed but "hidden" 
     when either the "close" or "X" buttons are pressed.
     """
     if not dialog:
         glade_file_path=self.find_file("config.glade")
         proxy=ConfigDialog(glade_file_path)
         dialog=proxy.get_dialog() 
     dialog.present()
     Bus.publish("pluging", "config?")
     return dialog
开发者ID:jldupont,项目名称:rb_synclastfm,代码行数:15,代码来源:__init__.py


示例20: _hpoll

    def _hpoll(self, pc):
        self.cpc=pc
        
        if not self.config:
            Bus.publish(self, "%config-amqp?")

        self.maybeSpawn()
        
        if self.currentWorker is not None:
            if not self.currentWorker.is_alive():
                Bus.publish(self, "%conn-error", "warning", "Connection to AMQP broker failed")
                del self.currentWorker
                self.currentWorker = None
                
        if self.currentWorker is not None:
            self.processMsgQueue()
开发者ID:jldupont,项目名称:sensors-apps,代码行数:16,代码来源:event_logger.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Configuration类代码示例发布时间:2022-05-27
下一篇:
Python makemenus.MakeMenu类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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