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


Python SessionBus.publish方法代码示例

本文整理汇总了Python中pydbus.SessionBus.publish方法的典型用法代码示例。如果您正苦于以下问题:Python SessionBus.publish方法的具体用法?Python SessionBus.publish怎么用?Python SessionBus.publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pydbus.SessionBus的用法示例。


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

示例1: Hello

# 需要导入模块: from pydbus import SessionBus [as 别名]
# 或者: from pydbus.SessionBus import publish [as 别名]
	"""
		<node>
			<interface name='net.lew21.pydbus.ClientServerExample'>
				<method name='Hello'>
					<arg type='s' name='response' direction='out'/>
				</method>
				<method name='EchoString'>
					<arg type='s' name='a' direction='in'/>
					<arg type='s' name='response' direction='out'/>
				</method>
				<method name='Quit'/>
			</interface>
		</node>
	"""

	def Hello(self):
		"""returns the string 'Hello, World!'"""
		return "Hello, World!"

	def EchoString(self, s):
		"""returns whatever is passed to it"""
		return s

	def Quit(self):
		"""removes this object from the DBUS connection and exits"""
		loop.quit()

bus = SessionBus()
bus.publish("net.lew21.pydbus.ClientServerExample", MyDBUSService())
loop.run()
开发者ID:akruis,项目名称:pydbus,代码行数:32,代码来源:server.py

示例2: Method2

# 需要导入模块: from pydbus import SessionBus [as 别名]
# 或者: from pydbus.SessionBus import publish [as 别名]
		global done
		done += 1
		if done == 2:
			loop.quit()
		return "M1"

	def Method2(self):
		global done
		done += 1
		if done == 2:
			loop.quit()
		return "M2"

bus = SessionBus()

with bus.publish("net.lew21.pydbus.tests.expose_multiface", TestObject()):
	remote = bus.get("net.lew21.pydbus.tests.expose_multiface")

	def t1_func():
		print(remote.Method1())
		print(remote.Method2())

	t1 = Thread(None, t1_func)
	t1.daemon = True

	def handle_timeout():
		print("ERROR: Timeout.")
		sys.exit(1)

	GLib.timeout_add_seconds(2, handle_timeout)
开发者ID:LEW21,项目名称:pydbus,代码行数:32,代码来源:publish_multiface.py

示例3: hello

# 需要导入模块: from pydbus import SessionBus [as 别名]
# 或者: from pydbus.SessionBus import publish [as 别名]
        self._who = "human"
        self._state = "good"

    def hello(self):
        return "Hello %s!" % self._who

    def quit(self):
        loop.quit()

    def whatsup(self):
        return "@!#$*&@!, %s!" % self._who

    @property
    def State(self):
        return self._state

    @property
    def Who(self):
        return self._who

    @Who.setter
    def Who(self, value):
        self._who = value
        self.PropertiesChanged("org.me.test1", {"Who": self._who}, [])

    PropertiesChanged = signal()

bus = SessionBus()
bus.publish("org.me.test", MyDBUSService())
loop.run()
开发者ID:rvykydal,项目名称:snippets,代码行数:32,代码来源:server-pydbus.py

示例4: __init__

# 需要导入模块: from pydbus import SessionBus [as 别名]
# 或者: from pydbus.SessionBus import publish [as 别名]
		<property name="Foo" type="s" access="read"/>
		<property name="Bar" type="s" access="write"/>
		<method name='Quit'/>
	</interface>
</node>
	'''
	def __init__(self):
		self.Foo = "foo"
		self.Foobar = "foobar"

	def Quit(self):
		loop.quit()

bus = SessionBus()

with bus.publish("net.lew21.pydbus.tests.publish_properties", TestObject()):
	remote = bus.get("net.lew21.pydbus.tests.publish_properties")
	remote_iface = remote['net.lew21.pydbus.tests.publish_properties']

	def t1_func():
		for obj in [remote, remote_iface]:
			assert(obj.Foo == "foo")
			assert(obj.Foobar == "foobar")
			obj.Foobar = "barfoo"
			assert(obj.Foobar == "barfoo")
			obj.Foobar = "foobar"
			assert(obj.Foobar == "foobar")
			obj.Bar = "rab"

		remote.Foobar = "barfoo"
开发者ID:LEW21,项目名称:pydbus,代码行数:32,代码来源:publish_properties.py

示例5: Mpvplayer

# 需要导入模块: from pydbus import SessionBus [as 别名]
# 或者: from pydbus.SessionBus import publish [as 别名]
from playthread import Mpvplayer

loop = GLib.MainLoop()
player = Mpvplayer()
player.start()

class DBUSPlayerService(object):
    """
        <node>
            <interface name='github.zhangn1985.dbplay'>
                <method name='play'>
                    <arg type='s' name='playinfo' direction='in'/>
                </method>
				<method name='stop'/>
				<method name='exit'/>
            </interface>
        </node>
    """

    def play(self, playinfo):
        player.play(playinfo)
    def stop(self):
        player.stop()
    def exit(self):
        player.exit()
        loop.quit()

bus = SessionBus()
bus.publish("github.zhangn1985.dbplay", DBUSPlayerService())
loop.run()
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:32,代码来源:dbusplayer.py

示例6: stop

# 需要导入模块: from pydbus import SessionBus [as 别名]
# 或者: from pydbus.SessionBus import publish [as 别名]
        if not self.is_running:
          self.next_call += self.interval
          self._timer = threading.Timer(self.next_call - time.time(), self._run)
          self._timer.start()
          self.is_running = True

    def stop(self):
        self._timer.cancel()
        self.is_running = False

if __name__=="__main__":
    # Launch the server
    # Use pydbus to establish a session gdbus. Rather than system gdbus
    # TODO: Use try/except, etc. in case bus already exists. e.g. bus.get(BUS)
    bus = SessionBus()
    bus.publish(BUS, DBusService())

    # Start the repeating timer. It auto-starts, no need of rt.start()
    # RepeatedTimer(period between function calls, function())
    rt = RepeatedTimer(period, timer_event)

    # Enable R-Pi channel to perform callbacks on detection of a pulse.
    if not simulated_pulse:
        #GPIO.add_event_detect(channel, GPIO.RISING, callback=pulse_callback, 
        #                      bouncetime=1)
        GPIO.add_event_detect(channel, GPIO.FALLING, callback=pulse_callback, 
                              bouncetime=1)
    print("server running...")
    try:
        loop.run()
    except KeyboardInterrupt:
开发者ID:HamPUG,项目名称:meetings,代码行数:33,代码来源:server.py

示例7: __init__

# 需要导入模块: from pydbus import SessionBus [as 别名]
# 或者: from pydbus.SessionBus import publish [as 别名]
	'''
	def __init__(self, id):
		self.id = id

	def HelloWorld(self, a, b):
		res = self.id + ": " + a + str(b)
		global done
		done += 1
		if done == 2:
			loop.quit()
		print(res)
		return res

bus = SessionBus()

with bus.publish("net.lew21.pydbus.Test", TestObject("Main"), ("Lol", TestObject("Lol"))):
	remoteMain = bus.get("net.lew21.pydbus.Test")
	remoteLol = bus.get("net.lew21.pydbus.Test", "Lol")

	def t1_func():
		print(remoteMain.HelloWorld("t", 1))

	def t2_func():
		print(remoteLol.HelloWorld("t", 2))

	t1 = Thread(None, t1_func)
	t2 = Thread(None, t2_func)
	t1.daemon = True
	t2.daemon = True

	def handle_timeout():
开发者ID:LEW21,项目名称:pydbus,代码行数:33,代码来源:publish.py


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