xAP Plugin

Questions and comments specific to a particular plugin should go here.

Re: xAP Plugin

Postby kgschlosser » Wed May 11, 2016 5:38 am

ok all fixed

added a couple things and change a couple of things while i was at it (things i didn't like)

client mode:
#1: added/fixed: there is no need to have to put single quotes around the {eg.event.payload} for the global to be evaluated the new way the data is handled corrected that

#2: added: client mode allows for different client names other than the xAP-Client for it to process an event. what it will do if the client name is other than the xAP-Client it will append the client name that is in the target to the suffix of the event if there is a suffix otherwise it will become the suffix

#3: added: the suffix and payload if they are either 'None' or not there at all will not be processed

#4: added: if by some chance something gets booger'd up and the Prefix is either not there or is a 'None' it would throw a plugin stopping traceback, there is handling built in for that to notify you of the problem

config panel:
#1: added/fixed: i changed the layout because if you are like me and have EG running on a machine with a limited resolution that was shorter than the dialog it was annoying to have to maximize to accept or close the thing

#2: fixed: jumping of the debug/Ignore when you checked/unchecked an item

#3: fixed: checkall/uncheckall buttons in the debug/ignore

#4 added: view payload option (don't remember if i released a version with this yet) the payload data is written to the eg.result all the time but because the data is large in size it clogs up the EG log so i provided an option to shut off the payload but again the data is always accessible from the eg.result and optionally from the eg.event.payload

server:
#1: added: modified the server bits so that if you have Logitech Media Server(LMS) running on the same machine as EG with this plugin and do not have the xAP plugin for the LMS in external hub mode it will notify you of the problem.

data parser:
#1: fixed: re coded a very large portion of the data handler there was an issue with having '=' in any of the data being sent. so that is all corrected and has opened up to other corrections as mentioned above it also reduced the amount of code (thought of a much better way to parse the data)


attached is a sub release to get a run through before i post it to the beginning thread page

thanks again K
Attachments
__init__.py
(40.26 KiB) Downloaded 53 times
A loved one and Time, The 2 things that can never be replaced.

Family, The only thing you don't get to choose in life.
User avatar
kgschlosser
Site Admin
 
Posts: 1467
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: xAP Plugin

Postby V_J » Mon Aug 01, 2016 8:05 am

Hello!

I yesterday got an error message about an improperly formatted field. It was during the playback of a streaming radio station, where the url contained special characters (/,&, ...). I was unable to copy the data and am now not sure I had the last version of the XAP plugin... I will be able to check later this week (Tuesday or Thursday at the earliest): first update to latest XAP, then post the excerpt of the log file if it still occurs (or confirm that it does not :)).


Jörg
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby kgschlosser » Mon Aug 01, 2016 9:53 am

sure thing. i do remember fixing a problem due to the special characters thing. so it may or may not be fixed this could be a new error
A loved one and Time, The 2 things that can never be replaced.

Family, The only thing you don't get to choose in life.
User avatar
kgschlosser
Site Admin
 
Posts: 1467
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: xAP Plugin

Postby V_J » Tue Aug 09, 2016 10:18 am

I did not forget it, but two computers started acting up after the Windows 10 anniversary update. First needed to fix that. :)
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby V_J » Wed Aug 10, 2016 2:41 pm

(do not install Symantec Workspace Virtualization on Windows 10 anniversary update: I learned that the hard way. It gets the system in a bluescreen loop, the software refused to uninstall in safemode and disabling it in safe mode also does not help :roll: Reinstall is the only way out it seems)

Ok, managed to get back to it. I used the file you uploaded most recently; in this post:
viewtopic.php?f=9&t=8121&start=45#p40137

It does not throw the error, but it breaks compatibility with my script... With the previous xap plugin, I used the following script to send the payload as a http post:
Code: Select all
import urllib2
import urllib
# create a password manager
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
# Add the username and password.
# If we knew the realm, we could use it instead of None.
top_level_url = "http://192.168.2.3:80/dev/sps/io/SetStudySqueezeboxAlbum/"+urllib.quote(eg.event.payload["Album"])
password_mgr.add_password(None, top_level_url, "admin", "admin")
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
# create "opener" (OpenerDirector instance)
opener = urllib2.build_opener(handler)
# use the opener to fetch a URL
opener.open(top_level_url)
# Install the opener.
# Now all calls to urllib2.urlopen use our opener.
urllib2.install_opener(opener)


With the latest xap plugin, I get this error:
Code: Select all
Traceback (most recent call last):
Python script "15", line 7, in <module>
top_level_url = "http://192.168.2.3:80/dev/sps/io/SetStudySqueezeboxAlbum/"+urllib.quote(eg.event.payload["Album"])
TypeError: 'NoneType' object is unsubscriptable


EDIT: First I thought it It may be related to the Miniserver, but later I realized its last update is from before the previous version.

So it looks like the xap plugin behaves ok regarding the characters (unless there was something very specific about that previous internetstream, but I doubt it: I was listening to the same internet radio) but gives another issue... Did the type of the payload change? And do I need to do something else to get to it? (it worked before with this script)


I will run a few more experiments, as I have some other ideas (e.g. if it is an internet stream, the squeezebox server probably does not send all the attributes).


Jörg
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby V_J » Thu Aug 11, 2016 10:37 am

I'm not at that computer now, but compared the python files: I just replaced the python file with the one from the post. But it looks like it adds some more configuration options: Payload. As I did not set anything in the plugin configuration, that one is most likely disabled. I'll verify this and see what happens if I enable that. :)
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby kgschlosser » Thu Aug 11, 2016 10:48 am

that is probably what it is.


because of the amount of xap data that is tossed about it congests the log up a lot. so if you disable the payload you can use the eg.result to access the data instead
A loved one and Time, The 2 things that can never be replaced.

Family, The only thing you don't get to choose in life.
User avatar
kgschlosser
Site Admin
 
Posts: 1467
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: xAP Plugin

Postby V_J » Thu Aug 11, 2016 11:54 am

Thank!
Is eg.result use in the same way as eg.event.payload (ie is it also a dictionary)?
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby kgschlosser » Thu Aug 11, 2016 3:48 pm

sure is. use it exactly the same way
A loved one and Time, The 2 things that can never be replaced.

Family, The only thing you don't get to choose in life.
User avatar
kgschlosser
Site Admin
 
Posts: 1467
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: xAP Plugin

Postby V_J » Fri Aug 12, 2016 3:42 pm

It works!
Just one weird behaviour... on this event:
--
ersp.SlimServer.Origen:Living.xAP-Audio.Transport.Event {'Class': 'xAP-Audio.Transport.Event', 'Repeat': 'off', 'Shuffle': 'none', 'UID': 'xx.xxxxxxxxx:xxxx', 'Playerid': 'xx:xx:xx:xx:xx:xx', 'Elapsed': '00:00', 'Source': 'ersp.SlimServer.Origen:Living', 'Hop': '1', 'V': '13', 'Type': 'Audio.Transport', 'Remaining': '03:35'}
--

I get the following error if I try to extract data for repeat, shuffle or remaining.
--
Traceback (most recent call last):
Python script "61", line 7, in <module>
top_level_url = "http://xxx.xxx.xxx.xxx:xx/dev/sps/io/SetLivingSqueezeboxRepeat/"+urllib.quote(eg.result["Repeat"])
KeyError: 'Repeat'
--
From that same event, I can get Elapsed...

FWIW, I get the same error for e.g. the Artist field when listening to an internet radio: I suspect the artist field for those is empty. The repeat/shuffle/remaining problem however occurs also when playing music for the library, which has these values...

Any thoughts?


Jörg
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby kgschlosser » Fri Aug 12, 2016 5:02 pm

well i have the debug set in place for those exact reasons. so turn it on for that xAP device. and see if the data being sent in actually has those keywords in the message body. because sometimes they don't have the same keywords in all of the messages.

so using something as follows is a good way to catch error.

Code: Select all

try:
    top_level_url = "http://xxx.xxx.xxx.xxx:xx/dev/sps/io/SetLivingSqueezeboxRepeat/"+urllib.quote(eg.result["Repeat"])
except KeyError:
    pass
else:
    CONTINUE THE REST OF THE CODE HERE


that is to catch the error

or if you want to avoid it

Code: Select all

if 'repeat' in eg.result:
    top_level_url = "http://xxx.xxx.xxx.xxx:xx/dev/sps/io/SetLivingSqueezeboxRepeat/"+urllib.quote(eg.result["Repeat"])
    CONTINUE THE REST OF THE CODE HERE



the debug option will print the whole message into the log exactly as it came in. letting you know if the message just didn't have that keyword. but it will also tell you ones you didn't know about.

I am thinking that maybe i will create secondary window for the debug so it will be easier to sort through the debug data. but in the meantime if you download my Auto Scroll Lock plugin it will allow for simple backwards scrolling of the EG log without having to click down on the scroll check box at the bottom of the EG window and remembering to uncheck it.
A loved one and Time, The 2 things that can never be replaced.

Family, The only thing you don't get to choose in life.
User avatar
kgschlosser
Site Admin
 
Posts: 1467
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: xAP Plugin

Postby V_J » Sat Aug 13, 2016 6:58 pm

kgschlosser wrote:well i have the debug set in place for those exact reasons. so turn it on for that xAP device. and see if the data being sent in actually has those keywords in the message body. because sometimes they don't have the same keywords in all of the messages.

I will try to debug it. The event I posted was exactly the one after which it could not find Repeat, Shuffle or Remaining, even though the were clearly present in the event as printed in the log. It will take me some time though before I can do it.
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby kgschlosser » Sat Aug 13, 2016 7:27 pm

If you add a

Code: Select all
print eg.result


Before this line

Code: Select all
"http://xxx.xxx.xxx.xxx:xx/dev/sps/io/SetLivingSqueezeboxRepeat/"+urllib.quote(eg.result["Repeat"])


It will print the eg.result for me. I need to see what that variable looks like
A loved one and Time, The 2 things that can never be replaced.

Family, The only thing you don't get to choose in life.
User avatar
kgschlosser
Site Admin
 
Posts: 1467
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: xAP Plugin

Postby V_J » Tue Aug 16, 2016 7:59 am

Debugging prints a lot of info... I think I may have found the issue: some things look a bit out of order. There are two xap packets sent immediately one after the other, one relates to xAP-Audio.Transport; the other to xAPBSC.Info. I want the first one. I suspect that while the macro is running, the next xap packet arrives and changes the value of eg.result.
The reason is that it sometimes works and sometimes throws the error. At the moment, I have 4 actions following one event. I will put it all together into 1 action, and see if it still occurs.
V_J
Experienced User
 
Posts: 155
Joined: Tue Mar 04, 2014 9:00 am

Re: xAP Plugin

Postby kgschlosser » Tue Aug 16, 2016 7:39 pm

It could. Because it does run in its own thread. So if something has been queued into the eventqueue then the xap plugin would continue to run.

So use the payload option and see if that fixes it. And if it does I will create a way for you to poll either the event or to pass the eventstring to an action to get the results. Once that has been done the event data will be deleted.

I am pretty sure that you are correct about the result data changing. Because the eg.event.payload doesn't actually get set until the event is printed to the log. So no conflict like this could arrive. I am thinking of a different way to work this bit. Or I could make an object from the actual event data.

So you could do something like this.

Code: Select all
songObj = eg.event.payload()
"http://xxx.xxx.xxx.xxx:xx/dev/sps/io/SetLivingSqueezeboxRepeat/"+urllib.quote(songObj.Repeat)


The purpose for initializing the object would be to set the gears into motion for flagging that it has been read. And at the end of your script you would do songObj.Destroy().

The object if read would stop an automatic deletion. And you could grab the data via eg.plugins.xAP.THEEVENTNAME

Only if the same event was triggered would it delete the object and create another with the same event name. But with updated data in it.

Could be handy if you just want to set up A polling thread to monitor the data and send whatever whenever for updating purposes. But if you wanted to do that from a script you will have to wait a little bit longer until I finish up my script editor plugin. Which allows for threading without hanging EG up
A loved one and Time, The 2 things that can never be replaced.

Family, The only thing you don't get to choose in life.
User avatar
kgschlosser
Site Admin
 
Posts: 1467
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

PreviousNext

Return to Plugin Support

Who is online

Users browsing this forum: No registered users and 5 guests