Om2008.8: execute script on incoming call

shawnzier at shawnzier at
Thu Sep 4 04:05:57 CEST 2008

On Tue, Sep 02, 2008 at 12:04:03AM +0200, Michael 'Mickey' Lauer wrote:
> Am Montag, 1. September 2008 23:18:02 schrieb shawnzier at
> > Should the else statement be at the same indent as the if?
> No, the else refers to the try/except clause.
> >       DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method
> > "Release" with signature "i" on interface "org.freesmartphone.GSM.Call"
> > doesn't exist
> Oops, it's probably called ReleaseCall. If in doubt about signatures, use 
> mdbus to introspect.

Finally figured it out. 

obj = bus.get_object( "org.freesmartphone.ogsmd", "/org/freesmartphone/Device/GSM" ) 

should be

obj = bus.get_object( "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device" )

I also had to import subprocess and dbus.mainloop.glib

Here is the corrected python code in full:

import dbus                                                                                                                                                                                                                                    
import dbus.mainloop                                                                                                                                                                                                                           
import dbus.mainloop.glib                                                                                                                                                                                                                      
import gobject                                                                                                                                                                                                                                 
import subprocess                                                                                                                                                                                                                              
actions = { \                                                                                                                                                                                                                                  
  "+491003":"/usr/bin/foo3" }                                                                                                                                                                                                                  
def onCallStatus( index, status, properties ):                                                                                                                                                                                                 
    if status == "incoming":                                                                                                                                                                                                                   
             action = actions[properties["peer"]]                                                                                                                                                                                              
        except KeyError:                                                                                                                                                                                                                       
              obj = bus.get_object( "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device" )                                                                                                                                             
              callInterface = dbus.Interface( obj, "org.freesmartphone.GSM.Call" )                                                                                                                                                             
              callInterface.Release( index )                                                                                                                                                                                                   
              subprocess.Popen( action, shell=True )                                                                                                                                                                                           
dbus.mainloop.glib.DBusGMainLoop( set_as_default=True )                                                                                                                                                                                        
mainloop = gobject.MainLoop()                                                                                                                                                                                                                  
bus = dbus.SystemBus()                                                                                                                                                                                                                         
bus.add_signal_receiver( onCallStatus, "CallStatus", "org.freesmartphone.GSM.Call", "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device" )                                                                                                                                   

Thanks for your help, Mickey. I know you've been real busy with the framework getting ready for Milestone 3, so I appreciate any time that you were able to donate in helping me out.

More information about the community mailing list