XBMC Community Forum  

Go Back   XBMC Community Forum > Development > Plugin/Script (Python) Development

Plugin/Script (Python) Development Developers forum for XBMC Python Plugins/Scripts. Scripters/coders only!
Not for posting feature requests, bugs, or end-user support requests!

Reply
 
Thread Tools Search this Thread Display Modes
Old 2003-10-09, 17:19   #1
darkie
Team-XBMC Developer
 
Join Date: Sep 2003
Posts: 530
darkie is on a distinguished road
Default

first of all 'python 2.3' is embedded into xbmc and you the need to do the following to get it working

extract the directories from python.rar (cvs\xbmc\python\python.rar)
to "xbmc home dir\python\"
and if you want some examples you should extract scripts.rar(cvs\xbmc\scripts\scripts.rar)
to "xbmc home dir\scripts\"

you will now have the next directory structure in xbmc
xbmc
* python
* * * lib
* * * temp
* * * www
* scripts
* * * medusa

you execute scripts thrue the myscripts gui which is under settings->scripts.
currently there is no interaction with xbmc, for example you can't see any output from the python interpreter (this will be added because it's the only way to see where the script stops when an error occours)

included in scripts.rar are the next files
Quote:
chat-server.py: runs a chat server on port 4000
download_apleasure_zip.py: downloads a file from ftp and places it in your xbmc home dir
download_xskit303_exe.py: downloads another file from ftp
echo_server_port_50007.py: runs an echo server on port 50007
mp3.py: only used for testing and doesn't work
url_fetcher_asyncore.py: used for testing and doesn't work
weather.py: used for testing and doesn't work

medusa\start_medusa: runs an ftp / web and chat server on the ports 8021, 8080 and 8888
if you need any documentation or need more scripts examples you can try the official python website http://www.python.org
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


darkie is offline   Reply With Quote
Old 2003-10-10, 13:12   #2
Gamester17
Team-XBMC Project Manager
 
Gamester17's Avatar
 
Join Date: Sep 2003
Location: Sweden
Posts: 10,582
Gamester17 will become famous soon enough
Question

darkie, as the coder of xbmc's python interpreter can you tell us all a little more about the techical aspects behind it, things like; is it loaded into a pragma section?, is it or will it be loaded by default?, how much ram does it use?, once the python interpreter is loaded into memory will/can it be unloaded when not used anymore or is reboot nessesary?, once a python script is loaded into memory will/can it be unloaded when not running anymore?, where are you planning to take this development wise?, and how do you plan to implement it in the gui, now & later?

...and other things like that, tia
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Gamester17 is offline   Reply With Quote
Old 2003-10-11, 11:46   #3
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

>is it loaded into a pragma section?
yes it is

>is it or will it be loaded by default?
no

>how much ram does it use?
when loaded about 350kbyte

> once the python interpreter is loaded into memory will/can it be unloaded when not used anymore
no, sorry?,

>once a python script is loaded into memory will/can it be unloaded when not running anymore?
yes
frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-11, 14:57   #4
Gamester17
Team-XBMC Project Manager
 
Gamester17's Avatar
 
Join Date: Sep 2003
Location: Sweden
Posts: 10,582
Gamester17 will become famous soon enough
Unhappy

Quote:
Originally Posted by (frodo @ oct. 11 2003,09:46)
> once the python interpreter is loaded into memory will/can it be unloaded when not used anymore
no, sorry?
why? i mean it must be possible somehow, or isn't? this will be a challange for all you devs to figure out
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Gamester17 is offline   Reply With Quote
Old 2003-10-11, 16:13   #5
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

why?

cause darkie couldnt get it to work (yet)
hopefully he'll manage to fix it

frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-11, 18:35   #6
Gamester17
Team-XBMC Project Manager
 
Gamester17's Avatar
 
Join Date: Sep 2003
Location: Sweden
Posts: 10,582
Gamester17 will become famous soon enough
Default

Quote:
Originally Posted by (frodo @ oct. 11 2003,14:13)
why? cause darkie couldnt get it to work (yet)
hehe, i meant the technical reason. i already knew that it didn't, i just thought i start an open dev/code discussion here
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Gamester17 is offline   Reply With Quote
Old 2003-10-11, 19:33   #7
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

k here's why:

python is using lots of static functions & vars
the problem is that static functions & vars dont work with section loading. we didnt find a solution to this yet
there's one solution and thats 2 rewrite python so it doesnt use any static things anymore. but thats a lot of work
so if any compiler/xdk/c++ guru's know a way how to get section loading 2 work with static vars & functions please let us know
frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-13, 17:43   #8
darkie
Team-XBMC Developer
 
Join Date: Sep 2003
Posts: 530
darkie is on a distinguished road
Default

k, first of all, python is made for working in processes and not threads, that means if you run a program in windows and stop it, all used memory is given back to the operating system.
since the xbox doesn't work with processes used memory that isn't released by python won't be given back to the xbox.

python is managing memory in a special way. it doesn't allocate memory for every object or string that is created, but instead it allocates 256k(called an area) of memory at once and keeps track of all objects, strings that are placed in it.
once you don't need an object anymore, python removes it from the 256k area but doesn't give the memory back to the system, instead when a new object is created, this object is placed in that free part of the area. python does this because it is faster then allocating / deallocating memory.
when more then 256k of memory is needed another area of 256k is created and so on.
all these area's are only released when a proces ends, and there is the problem on the xbox. memory once needed for a script in python is never given back to xbmc.

python as it exists in xbmc is created with 2 pragma section: python and py_rw.
python is a section which contains *c / c++ code and memory that can't change, this section is about 800k.
py_rw contains variable memory that is modified when python is used, this section is about 300k.

at startup of xbmc none of these sections are loaded, python doesn't use any memory at all.

when a python script is selected in xbmc to execute. both python and py_rw are loaded into memory and python is initialized. at this moment 1200k of memory is used.
now the script is beeing executed and if it needs memory for storing stuff a new area (see above) is created.
that means that if a script uses 4 areas, a total of 4 * 256k + 1200k = 2200k of memory is used from the 64mb available on the xbox.

when the script ends, all 4 areas are cleaned so they can be used when an user selects a next script to execute( 4 * 256k of memory isn't given back to the xbox!).
section python will be unloaded by xbmc and py_rw is not unloaded.
at this moment, 1 mb for the areas and 300k for py_rw is in use by python.
if we select another script to run, section python is loaded again. if this scripts would need 750k of memory, python will use the existing areas for it. that means 2200k of memory is used

i didn't unload py_rw because loading it again will reset all memory. if we would unload py_rw and load it when we would need python again. python would think there where no areas created before and therefore creates new areas.
at this moment the 1 mb of areas created for the first script is lost and will never be used again (a memory leak of 1 mb!)

that was the technical part, so what can you expect to come.
well there are still some small bugs to fix (including 256k areas that are never given back to xbmc).
currently i am buzy to integrate some xbmc stuff into xbmc, like a yes / no dialog and the progress dialog. for example, you could use the progress dialog when downloading a file from ftp so an user could see how long it takes before it would finish.

darkie
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


darkie is offline   Reply With Quote
Old 2003-10-15, 09:20   #9
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

darkie, thx for the explanation.
i still think python in xbmc has a lot of potential
especially when its able to access xbmc stuff like dialogs,windows etc.
things i would like 2 see for python:

1. bind a button control to a script.
so pressing a button will run a script
2. python scripts should b able to use the controls like:
- cguiimage to display an image
- list control
- text area
- button
- spincontrol

3. mapping of keys -> python

with these 3 things one should b able to build almost anything in pyton

frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-18, 00:59   #10
darkie
Team-XBMC Developer
 
Join Date: Sep 2003
Posts: 530
darkie is on a distinguished road
Default

ok, made a little progress.
with python now, you can use the 4 dialogs (dialogok, dialogyesno, dialogselect, and dialogprogress)

Quote:
1. bind a button control to a script.
so pressing a button will run a script
2. python scripts should b able to use the controls like:
- cguiimage to display an image
- list control
- text area
- button
- spincontrol

3. mapping of keys -> python
1 and 2 are both possible, but what exactly do you mean with 3. mapping of keys -> python?
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


darkie is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running python-scrips from "My Videos" theni9e Plugin/Script (Python) Help and Support 23 2006-10-25 17:26
How about a "4:3 Expanded" view mode? ie. "16:9 Pan and Scan", or "14:9 Stretched" LaTropa64 XBMC Feature Suggestions 34 2006-09-27 12:47
Telnet/SSH access to XBMC python interpreter sumanthjv Plugin/Script (Python) Development 4 2006-03-23 15:02
python "loadskin" bitplane XBMC Feature Suggestions 1 2004-04-13 11:28
Stuck inside "My Videos" submenu bburtin XBMC for Xbox Specific Support 2 2004-02-26 08:42


All times are GMT +2. The time now is 16:11.


Protected by Akismet, We recommend WordPress blogs
Copyright © 2008, XBMC Project