analyzing removable media

glenn glenn at tangelosoftware.net
Fri Sep 29 21:05:51 EDT 2006


Nick Vatamaniuc wrote:
> 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
>
> It won't be trivial because one of the goals of the operating systems
> is to hide the differences between various types of storage devices and
> make them all look the same (i.e. a jump drive, a CD-ROM, a network
> volume are presented uniformly to the user as just another path in the
> file system).
>
> But you can probably use guesswork on unix OS's, as somebody above
> suggested, and examine the path. If the path contains common media
> mount points then that should give you a clue. On Windows you cannot
> easily know. For example if your file is on D:\file.txt, it is not
> immediatly obvious if D is a jumpdrive, a networked drive, a hard
> drive, or a CD-ROM.
>
> The only thing I can think of is to try to examine the Windows registry
> with the _winreg module. Here are the docs:
> http://docs.python.org/lib/module--winreg.html  There might be a key
> burried in there some place that will tell you which drives are what
> type.

ok - thanks - will look at that - Any one know what a Mac approach
might be? can I expect that playing anything I write with fstab or
`mount` will work on OSX?, or anyother BSD for that matter?




More information about the Python-list mailing list