kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
304 stars 59 forks source link

1.0 dev #13

Closed Themanwithoutaplan closed 4 years ago

Themanwithoutaplan commented 4 years ago

Simplified the error code parsing.

kbr commented 4 years ago

The loop has been in the original code, to provide a more expressive error-message. Given an xml-report like this:

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <s:Fault>
            <faultcode>
                s:Client
            </faultcode>
            <faultstring>
                UPnPError
            </faultstring>
            <detail>
                <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
                    <errorCode>
                        401
                    </errorCode>
                    <errorDescription>
                        Invalid Action
                    </errorDescription>
                </UPnPError>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

should produce an error-message like that:

'UPnPError: errorCode: 401, errorDescription: Invalid Action'

At least errorCode and errorDescription (as received from the box) should be included.

Themanwithoutaplan commented 4 years ago

Ah, a case of a missing test case. I'll one for this.

kbr commented 4 years ago

Should I really squash and merge this again? Will your repository be still in sync afterwards?

Themanwithoutaplan commented 4 years ago

I've just pushed a commit with a function that uses requests. We can probably refactor this for more general use. Relying on etree.parse() to handle stuff, including things we don't control is asking for trouble.

Themanwithoutaplan commented 4 years ago

You can squash and merge. Worked fine yesterday and I've set my repo up to track your branch. It's just the usual dance of avoiding local changes before merging.

kbr commented 4 years ago

Ok. Here we go.

Themanwithoutaplan commented 4 years ago

No problems merging back in.