I answered my own question:
Use python's introspection function getattr() to get an attribute by name. e.g.:
getattr(ex.fault.detail, 'com.atlassian...')
On Mon, Jun 14, 2010 at 5:28 PM, Edwin Vane <revane(a)gmail.com> wrote:
That's just what I needed. Thanks!
So when I print out fault.detail I find this curious attribute:
(detail){
com.atlassian.jira.rpc.exception.RemotePermissionException = ""
hostname = ""
}
Maybe this is a language question but how do we access an attribute
whose name contains periods?
On Mon, Jun 14, 2010 at 4:28 PM, Joshua J. Kugler <joshua(a)eeinternet.com> wrote:
> On Monday 14 June 2010, Edwin Vane elucidated thus:
>> I apologize if these questions have been asked before. I wasn't able
>> to find a mailing list archive search.
>>
>> Is there an easy way to determine the SOAP exception object that was
>> raised from a suds.WebFault? It looks to me that using __str__ and
>> trying to parse the string is the only way to get the object. Is
>> there a better way?
>
> suds.WebFault exceptions are objects, so you can do some querying like:
>
> except WebFault, ex:
> if ('LoginFault' in ex.fault.detail
> and ex.fault.detail.LoginFault.exceptionCode
> == 'INVALID_LOGIN'):
> log.critical('Invalid credentials supplied for Salesforce')
>
> Another example:
>
> except WebFault, ex:
> if ('ApiFault' in ex.fault.detail
> and ex.fault.detail.ApiFault.message.startswith('Login
> failed')):
> log.critical('Invalid credentials supplied for Yahoo')
>
> What, exactly, you query for can depend on the service and the call
> you're performing.
>
>> When exceptions are thrown I get this error printed to stdout/stderr:
>>
>> No handlers could be found for logger "suds.client"
>>
>> Is there a way to turn off this message without having to use the
>> logging module? I would think if I didn't request logging that the
>> module shouldn't complain that I'm not using it right?
>
> If you want to ignore messages, you can just do something like:
>
> logging.getLogger('suds.client').setLevel(logging.CRITICAL)
>
> or make another similar call which will mute most or all messages.
>
> j
>
> --
> Joshua Kugler
> Part-Time System Admin/Programmer
>
http://www.eeinternet.com
> PGP Key:
http://pgp.mit.edu/ ID 0x73B13B6A
>
--
Edwin V