Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Physiker83 opened this issue Feb 25, 2018 · 4 comments
Open

Comments

@Physiker83
Copy link

Physiker83 commented Feb 25, 2018

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

@tilltnet
Copy link
Contributor

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.

@Physiker83
Copy link
Author

Physiker83 commented Feb 26, 2018

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")

@svenfoo
Copy link

svenfoo commented Mar 1, 2018

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.

@zonque
Copy link

zonque commented Mar 2, 2018

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:

pysimplesoap/pysimplesoap#161

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants