PDA

View Full Version : Drive eject/load over python command


tetzlav
2005-09-18, 03:19
is it possible do open the drive-tray with an phyton command. my dvd-drivbe has a bug and so i want to close its tray after startup xbmc autmatically.

greetings
tetzlav

solexalex
2005-09-18, 12:34
try this.
not tested ... so just tell me

what it does :
-wait 2 seconds to be sure... just in case
-test if cd tray is open
- if so, launch a command to close it

the test is important as it is the same command to open or close the tray
hope it works for you !
just copy the code below and past it inside a simple text file ; name it as you want .py (i.e autoclosecdtray.py) ; upload it in your xbmc script folder
if you want to launch it automatically at startup, name it autorun.py (or autoexec.py don't remember :( ) and place it exactly in your q:\script directory
import xbmc
from time import sleep
sleep(2) # suspend script for specified amount of time (secs) to wait for xbmc ready (maybe it is not essential... do not know)
if xbmc.getdvdstate==xbmc.tray_open:
xbmc.executebuiltin(xbmc.ejecttray())

tetzlav
2005-09-18, 15:51
thank you for the answer, but the xbmc.executebuiltin(xbmc.ejecttray())-command doesnt work for me.

i've tried this too (without sleep and tray-open-check)#! python
import xbmc
#from time import sleep
#sleep(2) # suspend script for specified amount of time (secs) to wait for xbmc ready (maybe it is not essential... do not know)
#if xbmc.getdvdstate==xbmc.tray_open:
xbmc.executebuiltin(xbmc.ejecttray())but this does nothing too. the pythonscripts had do be in cr or lf character set?

the eject/load-button in shutdown-submenu works fine.

further ideas!?

***edit***
i found the fault:
you have to encase the executebuiltin in two ' (apostrophe) like that#!python

import xbmc
xbmc.executebuiltin('xbmc.ejecttray()')
now the script works fine!

thanks!
***/edit***

greetings
tetzlav

solexalex
2005-09-19, 00:55
ok
sorry for this missing !
did you try my first script with single quotes ? does it work ?