[Pythonmac-SIG] how to eject a firewire drive

Piet van Oostrum piet at cs.uu.nl
Tue Mar 16 03:56:57 EST 2004


>>>>> <halloleo at fusemail.com> (L) wrote:

L> hi there
L> want to eject (logically) a firewire drive (iPod) through python.

L> however, i don't want to do it via an apple event to the finder. i tried
L> this via applescript: it reveals, that the finder pops up with a message
L> box, when i try to eject a drive currently in use. and excatly this message
L> i want to avoid and instead just wait a while and try again...

L> so, is there any way to do it in python with a native module, so that i can
L> intercept the success  status?

You can do it with command line programs. Call them with os.system,
fork/exec or spawn. 
First the output of the mount command will give you a line with your disk
in it, like:

/dev/disk1s1 on /Volumes/XXXX (local, nodev, nosuid)

grep for the volume name XXX.

Then issue the command:

hdiutil eject /dev/disk1

It will fail with an exit status 1 if the disk is busy.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Pythonmac-SIG mailing list