Reply
Thread Tools
JapieB's Avatar
Posts: 59 | Thanked: 42 times | Joined on Nov 2009 @ Wageningen (NL)
#1
I would like to use DBus from a Python QT application running on an N900

using 'dbus-monitor --monitor' I found the following call to the nokia maps service:
Code:
method call sender=:1.847 -> dest=com.nokia.Navigation.NokiaMapsProvider serial=11 path=/Provider; interface=com.nokia.Navigation.MapProvider; member=LocationToAddresses
   double 51.9785
   double 5.66882
   boolean false
method return sender=:1.848 -> dest=:1.847 reply_serial=11
   object path "/nokiamaps/response/3"
signal sender=:1.848 -> dest=(null destination) serial=13 path=/nokiamaps/response/3; interface=com.nokia.Navigation.MapProvider; member=LocationToAddressReply
   array [
      array [
         string "9"
         string ""
         string "Roghorst"
         string ""
         string "Wageningen"
         string ""
         string ""
         string "6708"
         string ""
         string "NLD"
         string ""
      ]
   ]
I cannot find how I can do the same call from within a Python QT application. Can anyone help me?

What I've tried so far is:

Code:
import sys
import dbus
from dbus.mainloop.qt import DBusQtMainLoop
from PyQt4 import QtCore
from PyQt4 import QtGui


app = QtGui.QApplication(sys.argv)

dbus_loop = DBusQtMainLoop()

bus = dbus.SessionBus(mainloop=dbus_loop)

provider = bus.get_object('com.nokia.Navigation.NokiaMapsProvider', '/Provider')

proxy = dbus.Interface(provider, 'com.nokia.Navigation.MapProvider') 
print proxy

print proxy.LocationToAddresses(51.9784,5.669,False)
which results in

Code:
<Interface <ProxyObject wrapping <dbus._dbus.SessionBus (session) at 0x226d50> :1.848 /Provider at 0x216ff0> implementing 'com.nokia.Navigation.MapProvider' at 0x22d0f0>
ERROR:dbus.proxies:Introspect error on :1.848:/Provider: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Message did not receive a reply (timeout by message bus)
Traceback (most recent call last):
  File "discover.py", line 23, in <module>
    print proxy.LocationToAddresses(51.9784,5.669,False)
  File "/usr/lib/pymodules/python2.5/dbus/proxies.py", line 68, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/pymodules/python2.5/dbus/proxies.py", line 140, in __call__
    **keywords)
  File "/usr/lib/pymodules/python2.5/dbus/connection.py", line 622, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name :1.848 was not provided by any .service files
dbus-monitor logging is:
Code:
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=144 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.852"
   string ""
   string ":1.852"
method call sender=:1.852 -> dest=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
method call sender=:1.852 -> dest=org.freedesktop.DBus serial=3 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=StartServiceByName
   string "com.nokia.Navigation.NokiaMapsProvider"
   uint32 0
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=145 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.853"
   string ""
   string ":1.853"
method call sender=:1.853 -> dest=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
method call sender=:1.853 -> dest=org.freedesktop.DBus serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus'"
method call sender=:1.853 -> dest=org.freedesktop.DBus serial=3 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.DBus'"
method call sender=:1.853 -> dest=org.freedesktop.DBus serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.DBus"
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string "com.nokia.Navigation.NokiaMapsProvider"
   string ""
   string ":1.853"
method call sender=:1.853 -> dest=org.freedesktop.DBus serial=5 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RequestName
   string "com.nokia.Navigation.NokiaMapsProvider"
   uint32 0
method call sender=:1.852 -> dest=org.freedesktop.DBus serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "com.nokia.Navigation.NokiaMapsProvider"
method call sender=:1.852 -> dest=:1.853 serial=5 path=/Provider; interface=org.freedesktop.DBus.Introspectable; member=Introspect
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=7 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string "com.nokia.Navigation.NokiaMapsProvider"
   string ":1.853"
   string ""
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=146 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.853"
   string ":1.853"
   string ""
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=147 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.851"
   string ":1.851"
   string ""
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=148 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.852"
   string ":1.852"
   string ""
 
hopbeat's Avatar
Posts: 516 | Thanked: 643 times | Joined on Oct 2009 @ Denmark/Poland
#2
You may want to take a look at this:
http://slexy.org/view/s25h3to4Rr

Probably bus.get_object may be interesting for you.
__________________
Hi! I'm a Maemo Greeter!
Witaj na talk.maemo.org!

Useful links for newcomers:
Użyteczne linki:
Nowi użyktownicy mówią cześć | New members say hello , Tu zaczynają nowi użytkownicy | New users start here, Podforum społeczności | Community subforum, Wiki dla początkujących | Beginners' wiki page, Maemo5 101, Często zadawane pytania | Frequently Asked Questions (FAQ), Google

Jeżeli mogę w czymś pomóc, pytaj!
If I can help with anything else, just ask!

Bored? Follow me
 
JapieB's Avatar
Posts: 59 | Thanked: 42 times | Joined on Nov 2009 @ Wageningen (NL)
#3
Originally Posted by hopbeat View Post
You may want to take a look at this:
http://slexy.org/view/s25h3to4Rr

Probably bus.get_object may be interesting for you.
Actually, I started with that code

In my code I use bus.get_object, and it succeeds.

Getting a proxy using dbus.Interface also seems to work , it prints:

Code:
<Interface <ProxyObject wrapping <dbus._dbus.SessionBus (session) at 0x226d50> :1.848 /Provider at 0x216ff0> implementing 'com.nokia.Navigation.MapProvider' at 0x22d0f0>
but the call to the LocationToAddresses method fails..
 
Posts: 14 | Thanked: 18 times | Joined on Dec 2009
#4
Originally Posted by JapieB View Post
Actually, I started with that code

In my code I use bus.get_object, and it succeeds.

Getting a proxy using dbus.Interface also seems to work , it prints:

Code:
<Interface <ProxyObject wrapping <dbus._dbus.SessionBus (session) at 0x226d50> :1.848 /Provider at 0x216ff0> implementing 'com.nokia.Navigation.MapProvider' at 0x22d0f0>
but the call to the LocationToAddresses method fails..
Have you tried using the SystemBus instead of the SessionBus?
 
Reply


 
Forum Jump


All times are GMT. The time now is 03:31.