Re: [pymaemo] hildon-desktop: getting D-Bus?

2010-04-14 Thread Kimmo Hämäläinen
On Tue, 2010-04-13 at 23:19 +0200, ext Thomas Waelti wrote:
 (Crossposting to maemo-devel, hoping for a Hildon-Desktop or D-Bus expert to 
 pick this up. Original thread is at 
 https://garage.maemo.org/pipermail/pymaemo-developers/2010-April/001444.html )
 
 Thanks for a very interesting input. Unfortunately, it didn't work for my 
 needs, as I must get my hands on the SYSTEM bus, not the Session one.
 I tried your example, changing it to
 
 self.bus = 
 dbus.bus.BusConnection(unix:abstract=/var/run/dbus/system_bus_socket)
 
 However, I get this error:
 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoServer: Failed to 
 connect to socket /var/run/dbus/system_bus_socket: Connection refused
 
 
 Isn't this the correct address of the system dbus?
 Or do I have a permission (or other) problem when trying to get on the 
 system-dbus from hildon-desktop?

You mean hildon-home (hildon-desktop does not have plugins). I found
some code from
http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#connecting-to-the-bus

=
import dbus
from dbus.mainloop.glib import DBusGMainLoop

dbus_loop = DBusGMainLoop()

bus = dbus.SessionBus(mainloop=dbus_loop)
=

Just replace SessionBus with SystemBus, yes?

-Kimmo

 
 
 Thanks all
 -Tom
 
 
  As a follow-up to the discussion about d-bus from a hildon widget a
  few days ago that I found out while having the same problem, I've
  finally managed to get something that seems to be working for me:
 
  # Create a session bus.
  import dbus
  from dbus.mainloop.glib import DBusGMainLoop
  dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  from os import environ
  bus = dbus.bus.BusConnection(environ[DBUS_SESSION_BUS_ADDRESS])
 
  And then bus can be used as usual. I haven't done a whole lot of
  testing, as I just found this out, but it appears to be working both
  in command line mode and as a home widget.
   Yves.
  ___
  pymaemo-developers mailing list
  pymaemo-develop...@garage.maemo.org
  https://garage.maemo.org/mailman/listinfo/pymaemo-developers
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: [pymaemo] hildon-desktop: getting D-Bus?

2010-04-14 Thread Thomas Wälti
Thanks to all of you! Based on your feedbacks, I was able to find a solution :-)
So here is on how to get your hands on a dbus system object in a
python-based hildon-home widget in a way that you can attach
callbacks.

from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
dbus.mainloop.glib.threads_init()

class YourHomePlugin(hildondesktop.HomePluginItem):

  def __init__(self):
self.bus = 
dbus.bus.BusConnection(unix:path=/var/run/dbus/system_bus_socket)


This means that auto-recording now works in my Recaller widget...
I'll post a new version to Extras-Devel during the next days.

Thanks again to everybody!
-Tom


2010/4/14 Kimmo Hämäläinen kimmo.hamalai...@nokia.com:
 On Tue, 2010-04-13 at 23:19 +0200, ext Thomas Waelti wrote:
 (Crossposting to maemo-devel, hoping for a Hildon-Desktop or D-Bus expert to 
 pick this up. Original thread is at 
 https://garage.maemo.org/pipermail/pymaemo-developers/2010-April/001444.html 
 )

 Thanks for a very interesting input. Unfortunately, it didn't work for my 
 needs, as I must get my hands on the SYSTEM bus, not the Session one.
 I tried your example, changing it to

     self.bus = 
 dbus.bus.BusConnection(unix:abstract=/var/run/dbus/system_bus_socket)

 However, I get this error:
 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoServer: Failed 
 to connect to socket /var/run/dbus/system_bus_socket: Connection refused


 Isn't this the correct address of the system dbus?
 Or do I have a permission (or other) problem when trying to get on the 
 system-dbus from hildon-desktop?

 You mean hildon-home (hildon-desktop does not have plugins). I found
 some code from
 http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#connecting-to-the-bus

 =
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop

 dbus_loop = DBusGMainLoop()

 bus = dbus.SessionBus(mainloop=dbus_loop)
 =

 Just replace SessionBus with SystemBus, yes?

 -Kimmo



 Thanks all
 -Tom


  As a follow-up to the discussion about d-bus from a hildon widget a
  few days ago that I found out while having the same problem, I've
  finally managed to get something that seems to be working for me:
 
  # Create a session bus.
  import dbus
  from dbus.mainloop.glib import DBusGMainLoop
  dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  from os import environ
  bus = dbus.bus.BusConnection(environ[DBUS_SESSION_BUS_ADDRESS])
 
  And then bus can be used as usual. I haven't done a whole lot of
  testing, as I just found this out, but it appears to be working both
  in command line mode and as a home widget.
   Yves.
  ___
  pymaemo-developers mailing list
  pymaemo-develop...@garage.maemo.org
  https://garage.maemo.org/mailman/listinfo/pymaemo-developers
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers


___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: [pymaemo] hildon-desktop: getting D-Bus?

2010-04-14 Thread Thomas Waelti
As a final status update:
a vastly improved version of Recaller has been built and uploaded - it will 
show up in extras-devel during the next hours :-)

Thanks for all the inputs and have fun
-Tom


 Thanks to all of you! Based on your feedbacks, I was able to find a solution 
 :-)
 So here is on how to get your hands on a dbus system object in a
 python-based hildon-home widget in a way that you can attach
 callbacks.

 from dbus.mainloop.glib import DBusGMainLoop
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 dbus.mainloop.glib.threads_init()

 class YourHomePlugin(hildondesktop.HomePluginItem):

  def __init__(self):
self.bus = 
 dbus.bus.BusConnection(unix:path=/var/run/dbus/system_bus_socket)


 This means that auto-recording now works in my Recaller widget...
 I'll post a new version to Extras-Devel during the next days.

 Thanks again to everybody!
 -Tom


 2010/4/14 Kimmo Hämäläinen kimmo.hamalai...@nokia.com:
 On Tue, 2010-04-13 at 23:19 +0200, ext Thomas Waelti wrote:
 (Crossposting to maemo-devel, hoping for a Hildon-Desktop or D-Bus expert 
 to pick this up. Original thread is at 
 https://garage.maemo.org/pipermail/pymaemo-developers/2010-April/001444.html
  )

 Thanks for a very interesting input. Unfortunately, it didn't work for my 
 needs, as I must get my hands on the SYSTEM bus, not the Session one.
 I tried your example, changing it to

 self.bus = 
 dbus.bus.BusConnection(unix:abstract=/var/run/dbus/system_bus_socket)

 However, I get this error:
 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoServer: Failed 
 to connect to socket /var/run/dbus/system_bus_socket: Connection refused


 Isn't this the correct address of the system dbus?
 Or do I have a permission (or other) problem when trying to get on the 
 system-dbus from hildon-desktop?

 You mean hildon-home (hildon-desktop does not have plugins). I found
 some code from
 http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#connecting-to-the-bus

 =
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop

 dbus_loop = DBusGMainLoop()

 bus = dbus.SessionBus(mainloop=dbus_loop)
 =

 Just replace SessionBus with SystemBus, yes?

 -Kimmo


 Thanks all
 -Tom


  As a follow-up to the discussion about d-bus from a hildon widget a
  few days ago that I found out while having the same problem, I've
  finally managed to get something that seems to be working for me:
 
  # Create a session bus.
  import dbus
  from dbus.mainloop.glib import DBusGMainLoop
  dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  from os import environ
  bus = dbus.bus.BusConnection(environ[DBUS_SESSION_BUS_ADDRESS])
 
  And then bus can be used as usual. I haven't done a whole lot of
  testing, as I just found this out, but it appears to be working both
  in command line mode and as a home widget.
   Yves.
  ___
  pymaemo-developers mailing list
  pymaemo-develop...@garage.maemo.org
  https://garage.maemo.org/mailman/listinfo/pymaemo-developers
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers