当前位置: 首页>>代码示例>>Python>>正文


Python mbus.Bus类代码示例

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


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


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