Adding modules to Python Libs

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Alexpoet Offline
Skilled Python Coder
Posts: 172
Joined: Jun 2004
Reputation: 0
Location: Oklahoma City, OK
Post: #1
A million years ago, when the XB version of XBMC was the only one, I did some messing around with Python scripts.

One thing I love about Python programming (and it occurs just as much in XBMC development as elsewhere) is the portability of convenience modules. I made some standard Libs that I distributed with all my scripts back in the day, and I'm coming back to the same issues again.

Specifically, I've made a generic HTMLParser that, coupled with the HTTPAPI functionality, really simplifies database queries. I figure I'll be using this parser as a module in several plugins, so it makes sense to drop it in Libs.

Along the same lines, the guys who did the Apple Quicktime Movie Trailers plugin have implemented a lightweight module of pySQLite that works even on the XBox (which requires some effort). The built-in SQLite module isn't a built-in for the version of Python XBMC runs, so that module by the Quicktime guys becomes incredibly valuable to anyone who wants SQL functionality within a Python script or plugin. I've found myself copying their folder into several plugins already.

I would like to see a new folder added to the scripts and plugins SVN, for /python/Libs, so that developers can easily produce, distribute, and maintain these sort of support modules without having to try to keep them up across multiple script/plugin folders.

Anyone have any thoughts on this?

For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #2
I kind of agree, but back in the day the thought was these modules may change versions and old scripts would be incompatable. my thought was have xbmc include popular modules

but having them available in the svn repo is doable.

let's create a list of popular modules:

1. pysqlite2
2. elementtree
3. PIL (i use 1.6 that was beta so maybe PIL1.5 and PIL1.6)
...

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Alexpoet Offline
Skilled Python Coder
Posts: 172
Joined: Jun 2004
Reputation: 0
Location: Oklahoma City, OK
Post: #3
PIL would be absolutely awesome. I had no idea there was a version of it that would work in XBMC Python.

I remember three different projects that I gave up on just because the image manipulation wasn't there.

For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
find quote
Johnnyfive Offline
Junior Member
Posts: 40
Joined: Aug 2007
Reputation: 4
Location: Strasbourg, France
Post: #4
What about beautifulsoup?
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 959
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #5
what about updating python to v2.6 Smile

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
find quote
Alexpoet Offline
Skilled Python Coder
Posts: 172
Joined: Jun 2004
Reputation: 0
Location: Oklahoma City, OK
Post: #6
Now you're talking....

For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #7
i'm sure they would welcome a patch Smile

i think they're nearing a freeze and i imagine upgrading to 2.6 would be a big undertaking.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Alexpoet Offline
Skilled Python Coder
Posts: 172
Joined: Jun 2004
Reputation: 0
Location: Oklahoma City, OK
Post: #8
I can't see it being easy.

Sort of on-topic...anyone know how to get a list of the modules currently available to import? I looked in sys.builtin_module_names and sys.modules.keys(). That gives me all of the builtins (and, for XBMC, gives me the custom xbmc modules), but it doesn't give me everything.

As a quick example, the module random doesn't show up in either list (unless you explicitly import it, in which case it's added to the second one).

XBMC is still able to import random, and when you do it shows it as being in "Q:\system\python\python24.zlib\random.py" Anyone know how to peek inside python24.zlib, or know of a reference that can tell me what's in there?

For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #9
i use 7-zip.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
rwparris2 Offline
Team-XBMC Python Developer
Posts: 1,341
Joined: Jan 2008
Reputation: 2
Location: US
Post: #10
to the best of my knowledge everything in the python 2.4 standard library is in xbmc's python.

Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
find quote