ElementTree.find on Mac? (Gotham/Mavericks)
#1
Hi all,

I'm trying to test my wip script on all the major platforms, but I'm having no luck with Mac. I can post a full log if its useful, but the salient part seems to be:

Code:
6:10:28 T:2961985536   ERROR: Traceback (most recent call last):
16:10:28 T:2961985536   ERROR:   File "/Users/andymorton/Library/Application Support/XBMC/addons/script.skinshortcuts/default.py", line 166, in __init__
16:10:28 T:2961985536   ERROR:     elem = tree.find('thumbnail[@labelID="' + listitem.getProperty( "labelID" ) + '"]')
16:10:28 T:2961985536   ERROR:   File "/Users/Shared/jenkins/workspace/XBMC-OSX-32/tools/depends/xbmc-depends/macosx10.8_i386-target/lib/python2.6/xml/etree/ElementTree.py", line 614, in find
16:10:28 T:2961985536   ERROR:   File "/Users/Shared/jenkins/workspace/XBMC-OSX-32/tools/depends/xbmc-depends/macosx10.8_i386-target/lib/python2.6/xml/etree/ElementTree.py", line 330, in find
16:10:28 T:2961985536   ERROR:   File "/Users/Shared/jenkins/workspace/XBMC-OSX-32/tools/depends/xbmc-depends/macosx10.8_i386-target/lib/python2.6/xml/etree/ElementPath.py", line 186, in find
16:10:28 T:2961985536   ERROR:   File "/Users/Shared/jenkins/workspace/XBMC-OSX-32/tools/depends/xbmc-depends/macosx10.8_i386-target/lib/python2.6/xml/etree/ElementPath.py", line 176, in _compile
16:10:28 T:2961985536   ERROR:   File "/Users/Shared/jenkins/workspace/XBMC-OSX-32/tools/depends/xbmc-depends/macosx10.8_i386-target/lib/python2.6/xml/etree/ElementPath.py", line 93, in __init__
16:10:28 T:2961985536   ERROR: SyntaxError: expected path separator ([)
16:10:28 T:2961985536   DEBUG: script.skinshortcuts: ### ERROR could not load file plugin://script.skinshortcuts/?type=launch&path=noop&group=mainmenu
16:10:28 T:2961985536   DEBUG: script.skinshortcuts: script stopped

The same code is working absolutely fine on Windows and Linux, so does this mean that elemtree.find is currently broken on Mac? Is there a special way of invoking Python on Mac? Or am I just missing something very obvious!

(Tested x86 and x64, latest nightly and latest monthly on Mavericks)

Any help would be appreciated.
Reply
#2
Hi,

I'm not 100% sure if this helps in your case but you could try the XBMC-Add-on Module ElementTree (instead the python builtin):

Add this to your addon.xml:
Code:
<import addon="script.module.elementtree" version="1.2.7"/>
Then you can import this module in your python code vide:
PHP Code:
from xml.etree.ElementTree import ElementTree 

Keep in mind that requirements via the addon.xml only get resolved while _installing_ such add-on. If you just add this (manually) to your local addon.xml it may not be resolved. Just install any other add-on which requires the same module to get it resolved (e.g. Programs->Playlists Script)

regards,
sphere
My GitHub. My Add-ons:
Image
Reply
#3
Thanks for the reply.

I thought I was using the plugin, as my code is something like the following (obv truncated)

Code:
import xml.etree.ElementTree as xmltree
tree = xmltree.parse( path )
elem = tree.find(' thumbnail[@labelID="' + labelID + '"]' )

However, I'm getting the same error whether or not I have the module installed, so now I'm not so convinced Smile I now know where to start looking to fix this, many thanks!
Reply
#4
(2013-12-16, 00:55)Unfledged Wrote: Thanks for the reply.

I thought I was using the plugin, as my code is something like the following (obv truncated)

Code:
import xml.etree.ElementTree as xmltree
tree = xmltree.parse( path )
elem = tree.find(' thumbnail[@labelID="' + labelID + '"]' )

However, I'm getting the same error whether or not I have the module installed, so now I'm not so convinced Smile I now know where to start looking to fix this, many thanks!

From your error message it looks like that the xbmc internal python ElementTree is in use:
Quote:16:10:28 T:2961985536 ERROR: File "/Users/Shared/jenkins/workspace/XBMC-OSX-32/tools/depends/xbmc-depends/macosx10.8_i386-target/lib/python2.6/xml/etree/ElementTree.py", line 614, in find

In the worst case there are three possible ElementTree modules:
1. XBMC Add-on ElementTree (path contains "addons")
2. XBMC shipped python (looks like the one in your log)
3. OSX Python (OSX comes with python pre-installed)

Good luck!
My GitHub. My Add-ons:
Image
Reply
#5
Thanks again for the help, sphere.

I've been able to get the plugin working using

Code:
import elementtree.ElementTree as xmltree

But still the same error (though with the path to the add-on this time). So, for now I'm going to assume that searching for an attribute in find just doesn't work on Mac and iterate through the items manually.
Reply
#6
'/Users/Shared/jenkins/workspace/XBMC-OSX-32/tools/depends/xbmc-depends/macosx10.8_i386-target/lib/python2.6/xml/etree/ElementTree.py' is the built path, runtime would not be the same path.
Reply

Logout Mark Read Team Forum Stats Members Help
ElementTree.find on Mac? (Gotham/Mavericks)0