Hello,<br><br>I&#39;m playing around with a little test dbus/PyQt4 python script, and have run into an issue... I am trying to accomplish two things in this script: 1) receive signals from the system bus, and 2) export a callable object on the session bus. When I run my little test script, only the last of these 2 things that I setup work.
<br><br>Scenario #1: Setup session bus first, and system bus second. In this scenario, the system bus handler get signals, the session bus exports the object, but a viewer like qdbusviewer hangs when it tries to open the path to the object. It seems that the call to 
dbus.SystemBus() &quot;kills&quot; the session bus setup (and if I remove the add_signal_receiver() call, and leave just the system_bus = dbus.SystemBus() call, it still fails).<br><br>session_bus = dbus.SessionBus()<br>name = 
dbus.service.BusName(&quot;com.hplip.StatusService&quot;, session_bus)<br>test = Test(name, &quot;/com/hplip/StatusService/Test&quot;)<br><br>system_bus = dbus.SystemBus()<br><br># processes of non-privledged users can rec. signals from the system bus
<br>system_bus.add_signal_receiver(handle_signal, sender_keyword=&#39;sender&#39;, <br>&nbsp;&nbsp;&nbsp; destination_keyword=&#39;dest&#39;, interface_keyword=&#39;interface&#39;, <br>&nbsp;&nbsp;&nbsp; member_keyword=&#39;member&#39;, path_keyword=&#39;path&#39;)
<br>&nbsp;&nbsp;&nbsp; <br><br>Scenario #2: Setup system bus first, and the session bus second. In this scenario, the object exported on the session bus is callable (I can successfully call the Echo method in qdbusviewer), but the signals from the system bus no longer function. It seems that the call to 
dbus.SessionBus() &quot;kills&quot; the system bus setup (and if I remove the next 2 lines and leave just the session_bus = dbus.SessionBus() line, it still fails).<br><br>system_bus = dbus.SystemBus()<br>

<br>

# processes of non-privledged users can rec. signals from the system bus<br>

system_bus.add_signal_receiver(handle_signal, sender_keyword=&#39;sender&#39;, <br>

&nbsp;&nbsp;&nbsp; destination_keyword=&#39;dest&#39;, interface_keyword=&#39;interface&#39;, <br>

&nbsp;&nbsp;&nbsp; member_keyword=&#39;member&#39;, path_keyword=&#39;path&#39;)<br>
<br>session_bus = dbus.SessionBus()<br>
name = dbus.service.BusName(&quot;com.hplip.StatusService&quot;, session_bus)<br>
test = Test(name, &quot;/com/hplip/StatusService/Test&quot;)<br><br>The complete script is here (in scenario #1 order):<br><br>#! /usr/bin/env python<br><br>import dbus<br>import dbus.service<br>import dbus.mainloop.qt<br>
from PyQt4 import QtGui, QtCore<br>from PyQt4.QtCore import Qt<br>import sys<br><br><br>def handle_signal(*args, **kwds):<br>&nbsp;&nbsp;&nbsp; print &quot;Signal!&quot;<br>&nbsp;&nbsp;&nbsp; print kwds<br>&nbsp;&nbsp;&nbsp; print<br>&nbsp;&nbsp;&nbsp; tray_icon.showMessage(&quot;HPLIP Status&quot;, 
QtCore.QString(&quot;Received message from %1&quot;).arg(kwds[&#39;sender&#39;]))<br><br>&nbsp;&nbsp;&nbsp; <br>def quit():<br>&nbsp;&nbsp;&nbsp; app.quit()<br>&nbsp;&nbsp;&nbsp; <br>class Test(dbus.service.Object):<br>&nbsp;&nbsp;&nbsp; def __init__(self, name, object_path):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
dbus.service.Object.__init__(self, name, object_path)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; @dbus.service.method(&#39;com.hplip.StatusService&#39;)<br>&nbsp;&nbsp;&nbsp; def EchoString(self, s):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return s<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br><br>app = QtGui.QApplication
(sys.argv)<br>dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)<br><br><br>session_bus = dbus.SessionBus()<br>name = dbus.service.BusName(&quot;com.hplip.StatusService&quot;, session_bus)<br>test = Test(name, &quot;/com/hplip/StatusService/Test&quot;)
<br><br><br>system_bus = dbus.SystemBus()<br><br># processes of non-privledged users can call methods on the system bus<br>proxy = system_bus.get_object(&#39;org.freedesktop.DBus&#39;, &#39;/org/freedesktop/DBus&#39;)<br>
print proxy.GetId()<br><br><br># processes of non-privledged users can rec. signals from the system bus<br>system_bus.add_signal_receiver(handle_signal, sender_keyword=&#39;sender&#39;, <br>&nbsp;&nbsp;&nbsp; destination_keyword=&#39;dest&#39;, interface_keyword=&#39;interface&#39;, 
<br>&nbsp;&nbsp;&nbsp; member_keyword=&#39;member&#39;, path_keyword=&#39;path&#39;)<br>&nbsp;&nbsp;&nbsp; <br><br>tray_icon = QtGui.QSystemTrayIcon()<br>icon = QtGui.QIcon(&quot;HPmenu.png&quot;) <br>tray_icon.setIcon(icon)<br>menu = QtGui.QMenu()<br>
menu.addAction(&quot;&amp;Quit&quot;, quit, Qt.CTRL + Qt.Key_Q)<br>tray_icon.setContextMenu(menu)<br><br>tray_icon.show()<br>app.exec_()<br><br><br><br>I don&#39;t know if there is something wrong in my code, if there is a bug in dbus or the qt dbus mainloop, or I am making some other sort of rookie mistake. It does say in the python-dbus docs that: &quot;Of course, you can connect to both [system and session buses] in the same application.&quot;, so I am pretty sure it is possible.
<br><br>Thanks for the help,<br><br>Don<br><br><br><br>
<br>