Some Python posix-related questions
John Abel
john.abel at pa.press.net
Tue Feb 25 04:38:27 EST 2003
Hi,
Can only help you with no 1, I'm afraid. The easiest way, is to parse
/etc/mnttab, though again, this isn't that portable, though this is
basically what df does. If you do, then you could use:
def GetSpace( path ):
s = os.statvfs(path)
return s[statvfs.F_BAVAIL] * long(s[statvfs.F_BSIZE])
Regards
John
Tim Daneliuk wrote:
> 1) On Unix-like (posix) systems, is there some reasonably straighforward
> way to get the mount information back. What I really want is:
>
> - The device name
> - Total available space
> - Available free space
> - Mount point
>
> I would prefer to not have to parse the results of the 'df' command to
> do this, since I cannot guarantee portability of the output of this
> command on all systems.
>
> 2) What does Mac OS X return for os.name? I have a program that is
> coded to work properly when os.name returns 'nt' or 'posix'. I
> was kinda hoping that OS X returns 'posix' (and my program should
> thus work there), as I have no access to such as system.
>
> TIA,
> ------------------------------------------------------------------------------
> Tim Daneliuk
> tundra at tundraware.com
>
More information about the Python-list
mailing list