[Tutor] Checking to see whether or not a filesystem is mounted--?
klappnase at freenet.de
Sun Aug 8 23:07:07 CEST 2004
On Sat, 07 Aug 2004 09:17:57 -0400
Marv Boyes <marvboyes at att.net> wrote:
> Anyway, enough preamble. I'm wanting to write a small graphical applet
> for mounting and unmounting filesystems with a button-press. Can anyone
> suggest a method for testing whether or not a particular filesystem is
> mounted (so I can inform the user with a message dialog)?
Another suggestion, which I found very handy for personal use:
device = sys.argv
mntlist = commands.getoutput('cat /etc/mtab').split()
if device in mntlist:
<ask the user to unmount, etc.>
This worked fine for me in a little program that I use to put icons on my desktop for floppy and cdrom
which allow to mount the device and open the file manager with a mouse-click as if I were using Gnome or KDE; "device" gets
of course passed to the app as command line argument( like '/mnt/floppy'), and if device is already mounted you are asked to
unmount it or just simply open the file manager there.
More information about the Tutor