cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
966
Views
10
Helpful
2
Replies

Python/Zeep - failing to trap failure on getLine for non-existent DN

I have been staring at the AXL schema, but I am not making heads or tails of it. I am trying to figure out what error I should trap when I do a getLine for a DN that doesn't exist. This is the code fragment I have at the moment.

try:
    adn_search2 = source_axl.getLine(pattern=next_agent_dn,routePartitionName=csf_partition)
except Fault:
    print('adn_search2 failed')

 This is the error I am getting.

Traceback (most recent call last):
  File "/usr/home/ebd/CLAUTO/CUCM/./x2e_build.py", line 265, in main
    adn_search2 = source_axl.getLine(pattern=next_agent_dn,routePartitionName=csf_partition)
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 46, in __call__
    return self._proxy._binding.send(
  File "/usr/local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 135, in send
    return self.process_reply(client, operation_obj, response)
  File "/usr/local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 229, in process_reply
    return self.process_error(doc, operation)
  File "/usr/local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 329, in process_error
    raise Fault(
zeep.exceptions.Fault: Item not valid: The specified Line was not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/home/ebd/CLAUTO/CUCM/./x2e_build.py", line 592, in <module>
    main()
  File "/usr/home/ebd/CLAUTO/CUCM/./x2e_build.py", line 266, in main
    except Fault:
NameError: name 'Fault' is not defined

 I freely admit that perhaps I am reading the AXL schema incorrectly, but I can't figure out what exception I should try to catch. I even tried looking at ciscoaxl/schema/10.5/AXLSoap.xsd but the answer is still evading me.

1 Accepted Solution

Accepted Solutions

BjoernMartin
Spotlight
Spotlight

Hello Elliot!
That's no problem, that's what the community is there for!

You get a zeep exception!
zeep.exceptions.Fault: Item not valid: The specified Line was not found

1.    To catch this exception you need to import the zeep exception module.

from zeep.exceptions import Fault

2.    Change your except step to:
except Fault as err:
    print(err)

Then you should get this output:
Item not valid: The specified line was not found

View solution in original post

2 Replies 2

BjoernMartin
Spotlight
Spotlight

Hello Elliot!
That's no problem, that's what the community is there for!

You get a zeep exception!
zeep.exceptions.Fault: Item not valid: The specified Line was not found

1.    To catch this exception you need to import the zeep exception module.

from zeep.exceptions import Fault

2.    Change your except step to:
except Fault as err:
    print(err)

Then you should get this output:
Item not valid: The specified line was not found

Excellent, thanks! I wish I had a better grasp of where to look for this sort of thing on my own. I swear I tried google and searching the community. It doesn't help that I'll have some tasks that I need to do where Python is the perfect tool, and then I might not touch it for months. Thanks again.