A dbus.mainloop.NativeMainLoop instance is required [Was: Re: dbus-python: support for Windows and OS X]
Lukas Hetzenecker
lukas.hetzenecker at gmail.com
Fri Feb 4 02:47:37 PST 2011
When I commented out these checks I finally got it working (I register an
object on the session bus successfully).
I will try to investigate this further.
Lukas
Am Mittwoch, 2. Februar 2011, 19:16:41 schrieb Lukas Hetzenecker:
> I was able to compile dbus and dbus-python on Windows without any problems,
> but now I get strange error messages when I try to create a D-Bus service:
>
> Windows XP; dbus 1.4.1-2
>
> C:\Python27\Lib\site-packages\dbus>C:\Python27\python.exe
> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)]
> on win32
>
> >>> import sys
> >>> import dbus
> >>> import dbus.service
> >>> import dbus.mainloop.qt
> >>> from PyQt4 import QtCore
> >>>
> >>> app = QtCore.QCoreApplication(sys.argv)
> >>> mainloop = dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)
> >>> sb = dbus.SessionBus()
> >>> name = dbus.service.BusName("net.sourceforge.series60remote", sb)
> >>>
> >>> obj = dbus.service.Object.__init__(dbus.service.Object(), sb,
>
> '/Series60Remote')
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "C:\Python27\lib\site-packages\dbus\service.py", line 480, in
> __init__ self.add_to_connection(conn, object_path)
> File "C:\Python27\lib\site-packages\dbus\service.py", line 571, in
> add_to_connection
> self._fallback)
> RuntimeError: To make asynchronous calls, receive signals or export objects,
> D-Bus connections must be attached to a main loop by passing mainloop=...
> to the constructor or calling dbus.set_default_main_loop(...)
>
> But when I try to call dbus.set_default_main_loop I get this error:
> >>> dbus.set_default_main_loop(mainloop)
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: A dbus.mainloop.NativeMainLoop instance is required
>
>
> which is really odd, because mainloop is an instance of
>
> dbus.mainloop.NativeMainLoop:
> >>> isinstance(mainloop, NativeMainLoop)
>
> True
>
> >>> dbus.version
>
> (0, 83, 2)
>
>
> The same code works on a Linux system without any problems:
>
> Fedora 14; dbus 1.4.0-2
>
> Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)
> [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
>
> >>> import sys
> >>> import dbus
> >>> import dbus.service
> >>> import dbus.mainloop.qt
> >>> from PyQt4 import QtCore
> >>> app = QtCore.QCoreApplication(sys.argv)
> >>> mainloop = dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)
> >>> sb = dbus.SessionBus()
> >>> name = dbus.service.BusName("net.sourceforge.series60remote", sb)
> >>> obj = dbus.service.Object.__init__(dbus.service.Object(), sb,
>
> '/Series60Remote')
>
> >>> dbus.version
>
> (0, 83, 0)
>
>
> Does anybody know what causes this odd behaviour?
>
> Thanks,
> Lukas
>
> Am Donnerstag, 27. Januar 2011, 23:13:26 schrieb Ralf Habacker:
> > Am 26.01.2011 10:56, schrieb Lukas Hetzenecker:
> > > Hello,
> > >
> > > I'm the developer of the cross-platform application Series60-Remote,
> > > which is written in Python. I would like to use an inter-process
> > > communication framework and D-Bus seems to be a great choice.
> > > Are there already python bindings which support also Windows (and OS
> > > X)?
> > >
> > > I used the binary package for the D-Bus server of the KDE-Windows
> > > project and this seems to work correctly. But I can't get the python
> > > bindings to work. I followed the instructions of the deluge project
> > > [1], but they seem to be outdated (they switched to an other IPC
> > > framework in January 2010).
> > >
> > > Is there anybody who has used dbus-python already on Windows or has
> > > an
> > > installation howto?
> >
> > In the KDE on windows buildsystem there is a build-from-source-package
> > for dbus-python (it works at least for msvc release builds), see
> > http://websvn.kde.org/trunk/kdesupport/emerge/portage/testing/dbus-pytho
> > n/
> >
> > Regards
> >
> > Ralf
> >
> > _______________________________________________
> > dbus mailing list
> > dbus at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/dbus
More information about the dbus
mailing list