Drive eject/load over python command
#1
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
Reply
#2
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 Sad ) and place it exactly in your q:\script directory
Quote: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())
Reply
#3
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)
Quote:#! 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
Quote:#!python

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

thanks!
***/edit***

greetings
tetzlav



Reply
#4
ok
sorry for this missing !
did you try my first script with single quotes ? does it work ?
Reply

Logout Mark Read Team Forum Stats Members Help
Drive eject/load over python command0