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

Support XPath checks for documents containing an encoding header #29

Closed
languitar opened this Issue May 25, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@languitar
Copy link
Owner

languitar commented May 25, 2018

From #27 and @clemensvb

In analogy to your tvheadend check, I tried to implement a check for plex media sever. Via the URL a xml file is provided for which I implementet the following xpath-expression:

[check.Plex-Media-Server]
class = XPath
enabled = true
url = http://192.168.1.20:32400/status/sessions?X-Plex-Token=MEINTOKEN
xpath = /MediaContainer[@size>'0']

Unfortunately, the check produces an error, which I can't debug. Do you have any hints for me how to circumvent this?

Error output is:

DEBUG:Processor:Executing check Plex-Media-Server
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.20
DEBUG:urllib3.connectionpool:http://192.168.1.20:32400 "GET /status/sessions?X-Plex-Token=MEINTOKEN HTTP/1.1" 200 90
Traceback (most recent call last):
  File "/usr/local/bin/autosuspend", line 4, in <module>
    __import__('pkg_resources').run_script('autosuspend==2.0.0.dev0', 'autosuspend')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 719, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1504, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.5/dist-packages/autosuspend-2.0.0.dev0-py3.5.egg/EGG-INFO/scripts/autosuspend", line 1374, in <module>
    main()
  File "/usr/local/lib/python3.5/dist-packages/autosuspend-2.0.0.dev0-py3.5.egg/EGG-INFO/scripts/autosuspend", line 1370, in main
    fallback='/var/run/autosuspend-just-woke-up'))
  File "/usr/local/lib/python3.5/dist-packages/autosuspend-2.0.0.dev0-py3.5.egg/EGG-INFO/scripts/autosuspend", line 1169, in loop
    just_woke_up)
  File "/usr/local/lib/python3.5/dist-packages/autosuspend-2.0.0.dev0-py3.5.egg/EGG-INFO/scripts/autosuspend", line 1084, in iteration
    self._logger)
  File "/usr/local/lib/python3.5/dist-packages/autosuspend-2.0.0.dev0-py3.5.egg/EGG-INFO/scripts/autosuspend", line 983, in execute_checks
    result = check.check()
  File "/usr/local/lib/python3.5/dist-packages/autosuspend-2.0.0.dev0-py3.5.egg/EGG-INFO/scripts/autosuspend", line 883, in check
    if self.evaluate():
  File "/usr/local/lib/python3.5/dist-packages/autosuspend-2.0.0.dev0-py3.5.egg/EGG-INFO/scripts/autosuspend", line 251, in evaluate
    root = etree.fromstring(reply)
  File "src/lxml/etree.pyx", line 3213, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1871, in lxml.etree._parseMemoryDocument
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

I attached the two xml-Files to this post (saved to file via chromium browser), one when there is no client connected to the server and one with connections. Any help to get this running is much appreciated.

pms_sessions_streaming.txt
pms_sessions_no-streaming.txt

@languitar languitar added this to the 2.0 milestone May 25, 2018

@languitar languitar added the bug label May 25, 2018

@languitar languitar self-assigned this May 25, 2018

@languitar languitar closed this in 2369169 May 25, 2018

@languitar

This comment has been minimized.

Copy link
Owner

languitar commented May 25, 2018

@clemensvb: can you try the new version?

@clemensvb

This comment has been minimized.

Copy link

clemensvb commented May 25, 2018

@languitar: Works very well! Thanks again for your effort. If I may suggest, you should realy advertise the capability of your autosuspend deamon! It is the most versatile solution I found so far. The only thing I am looking forward very much is #24.
By the way, I am not a programmer, but I could offer to add the Plex-Solution to the documentation?

@languitar

This comment has been minimized.

Copy link
Owner

languitar commented May 25, 2018

Nice to see that #24 would actually be useful for someone. It was just a rough guess, because I don't actually need it. Could you please add a comment to your ticket with examples for rules that you need?

Feel free to create a pull request for the updated documentation.

@languitar languitar changed the title Make XPath check work with plex media server Support XPath checks with documents containing an encoding header May 25, 2018

@languitar languitar changed the title Support XPath checks with documents containing an encoding header Support XPath checks for documents containing an encoding header May 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment