Python bindings

Andrew Bird ajb at spheresystems.co.uk
Fri Nov 16 13:37:51 PST 2012


Hi Aleksander,
   I think there's something odd about the return values that indicate 
success/failure. For instance:

def start_network_ready(client, result, arg):                                   
    m = client.start_network_finish(result)                                     
    print "attempt finished"                                                    
    print m.get_result()                                                        

def device_allocate_wds_client_ready(device, result, arg):                      
    client = device.allocate_client_finish(result)                              
    print "allocated"                                                                                
                                                                                
    info = Qmi.MessageWdsStartNetworkInput()                                    
    info.set_apn("internet2")                                                   
    info.set_username("web")                                                    
    info.set_password("web")                                                    
    client.start_network(info, 15, None, start_network_ready, None)             

I try to connect to the network and I wish to print the result. If it 
connected, then True is returned. If it failed I get an exception e.g.

Traceback (most recent call last):
  File "qmi.py", line 98, in start_network_ready
    print m.get_result()
  File "/usr/lib/python2.7/site-packages/gi/types.py", line 43, in function
    return info.invoke(*args, **kwargs)
gi._glib.GError: QMI protocol error (14): 'CallFailed'

Is that what you expect to happen? Usually in Python we'd either use True / 
False else use try / except, but rarely mix the two. At this point I can't see 
how False could ever be returned to the caller.

Andrew



More information about the libqmi-devel mailing list