| | |
Handling CD Drives from python
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hey,
Just a simple question really, i was looking through the documentation for python and i couldn't find anything that did basic cd drive things, like ejecting it and stuff. The one module i did find 'cd' was only compatible on IRIX systems.
After failing miserably on google i was just wondering if anyone happened to know of a command or module that opens the cd drive, and reads from it, seems simple but meh..
I'm hoping theres something built in that does it.
Thanks,
a1eio
Just a simple question really, i was looking through the documentation for python and i couldn't find anything that did basic cd drive things, like ejecting it and stuff. The one module i did find 'cd' was only compatible on IRIX systems.
After failing miserably on google i was just wondering if anyone happened to know of a command or module that opens the cd drive, and reads from it, seems simple but meh..
I'm hoping theres something built in that does it.
Thanks,
a1eio
•
•
Join Date: Apr 2006
Posts: 148
Reputation:
Solved Threads: 40
•
•
•
•
yea, i forgot to mention, i'm trying to do this on a windows machine.
the os.popen idea did occur to me, but then i got stuck again.. :p i don't know the dos command for opening the cd drive.
thanks
a1eio
Python Syntax (Toggle Plain Text)
import pygame.cdrom as cdrom cdrom.init() cd = cdrom.CD(0) # 0 = first cdrom device cd.init() cd.eject() cd.quit() cdrom.quit()
or here's something i found GNU CD Input and Control Library . you can try it out.
•
•
Join Date: Jul 2008
Posts: 21
Reputation:
Solved Threads: 2
Is there any way (non platform-depended) to close the tray using python 3.
I couldn't find any function in the api of pygame.cdrom module. The best result so far is for Windows.
http://code.activestate.com/recipes/180919/
I couldn't find any function in the api of pygame.cdrom module. The best result so far is for Windows.
http://code.activestate.com/recipes/180919/
Here is one that works on Windows machines with Python3 ...
python Syntax (Toggle Plain Text)
# open and close the CD tray door (Windows OS) # tested with Python 3.1 import ctypes import time # open the CD tray door ctypes.windll.winmm.mciSendStringW("set cdaudio door open", None, 0, None) # wait 3.5 seconds time.sleep(3.5) # close the CD tray (manual closing only with some notebooks) ctypes.windll.winmm.mciSendStringW("set cdaudio door closed", None, 0, None)
May 'the Google' be with you!
![]() |
Similar Threads
- Starting Python (Python)
- Handling unicode values in python. (Python)
- Frequently Used Python Commands (Python)
- C++ CGI Scripts (C++)
- CD-ROm isnt working correctly (Storage)
Other Threads in the Python Forum
- Previous Thread: help? - dictionary search problem
- Next Thread: Beginners help!
| Thread Tools | Search this Thread |
accessdenied advanced aliased argv beginner bits calling casino change command convert count csv cturtle cursor def dictionary digital dynamic dynamically enter event examples external file float format frange function google gui hints homework i/o iframe import info input jaunty java keyboard lapse line linux list lists loop microphone mouse multiple newb number numbers obexftp output parameters parsing path port prime programming projects py py2exe pygame pygtk pyopengl python random recursion return scrolledtext signal skinning sprite stderr string strings subprocess table tennis terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 variable voip web-scrape whileloop windows wxpython






