On 7/18/09, Vikas Saurabh <[email protected]> wrote:
>> Yes, it's very simple to be done by python app :) Everything what you
>> need is available by dbus methods or signals.
>
> I gave a shot at python to have a script which would enable GPRS. It
> can be found at http://pastebin.com/m2668251e. If everything gets up
> and running, this script works as expected.
>
> But, if I set it up as /etc/init.d/rc5.d/S99init-gprs.py, the script fails
> at:
> gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd",
> "/org/freesmartphone/GSM/Device")
> saying:
> Traceback (most recent call last):
>   File "/usr/bin/init-gprs.py", line 12, in <module>
>     gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd",
> "/org/freesmartphone/GSM/Device")
>   File "/usr/lib/python2.6/site-packages/dbus/bus.py", line 244, in
> get_object
>     follow_name_owner_changes=follow_name_owner_changes)
>   File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 241, in
> __init__
>     self._named_service = conn.activate_name_owner(bus_name)
>   File "/usr/lib/python2.6/site-packages/dbus/bus.py", line 183, in
> activate_name_owner
>     self.start_service_by_name(bus_name)
>   File "/usr/lib/python2.6/site-packages/dbus/bus.py", line 281, in
> start_service_by_name
>     'su', (bus_name, flags)))
>   File "/usr/lib/python2.6/site-packages/dbus/connection.py", line
> 622, in call_blocking
>     message, timeout)
> dbus.exceptions.DBusException:
> org.freedesktop.DBus.Error.ServiceUnknown: The name
> org.freesmartphone.ogsmd was not provided by any .service files
>
> I know this is a simple timing issue...but there got to a definitive
> way to fire the script just at the right time. I hope busy polling
> until one gets the bus is not a good idea!
>
> --Vikas
>
> PS: If someone looks at the code, please tell me why I can't register
> for the ReadyStatus signal. It said:
> Traceback (most recent call last):
>   File "/usr/bin/init-gprs.py", line 27, in <module>
>     simIFace.connect_to_signal("ReadyStatus", on_sim_ready)
> NameError: name 'on_sim_ready' is not defined
>

Instead of making iface at start, make listener like this:

bus.add_signal_receiver(on_sim_ready, signal_name='ReadyStatus',
dbus_interface='org.freesmartphone.GSM.SIM',
bus_name='org.freesmartphone.ogsmd')

Of course you have to define function on_sim_ready. In that function
make iface and then connect to GPRS :)
_______________________________________________
Shr-User mailing list
[email protected]
http://lists.shr-project.org/mailman/listinfo/shr-user

Reply via email to