Drive eject/load over python command

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
tetzlav Offline
Junior Member
Posts: 7
Joined: Aug 2005
Reputation: 0
Post: #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
find quote
solexalex Offline
Skilled Python Coder
Posts: 706
Joined: Jul 2004
Reputation: 6
Post: #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())
find quote
tetzlav Offline
Junior Member
Posts: 7
Joined: Aug 2005
Reputation: 0
Post: #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
find quote
solexalex Offline
Skilled Python Coder
Posts: 706
Joined: Jul 2004
Reputation: 6
Post: #4
ok
sorry for this missing !
did you try my first script with single quotes ? does it work ?
find quote