analyzing removable media

Jay jaysherby at gmail.com
Fri Sep 29 02:16:50 EDT 2006


Well, in linux you can get a lot of info about where a file is based
upon where it lies in the file system.  For example, if the folder the
file is located in resides in the /media or /mnt directories, then the
file is, barring a few rare circumstances, located upon a removable
medium of some sort.  Once you get the name of that directory that is
right below /media or /mnt, then you can cross check the name in
/etc/fstab file.

However, the contents of your post lead me to believe that you're
working in a win32 environment.  That's a bit trickier.  Things aren't
so simple.  You could probably grab similar information from the full
path itself.  For example, just getting the drive letter that the file
resides on could tell you a lot.  Now, where you'd cross check that is
more of a mystery to me.  I'd guess the registry?  For an easier way of
accessing the registry, I believe that the wrapper pywin32 may be of
interest to you.  It shouldn't be that hard considering that you'd only
be getting some information, not setting anything.

If by chance we're talking about MacOS, I'm of almost no help.  In the
case of MacOS X, it has a unix core, so I'd imagine that the method I
described for linux could probably be adapted.

Jay

glenn wrote:
> Hi
> can anyone tell me how given a directory or file path, I can
> pythonically  tell if that item is on 'removable media', or sometype of
> vfs, the label of the media (or volume) and perhaps any other details
> about the media itself?
> thanks
> Glenn




More information about the Python-list mailing list