PyRaumfeld icon indicating copy to clipboard operation
PyRaumfeld copied to clipboard

ExpatError: not well-formed (invalid token): line 1, column 185

Open Physiker83 opened this issue 7 years ago • 4 comments

Hi,

At first: Reaally cool library! Thanks for investing the time! I got the following error if I try to change something at a renderer:

2018-02-25 23:59:32,596 <?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:ChangeVolumeResponse xmlns:u=urn:upnp-org:serviceId:RenderingControl"></u:ChangeVolumeResponse></s:Body></s:Envelope>

Traceback (most recent call last):
  File "M:\Python_Skripte\Raumfeld\Test2.py", line 36, in <module>
    spbuero.changeVolume(int(-10))
  File "build\bdist.win32\egg\raumfeld\__init__.py", line 234, in changeVolume
    self._renderingControl.ChangeVolume(InstanceID=1, Amount=value)
  File "C:\Python27\lib\site-packages\pysimplesoap\client.py", line 175, in <lambda>
    return lambda *args, **kwargs: self.call(attr, *args, **kwargs)
  File "C:\Python27\lib\site-packages\pysimplesoap\client.py", line 258, in call
    jetty=self.__soap_server in ('jetty',))
  File "C:\Python27\lib\site-packages\pysimplesoap\simplexml.py", line 56, in __init__
    self.__document = xml.dom.minidom.parseString(text)
  File "C:\Python27\lib\xml\dom\minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "C:\Python27\lib\xml\dom\expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "C:\Python27\lib\xml\dom\expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
ExpatError: not well-formed (invalid token): line 1, column 185

My program is more a less like the example code...

# -*- coding: cp1252 -*-
import raumfeld
from time import gmtime, strftime
import logging
def dataHasBeenUpdated():
    print("########## " + strftime("%Y-%m-%d %H:%M:%S", gmtime()) + " ##########")
    print("Zones:")
    for zone in raumfeld.getZones():
        print("UDN: " + zone.UDN + " Name: " + zone.Name + " Location: " + zone.Location)
        for room in zone.getRooms():
            print("\tUDN: " + room.UDN + " Name: " + room.Name)
            for renderer in room.getRenderers():
                print("\t\tUDN: " + renderer.UDN + " Name: " + renderer.Name + " Location: " + renderer.Location + " Volume: " + unicode(renderer.volume))
     
    print("Unassigned Rooms:")
    for room in raumfeld.getUnassignedRooms():
        print("Name: " + room.Name + " UDN: " + room.UDN)
        for renderer in room.getRenderers():
            print("\tUDN: " + renderer.UDN + " Name: " + renderer.Name + " Location: " + renderer.Location)
    print("########## This gets updated when the config changes. To QUIT press any key... ##########")
  
raumfeld.setLogging(logging.WARN);
raumfeld.registerChangeCallback(dataHasBeenUpdated)
raumfeld.init() # or with the host IP: raumfeld.init("192.168.0.10")
print("Host URL: " +raumfeld.hostBaseURL)

buero = raumfeld.getRoomsByName(u'Büro')[0]
print(buero.Name)
for renderer in buero.getRenderers():
    print(renderer.Name + " " + renderer.UDN)
spbuero = buero.getRenderer("uuid:bac81551-8bbc-463b-9f3c-5953019abf87")
print(spbuero.Name)
spbuero.changeVolume(int(-10))
spbuero.stop()

What is the reason for that issue. I think it is something deep in the communication...

Thanks, Michael

Physiker83 avatar Feb 25 '18 23:02 Physiker83

Does the same thing happen, if you try it with a renderer, that has no Umlaut in its name?

Also, can you try and fix the formatting of your post? It's a bit hard to read in its current state.

tilltnet avatar Feb 26 '18 12:02 tilltnet

Sorry, it was late yesterday. I hope the format is better now...

I can try it with another receiver today evening.

Could it help to use this "u" before the receiver udn? buero.getRenderer(u"uuid:bac81551-8bbc-463b-9f3c-5953019abf87")

Physiker83 avatar Feb 26 '18 12:02 Physiker83

Looks like this is most likely caused by https://bugzilla.gnome.org/show_bug.cgi?id=793955

We will include a fix for this in the next firmware update.

svenfoo avatar Mar 01 '18 15:03 svenfoo

After some more investigation, it turns out that while gupnp should not reply with malformed XML, the real issue is a missing quoting in SOAPClient. I've filed a PR to fix this here:

https://github.com/pysimplesoap/pysimplesoap/pull/161

With this applied, the library works well with my setup.

zonque avatar Mar 02 '18 09:03 zonque