FalkTannhaeuser / python-onvif-zeep

ONVIF Client Implementation in Python 2+3 (using https://github.com/mvantellingen/python-zeep instead of suds as SOAP client)
MIT License
424 stars 138 forks source link

command python3 -mzeep https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl fails #56

Open peteratebs opened 4 years ago

peteratebs commented 4 years ago

working from commit: aae3def4385b0f8922e0e83b9cdcd68b2263f739

command python3 -mzeep https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl fails

The command fails while processing this code fragment of the file onvif.xsd:

        <xs:complexType name="CapabilitiesExtension">
                <xs:sequence>
                        <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unboundedaae3def4385b0f8922e0e83b9cdcd68b2263f739"/>
                        <xs:element name="DeviceIO" type="tt:DeviceIOCapabilities" minOccurs="0"/>
                        <xs:element name="Display" type="tt:DisplayCapabilities" minOccurs="0"/>

The exception message is as follows:

egg/zeep/xsd/types/complex.py", line 530, in signature
    value = ", ".join(parts)
TypeError: sequence item 0: expected str instance, NoneType found

I put the a patch in zeep/xsd/complex.py to work around this problem but wondering if this is a bigger problem. I've found another issue, but not directly related issue with this xml fragment that I'll post separately. .

This is the patched signature method.

    def signature(self, schema=None, standalone=True):
        parts = []
        LetAppendNull = True # set to true to let it fail
        for name, element in self.elements_nested:
            part = element.signature(schema, standalone=False)
            if LetAppendNull or part != None:
                parts.append(part)

        for name, attribute in self.attributes:
            part = "%s: %s" % (name, attribute.signature(schema, standalone=False))
            if LetAppendNull or part != None:
                parts.append(part)

        value = ", ".join(parts)
        if standalone:
            return "%s(%s)" % (self.get_prefixed_name(schema), value)
        else:
            return value