本文整理汇总了Python中system.mbus.Bus.publish方法的典型用法代码示例。如果您正苦于以下问题:Python Bus.publish方法的具体用法?Python Bus.publish怎么用?Python Bus.publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类system.mbus.Bus
的用法示例。
在下文中一共展示了Bus.publish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
def __init__(self):
self.config={}
self.conn=None
self.chan=None
self.cpoll=0
self.cLastConnAttempt=0
Bus.publish(self,"%llconfig", self.LCONFIG)
示例2: activate
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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")
示例3: _onError
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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)
示例4: _hDin
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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)
示例5: validateConfig
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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)
示例6: Devices
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
def Devices(self, devices):
""" Signal Handler
Signal normally issued by Phidgets-Manager
"""
for device in devices:
ddetails=deviceHelper(device)
Bus.publish(self, "%device", ddetails)
示例7: processChange
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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)
示例8: _doUpdateInfo
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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)
示例9: processMsg
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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
示例10: on_load_complete
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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)
示例11: _setup
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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")
示例12: __init__
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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")
示例13: _hPoll
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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
示例14: setup
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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
示例15: on_entry_added
# 需要导入模块: from system.mbus import Bus [as 别名]
# 或者: from system.mbus.Bus import publish [as 别名]
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)