web services - Error Handling in Python with SUDS -
i have been trying control camera through wsdl file using suds. have got code working want place error handling script. have tried different exceptions unable script working. when enter invalid coordinate error. code using below followed error recieving.
#!/home/build/python-2.6.4/python import suds suds.client import client #################################################################### # # python suds script controls movement of camera # #################################################################### # # absolute move function # #################################################################### def absolutemove(): # connects wsdl file , stores location in variable 'client' client = client('http://file.wsdl') # create 'token' object pass argument using 'factory' namespace token = client.factory.create('ns4:referencetoken') print token # create 'dest' object pass argument , values passed object dest = client.factory.create('ns4:ptzvector') dest.pantilt._x=400 dest.pantilt._y=0 dest.zoom._x=1 print dest # create 'speed' object pass argument , values passed object speed = client.factory.create('ns4:ptzspeed') speed.pantilt._x=0 speed.pantilt._y=0 speed.zoom._x=1 print speed # 'absolutemove' method invoked passing in new values entered in above objects try: result = client.service.absolutemove(token, dest, speed) except runtimeerror detail: print 'handling run-time error:', detail print "absolutemove result ", result result = absolutemove()
the error below:
no handlers found logger "suds.client" traceback (most recent call last): file "ptztest.py", line 48, in <module> if __name__ == '__main__': result = absolutemove() file "ptztest.py", line 42, in absolutemove result = client.service.absolutemove(token, dest, speed) file "build/bdist.linux-i686/egg/suds/client.py", line 537, in __call__ file "build/bdist.linux-i686/egg/suds/client.py", line 597, in invoke file "build/bdist.linux-i686/egg/suds/client.py", line 632, in send file "build/bdist.linux-i686/egg/suds/client.py", line 683, in failed file "build/bdist.linux-i686/egg/suds/bindings/binding.py", line 235, in get_fault suds.webfault: server raised fault: 'error setting requested pan'
i not sure exception should using here. know how catch error. x coordinate value 400 in degree's why error happens.
thanks
okay have found solution. in suds if enter:
faults=false
into client definition, catches faults , gives reason why fault happened. line should read:
client = client('http://file.wsdl', faults=false)
the post have marked correct answer able catch problem has happened.
thanks all
if want catch exception should put
try: result = client.service.absolutemove(token, dest, speed) except suds.webfault detail: ...
Comments
Post a Comment